cs418 2
cs418 2
Lecture 2
1
1. Early Memory Management Systems
• In the early days, a computer can only have one user at one
time. Moreover, a computer can only run a program at a time.
To run a program, it must be entirely and contiguously loaded
into memory. The memory management is therefore easy.
• Algorithm: Load a job in a single-user system
– 1. Store first memory location Y of program into
base register
– 2. Set program counter = Y
– 3. Read first instruction of program
– 4. Increment program counter by # of bytes of
instruction
– 5. Last instruction?
– if YES, then stop loading
– if NO, then continue with step 6
– 6. Program counter > memory size?
– if YES, then stop loading
– if NO, then continue with step 7
– 7. Load instruction to memory
– 8. Read next instruction of program
– 9. Go to step 4
2. Fixed (Static) Partitions
• When memory spaces are not used anymore they must be re-
leased (returned back to) the system.
• Fixed partition: easy! just reset the ’free/busy’ status variable.
• Dynamic partition: we need to combine free areas of memory.
• Think of 3 situations when a block is to be released:
• Algorithm: Dynamic partition–memory dealloca-
tion
– 1. If job location is adjacent to one or more
free blocks
– then
– if job location is between 2 free blocks
– then merge all three blocks into one.
– memory size(i-1)=memory size(i-1)
– +job size+memory size(i+1).
– set the status of memory size(i+1)
– to NULL.
– else merge both blocks into one
– memory size(i-1)=memory size(i-1)
– +job size.
– else search for NULL entry in free memory
– list.
– enter job size and beginning address
– in the entry list.
– set its status to FREE.
5. Relocatable Dynamic Partitions
• Overhead!
• When should we use relocatable dynamic partition?
– 1. When memory is busy.
– 2. When many jobs are waiting.
– 3. When the waiting time is too long.
• What can we learn from relocatable dynamic partition?
– 1. Programs do not have to be stored completely in mem-
ory.
– 2. Programs do not have to be stored contiguously in mem-
ory.