Unit VII Virtual Memory
Unit VII Virtual Memory
Unit VII Virtual Memory
Background
Demand Paging
Page Replacement
Page Replacement Algorithms
Allocation of Frames
Thrashing (only concept)
0
0
page table
During address translation, if valid–invalid bit in page table
entry is 0 page fault.
Operating System Concepts 10.6 Silberschatz, Galvin and Gagne 2002
Page Table When Some Pages Are Not in Main Memory
1 1 4 5
2 2 1 3 9 page faults
4 frames
3 3 2 4
1 1 5 4
2 2 1 5 10 page faults
FIFO Replacement – Belady’s Anomaly
more frames less3page3faults
2
4 4 3
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
How do you know this?
Used for measuring how well your algorithm performs.
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
1 5
2
3 5 4
4 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.
Prepaging
Program structure
int A[][] = new int[1024][1024];
Each row is stored in one page
Program 1 for (j = 0; j < A.length; j++)
for (i = 0; i < A.length; i++)
A[i,j] = 0;
1024 x 1024 page faults
Consider I/O. Pages that are used for copying a file from
a device must be locked from being selected for eviction
by a page replacement algorithm.
Windows NT
Solaris 2