Virtual Memory Management Flashcards
What is virtual memory used for?
Processes addresses a virtual address space. Virtual memory is larger than physical memory.
What is swapping?
Swap complete processes in and out of physical memory. Save/load from disk on very context switch, and restore paging tables.
What is demand paging?
Contents of virtual address space held on disk. Pages are copied to physical memory as needed by the Pager.
What are the benefits of demand paging?
Programmer isn’t concerned with amount of physical memory, making programming simpler and portable.
More ps can be run concurrently.
Less IO needed for loading and swapping processes
What are the drawbacks of demand paging?
Implementation is complex.
How is demand paging implemented?
HW support need, valid and invalid bit for each page table entry.
Valid bit indicates page is in memory
Invalid bit indicates page isn’t in memory.
What is a page fault?
Check the V/I bit on each memory reference, page as normal when valid and trap on invalid.
What happens when a page fault occurs?
Check address is legal, find a free frame then schedule disk read operation. Set the frame number and valid bit in the page table and restart the instruction that caused the fault
What is pure demand paging?
Need have no pages in memory to start execution of a process. PC initially points to invalid address. Page containing first instruction is faulted on PC dereference.
Why do we need to be able to restart an instruction?
Any instruction that accesses memory can cause a page fault, must be able to restart. Can be expensive for complex instructions.
How do we calculate demand paging performance?
EAT = (1-p) * ma * page fault time
where p = probability of page fault and ma is memory access time (10-200 ns)
What is over-allocation?
Process may use less physical memory than size of VM.
Physical memory can be over-allocated.
What are the benefits of over-allocation?
allows increased multi-programming and increases CPU utilisation and throughput.
What are the drawbacks of over-allocation?
When 1 > processes have increased VM demands memory is also used to buffer IO.
May find no free frames when servicing page fault.
How is over-allocation handles?
Terminate the process
Swap out a process completely (freeing its frames)
Page replacement
- local (affects current process)
- global (affect any process)