Logical- Versus Physical-Address Space
Logical versus physical Address, The logical address is a virtual address. It can be viewed by the user. The user can’t see the physical address directly. The logical address is used as a reference, to access the physical address.
- An address generated by the CPU is commonly referred to as a logical address or a virtual address whereas an address seen by the main memory unit is commonly referred to as a physical address.
- The set of all logical addresses generated by a program is a logical-address space whereas the set of all physical addresses corresponding to these logical addresses is a physical address space.
- Logical and physical addresses are the same in compile-time and load-time address-binding schemes; logical (virtual) and physical addresses differ in the execution-time address-binding scheme.
- The Memory Management Unit is a hardware device that maps virtual to physical address. In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory as follows:
(Dynamic relocation using a relocation register)
Dynamic Loading
- It loads the program and data dynamically into physical memory to obtain better memory-space utilization.
- With dynamic loading, a routine is not loaded until it is called.
- The advantage of dynamic loading is that an unused routine is never loaded.
- This method is useful when large amounts of code are needed to handle infrequently occurring cases, such as error routines.
- Dynamic loading does not require special support from the operating system.
Dynamic Linking
- Linking postponed until execution time.
- A small piece of code (stub) used to locate the appropriate memory-resident library routine.
- Stub replaces itself with the address of the routine and executes the routine.
- The operating system needed to check if the routine is in processes memory address.
- Dynamic linking is particularly useful for libraries.
Overlays
- Keep in memory only those instructions and data that are needed at any given time.
- Needed when the process is larger than the amount of memory allocated to it.
- Implemented by the user, no special support needed from the operating system, programming design of overlay structure is complex.
Swapping
- A process can be swapped temporarily out of memory to a backing store (large disc), and then brought back into memory for continued execution.
- Roll out, roll in: A variant of this swapping policy is used for priority-based scheduling algorithms. If a higher-priority process arrives and wants service, the memory manager can swap out the lower-priority process so that it can load and execute the higher-priority process. When the higher-priority process finishes, the lower-priority process can be swapped back in and continued. This variant of swapping is called roll out, roll in.
- A major part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped.
- Modified versions of swapping are found on many systems (UNIX, Linux, and Windows).