Program must be brought (from disk) into memory and placed within a process for it to be run
Main memory and registers
Only storage CPU can access directly
Memory
Consists of a large array of bytes
Memory unit
Only sees a stream of addresses + read requests, or address + data and write requests
Register access
Done in one CPU clock (or less)
Main memory access
Can take many cycles, causing a stall - memory does not have the data required to complete the instruction that it is executing
Cache
Sits between main memory and CPU registers
Protection of memory is required to ensure correct operation
Base and limit registers
Define the logical address space of a process
CPU must check every memory access generated in user mode to be sure it is between base and limit for that user
The instructions to loading the base and limit registers are privileged
Symbolic addresses
Addresses represented in source code
Relocatable addresses
Addresses that bind to a specific location at a later stage
Absolute addresses
Final addresses that a program will execute at
Address binding
1. Compile time
2. Load time
3. Execution time
Logical address is generated by the CPU; also referred to as virtual address
Physical address is the address seen by the memory unit
Logical and physical addresses are the same in compile-time and load-time address-binding schemes; logical (virtual) and physical addresses differ in execution-time address-binding scheme
Logical address space is the set of all logical addresses generated by a program
Physical address space is the set of all physical addresses corresponding to these logical addresses
Memory-Management Unit (MMU)
Hardware device that at run time maps virtual to physical address
Relocation register
The value in the register is added to every address generated by a user process at the time it is sent to memory
The user program deals with logical addresses; it never sees the real physical addresses
Execution-time binding occurs when reference is made to location in memory
Logical address bound to physical addresses
Dynamic loading
Routine is not loaded until it is called
No special support from the operating system is required for dynamic loading
Dynamic linking
Linking postponed until execution time
Stub
Small piece of code used to locate the appropriate memory-resident library routine
Operating system checks if routine is in processes' memory address, and if not, adds it to the address space
Contiguous allocation
Main memory is divided into two partitions: resident operating system in low memory, and user processes in high memory
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
Variable partition
Multiple-partition allocation with variable-sized partitions
Hole
Block of available memory; holes of various size are scattered throughout memory
Operating system maintains information about allocated partitions and free partitions (holes)
Dynamic storage-allocation algorithms
First-fit
Best-fit
Worst-fit
External fragmentation
Total memory space exists to satisfy a request, but it is not contiguous