Help!!!!! I'm sorry to ask for help again but......
This question even difficult than the previous one.....


Please write C++ code for the following algorithm:

1) Store first memory location of program into base register
2) Set program counter equal to address of first memory location
3) Load instruction of program
4) Increment program counter by number bytes in instruction
5) Has the last instruction been reached?
if yes, then stop loading program
if no, then continute with step 6
6) Is program greater than memory size?
if yes, then stop loading
if no, then continute with step 7
7) Load instruction in memory
8) Go to step 3

P/S: This is a algorithm to load a job in a single-user system
Please help.....
Is not that I'm lazy but I really weak in C++.....

Okay that's it. Nobody is going to spoon feed you. If you are weak in C++, you study. If you can't do an assignment, you don't take it. If you have this assignment for a course you don't enroll in it. This is not anybody's free homework service. You try it first, and post it. Not just the above pseudocode written inside code tags and a main function. It should be pure C++. Unless the reply is satisfying enough no further help will be offered.

#include<iostream.h>

void main()
{
    int memory_location, base_register, byte, memory_size ;

    memory_location = 1 ;

    base_register = memory_location ;
    
    while( true )
    {
        cout<<"Please enter the number of bytes in instuctions" ;
        cin>>byte ;

        memory_size = byte ;
    
        for( int counter = memory_location ; counter <=byte ; counter++)
        {
            if( counter < byte )
                break ;
            else
            if( counter > memory_size )
                break ;
        }
    }
}

If this one is not satisfied by you......
Then I think I should do wat you said: Giv up on my course......
Really.....Coz I hav try my best.....
But I really beg you if you don satisfied can you tell the reason?
Coz maybe I can modified until it is satisfied by you......
Thanks for your attention and reply......

You must be in an operating systems course. Now I want you to explain me what are the characteristics of a Single-User Memory System. I don't want your lecture notes copied and pasted here directly. I already have them with me. I want your explaination in your own words.

Then tell me what are the constant parameters of a given Single-User memory system.

As for the code, let's start by learning this simple correction.

#include<iostream> // Not <iostream.h>

int main() // Not void main()
{
          return 0; // This is not necessary, if this is omitted the standard assumes that main returns 0. But to be explicit just add this.
}

Let's work on the other parts as we go on.

Alright.....
Thanks 4 your reply....
Hmm....Single-user system....
Is a early system of memory management.....
Each program loaded in its entirely into memory and allocated as much contiguous memory space as needed
So only a program can run at one time....
Also, if a program is too large for the memory,
it can't run.....
For single-user system, it need 2 hardware:
1) Register to store base address
2) Accumulator to track size of program as it is loaded into memory

Correct right?

I not really know about constant parameter in single-user memory system coz my lecturer didn't say 'bout it....
Yup...I'm taking OS course......
But I 'll try to answer it....
For me constant variable are total memory size and base register....

Oh.....OK....iostream without ".h"....
Thanks....

Is a early system of memory management.....
Each program loaded in its entirely into memory and allocated as much contiguous memory space as needed
So only a program can run at one time....
Also, if a program is too large for the memory,
it can't run.....
For single-user system, it need 2 hardware:
1) Register to store base address
2) Accumulator to track size of program as it is loaded into memory

Correct right?

I told you no lecture notes, but the answer is accepted.

I not really know about constant parameter in single-user memory system coz my lecturer didn't say 'bout it....
Yup...I'm taking OS course......
But I 'll try to answer it....
For me constant variable are total memory size and base register....

Good. You are doing fine.

The base register is not needed for the simulation, so I will discard it.Also I will add an additional constant called NUMER_OF_BYTES_PER_INSTRUCTION.

Now you add the following constants in C++ to the int main function I gave you earlier.
Total Memory Size - You can use any realistic value
Number of bytes per instruction - This is also any realistic value you like.

Also tell me the input needed from the user to simulate the job loading function, and the other variables that will be used while the program is running.

This article has been dead for over six months. Start a new discussion instead.