Professional Documents
Culture Documents
VIRTUAL MEMORY
Two characteristics fundamental
to memory management
1) All memory references are logical addresses
that are dynamically translated into physical
Hardware and addresses at run time
Control 2) A process may be broken up into a number of
pieces that don’t need to be contiguously
Structures located in main memory during execution
It is not necessary
that all the pages or segments of a process
be in main memory during execution
Replacement 3. Bring the desired page into the (newly) free frame;
update the page and frame tables
4. Continue the process by restarting the instruction that
caused the trap
5. Note: now potentially 2 page transfers for page fault –
increasing EAT
First-In-First-
Out (FIFO) 15 page faults
Algorithm
Can vary by reference string: consider 1,2,3,4,1,2,5,1,2,3,4,5
Adding more frames can cause more page faults!
Belady’s Anomaly
1 2 3 4 5 6 7
number of frames
Optimal
Algorithm 9 page faults
Least Recently
Used (LRU)
Algorithm
0 0
0 0
Second- next
victim
1 0
Chance (clock) 1 0
Page-
0 0
Replacement
…
Algorithm 1 1
1 1
First frame in
circular buffer of page 222 page 191
use = 0 use = 1 3
n–1 0 frames that are8
candidates for replacement
page 9 page 19 1 page 33 page 556
use = 1 use = 1 use = 1 use = 0
page 1 7 page 67 page 13 4
use = 1 use = 0
use = 1
6 5
next frame page 45 2
(a) State of buffer just prior to a page replacement
Second- pointer use = 1
n–1 0
Chance (clock) 8
page 222
use = 0
page 191
use = 1 3
page 9 page 19 1
use = 1 use = 1
Page- page 33
use = 1
page 556
use = 0 page 1
use = 1
page 67 page 13
Replacement 7 use = 1 use = 0
4
page 45 2
Algorithm 6 5
(a) State of buffer just prior to a page replacement
use = 0
Replacement Local
Scope • Chooses only among the resident pages of the process that
generated the page fault
Global
• Considers all unlocked pages in main memory
Variable
Free frame is added to resident set of process when a
Allocation page fault occurs
Global Scope
If no frames are available the OS must choose a page
currently in memory
Variable
Allocation Key elements:
Local Scope • Criteria used to determine
resident set size
• The timing of changes
Page-Fault
Frequency
page-fault rate
increase number
of frames
upper bound
lower bound
decrease number
of frames
number of frames
256 KB
128 KB 128 KB
Buddy System A
L
A
R
Allocator 64 KB 64 KB
B B
L R
32 KB 32 KB
C C
L R
3-KB
objects
Slab physically
contiguous
Allocation pages
7-KB
objects
Program 2
for (i = 0; i < 128; i++)
for (j = 0; j < 128; j++)
data[i,j] = 0;
128 page faults
Memory Page
directory
memory
Scheme +
+
cr3
register