Professional Documents
Culture Documents
Virtual Memory: Silberschatz, Galvin and Gagne ©2009 Operating System Concepts - 8 Edition
Virtual Memory: Silberschatz, Galvin and Gagne ©2009 Operating System Concepts - 8 Edition
What to Learn?
Chapter 8 in the text book OSCE. Chapter 9 in OSC.
The benefits of a virtual memory system
The concepts of
demand
paging
page-replacement
and
algorithms
9.2
Background
Virtual memory
Only
Logical
Allows
9.3
9.4
9.5
needed
Less
I/O needed
Less
memory needed
Faster
More
response
users supported
needed
not-in-memory
bring to memory
9.6
Valid-Invalid Bit
With each page table entry a validinvalid bit is
associated
(v in-memory, i not-in-memory)
Frame #
valid-invalid bit
v
v
v
v
i
.
i
i
page table
Operating System Concepts 8th Edition
9.7
9.8
page fault
9.9
Auto
move
increment/decrement
9.10
9.11
p = 0, no page faults
if
9.12
= (1 p x 200 + p x 8,000,000
= 200 + p x 7,999,800
If one access out of 1,000 causes a page fault, then
9.13
Other Benefits
Virtual memory allows other benefits
- Shared pages
- Copy-on-Write during process creation
- Memory-Mapped Files
9.14
9.15
9.16
9.17
9.18
Memory-Mapped Files
Allow file I/O to be treated as routine memory
9.19
9.20
NUMINTS * sizeof(int)
9.21
several times
9.22
9.23
Page Replacement
9.24
9.25
9.26
4 frames
9 page faults
10 page faults
9.27
9.28
9.29
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
6 page faults
3
4
9.30
9.31
Counter implementation
9.32
9.33
referenced:
move
it to the top
requires
No
6 pointers to be changed
9.34
9.35
Second chance
bit 0.
9.36
Second-Chance
Page-Replacement Algorithm
9.37
processes.
9.38
Fixed Allocation
Equal allocation For example, if there are 100 frames and 5
si size of process pi
S si
m total number of frames
s
ai allocation for pi i m
S
m 64
si 10
s2 127
10
64 5
137
127
a2
64 59
137
a1
9.39
Priority Allocation
Use a proportional allocation scheme using
select
9.40
Thrashing
If a process does not have enough pages,
CPU utilization
operating
another
9.41
Thrashing (Cont.)
9.42
Locality model
Process
another
Localities
Need
may overlap
9.43
9.44
9.45
process startup)
pages is used
>
9.46
fragmentation
table size
overhead
locality
9.47
9.48
128x4 bytes
Program structure
Int[128,128] data;
9.49
Int[128,128] data;
Program 1
for (j = 0; j <128; j++)
for (i = 0; i < 128; i++)
data[i,j] = 0;
128 x 128 = 16,384 page faults
Program 2
for (i = 0; i < 128; i++)
for (j = 0; j < 128; j++)
data[i,j] = 0;
128 page faults
9.50
9.51