Day 103 - Logical vs. Physical Address Space

We know that in order for a process to execute it has to be in memory and in memory it is assigned to a physical address space from which a CPU can fetch it to execute. A process can change these places in memory for some reasons. These reasons are following.

  • A process must be unloaded from the memory if its CPU time has ended. It can be reloaded back into the memory to complete its execution. This loading and unloading gives time to other processes to execute.
  • A process must be unloaded from the memory if it enters block state by calling some I/O function. It is them added into block queue to be loaded later.
  • The process may change its position if compaction is applied.

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.

When a process is loaded into the memory its first physical address location is put into the base register. All process addresses are interpreted as being relative to this base address. Now to map the address a to the physical location in the memory the OS add the address a to the base register B.

Suppose the base address is 1000 and a JUMP 100 instruction is encountered. Now the physical address of the jump instruction is 1000 + 100 = 1100.

By this mechanism the process is reallocated by just moving the process to a different place int he memory and setting the base register value to an appropiate location.

  • A limit register is used know what is the highest memory location a process can access in order for other processes to protect them from other process's interference.
  • A logical address is a relative location to the first address of the process. All the instrucitons in the progams are logical addresses.
  • A physical address is the actual space in the memory.

Happy Ramadan To All Of You.


zainscizainsci