Professional Documents
Culture Documents
ch7KIIT (Compatibility Mode)
ch7KIIT (Compatibility Mode)
ch7KIIT (Compatibility Mode)
⇒
Demand Paging
i
i
page table
During address translation, if valid–invalid bit in page table entry
is I ⇒ page fault
Page Table When Some Pages Are Not in Main Memory
Backing
storage
Page Fault
If the process is available on main memory in terms of pages
then a legal page (V)access is possible & execution starts.
If there is a reference to a page for access & the page is not
available on main memory then it is an illegal page (I) which will
be trap to operating system: PAGE FAULT
1. Operating system looks at another table to decide:
Invalid reference ⇒ abort
Just not in memory
2. Get empty frame on main memory to load the illegal page.
3. Swap page into frame.
4. Reset tables entries [ I bit converts to V ]
5. Set validation bit = v
6. Restart the instruction that caused the page fault
Steps in Handling a Page Fault
Page Fault Service Time
1. Trap to the operating system.
2. Save the user register & process state.
3. Determine the interrupt was a page fault.
4. Determine the page location on disk.
5. Issue a read from disk to free frame ( device queue, disk latency time
& page transfer time )
6. While waiting allocate the CPU to some other user.
7. Interrupt from disk (I/O completion).
8. Save the process state for the other process.
9. Determine that the interrupt was from disk.
10. Correct the page table.
11. Wait for CPU to resume back to the same process.
12. Restore the user register, process state & new page table then
resume the interrupted instruction.
Performance of Demand Paging
H TWO TWO
I HITS HITS
T
15 PAGE FAULTS
Problem with FIFO Algorithm
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
3 frames (3 pages can be in memory at a time per process)
1 1 4 5 9 page faults
2 2 1 3
3 3 2 4
4 frames UNEXPECTED
1 1 5 4 Page fault
increases
2 2 1 5
3 3 2
4 4 3 10 page faults
H H
I I TWO
TWO TWO THREE
T T HITS
HITS HITS HITS
09 PAGE FAULTS
Difficulty with Optimal Algorithm
Replace page that will not be used for longest period of time
4 frames example
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
1 4
2
6 page faults
3
4 5
H H H TWO
TWO H
I I I HITS
HITS I
T T T T
12 PAGE FAULTS
Least Recently Used (LRU) Algorithm
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
1 1 1 1 5
2 2 2 2 2
3 5 5 4 4
4 4 3 3 3
Counter implementation
Every page entry has a counter; every time page is referenced
through this entry, copy the clock into the counter
When a page needs to be changed, look at the counters to
determine which are to change
End of Chapter 9