- Back to Home »
- Logical vs Physical Address Space
Logical vs Physical Address Space:
A process can change place in memory for the following three main reasons:
- If a process CPU time-slice has ended, the process must be unloaded from memory and put in the ready queue to be loaded again at a later stage. By this way space is made available to another process.
- If a process enters a block state (by calling an I/O function) then again it must be unloaded and put in the blocked queue to be loaded later.
- If compaction is applied it may be possible that a process changes its position.
In all the above cases, the process is being reallocated in memory. It must be possible for a process to be loaded at any address selected by the operating system. The mechanism involved in the reallocation of processes is shown below:
When a process is loaded in memory, the physical address of the first location is put in the base register. All process addresses are interpreted as being relative to this base address. Thus to map a process address a to the physical address, the operating system will add the address a to the base B.
Suppose the base address is 5000 and a 'JUMP 100' instruction is encountered. The physical address for the jump is 5000 + 100 = 5100.
By the above mechanism, relocation is accomplished by simply moving the process and resetting the base address to the appropriate value.
- The limit register is used to hold the highest memory location that a process can access. By this way, each process is protected from other processes in memory.
- A logical address is expressed as a location relative to the beginning of the process (program). Instructions in the program contain only logical addresses.
- A physical address is of course an actual location in main memory.