Virtual Memory
Virtual Memory
.
.
.
Memory
Page v Map
Virtual Physical
Memory Memory
Virtual
Address
Space
Heap
Data
Code
0
Virtual Address Space
Heap Heap
Data Data
Code Code
0 0
Virtual Address Space Virtual Address Space
Shared Library using Virtual Memory
Memory Management_Lecture Notes Slide Number 10
Demand Paging
Swap Out 0 1 2 3
Program A
4 5 6 7
8 9 10 11
Program B 12 13 14 15
16 17 18 19
20 21 22 23
Main Memory
Secondary Memory
•If the process only ever accesses pages that are loaded in
memory(memory resident pages), then the process runs
exactly as if all the pages were loaded in to memory.
•If a page is needed that was not originally loaded up, then
a page fault trap is generated, which must be handled in a
series of steps:
•The memory address requested is first checked, to make
sure it was a valid memory request.
•If the reference was invalid, the process is terminated.
Otherwise, the page must be paged in.
•A free frame is located, possibly from a free-frame list.
Operating
System
2 Trap
1 Reference
Load M
6
Free Frame
4 Bring in Missing Page
Restart Instruction
Page Table
•FIFO
•LRU
•LRU Optimal
•Page which has not been used for the longest time in main
memory is the one which will be selected for replacement.
•Easy to implement, keep a list, replace pages by looking
back into time.