CH 09
CH 09
Management
Chapter 9: Virtual Memory
Background
Demand Paging
Copy-on-Write
Page Replacement
Allocation of Frames
Thrashing
Memory-Mapped Files
Allocation Kernel Memory
Other Consideration
Copy of page C
3. Read the desired page into the (newly) free frame. Update the
page and frame tables.
Replace the page that will not be used for the longest period of
time.
The lowest page-fault rate and no Belady’s anomaly
Requires future knowledge of page reference
Time
z FIFO uses the time when a page was brought into memory
z OPT uses the time when a page is to be used
z LRU, least recently used, uses the time that a page has not
been used
LRU: replace the page that has not been used for the longest
period of time
z Like OPT looking backward in time
Requires hardware support for implementing LRU
Local
z Each process can select from its own set of allocated frames
Global
z A process can select replacement frame from all frames, even
it is currently allocated to other process.
z Has better throughput
z Performance of a process depends not only on the paging
behavior of that process but also on other processes.
A process cannot control its own page-fault rate.
Original configuration
Local page replacement
Global page replacement
Also allows several processes to map the same file allowing the
pages in memory to be shared
Prepaging
z To reduce the large number of page faults that occurs at process
startup
z Prepage all or some of the pages a process will need, before
they are referenced
z But if prepaged pages are unused, I/O and memory was wasted
z Assume s pages are prepaged and α of the pages is used
Is the cost of s * α saved pages faults > or < than the cost of
prepaging s * (1- α) unnecessary pages?
α near zero ⇒ prepaging loses
s⋅e p
overhead = + internal
p 2 fragmentation
Where
z s = average process size in bytes
Optimized when
z
z
p = page size in bytes
e = page entry size in bytes
p = 2 se
Program structure
z Int[128,128] data;
z Each row is stored in one page
z Program 1
for (j = 0; j <128; j++)
for (i = 0; i < 128; i++)
data[i,j] = 0;
z Program 2
for (i = 0; i < 128; i++)
for (j = 0; j < 128; j++)
data[i,j] = 0;