2. Background
• Program must be brought (from disk) into memory and placed within
a process for it to be run
● Main memory and registers are only storage CPU can access directly
● Memory unit only sees a stream of addresses + read requests, or
address + data and write requests
● Register access in one CPU clock (or less)
• Cache sits between main memory and CPU registers
• Protection of memory required to ensure correct operation
4. Address Binding
• Address binding is a technique of generating addresses to the
instruction of programs
• Address binding is the process of mapping from one address space to
another address space.
• Address binding of instructions and data to memory addresses can
happen at three different stages
Compile time:
Load time:
Execution time
5. Binding of Instructions and Data to Memory
• Compile time: If memory location known a priori, absolute code can be
generated; must recompile code if starting location changes
• Load time: Must generate relocatable code if memory location is not known
at compile time
• Execution time: Binding delayed until run time if the process can be moved
during its execution from one memory segment to another
6.
7. Logical vs. Physical Address Space
• Logical address – generated by the CPU; also referred to as virtual address
• Physical address – address seen by the memory unit
• The run time mapping from a logical address to physical address is done by a
hardware device called MMU.
• Logical address space is the set of all logical addresses generated by a
program
• Physical address space is the set of all physical addresses generated
by a program
8. Dynamic relocation using a relocation register
Hardware device that at run time
maps virtual to physical
address
● To start, consider simple scheme
where the value in the
relocation register is added to every
address generated by a
user process at the time it is sent to
memory
● Base register now called
relocation register
9. Dynamic loading
• With dynamic loading, a routine is not loaded until it is called.
• All routines are kept on disk in a relocatable load format.
• The main program is loaded into memory and is executed. When a routine
needs to call another routine, the calling routine first checks to see whether
the other routine has been loaded.
• If not, the relocatable linking loader is called to load the desired routine into
memory and to update the program's address tables to reflect this change.
• Then control is passed to the newly loaded routine.
• The advantage of dynamic loading is that an unused routine is never
loaded.
10. Dynamic linking
• In static linking, the system libraries are treated like any other object
modules and combined by the loader into the executing program.
• The dynamic linking, similar to dynamic loading is delayed until run-time.
• With static linking library modules get fully included in executable
modules, wasting both disk space and main memory usage, because every
program that included a certain routine from the library would have to
have their own copy of that routine linked into their executable code.
• With dynamic linking, however, only a stub is linked into the executable
module, containing references to the actual library module linked in at run
time.
• This method saves disk space, because the library routines do not need to be fully
included in the executable modules, only the stubs.
11. swapping
• A process must be in the main memory before it starts execution.
• So, a process that is ready for execution is brought in the main memory.
• Now, if a running the process gets blocked.
• The memory manager temporarily swaps out that blocked process on to
the disk.
• This makes the space for another process in the main memory.
• So, the memory manager swaps in the process ready for execution, in the
main memory, from the disk.
• The swapped out process is also brought back into the main memory
when it again gets ready for execution.
12.
13. Memory protection
Relocation registers used to protect user
processes from each other, and from
changing operating-system code and
data
• Base register contains value of
smallest physical address
• Limit register contains range of
logical addresses – each logical
address must be less than the
limit register
• MMU maps logical address
dynamically