Professional Documents
Culture Documents
Virtual
Memory
Ninth Edition, Global Edition
William Stallings
Mir l 幽曲
己
M
彗
load
豕
一 웞
f
if
MM 廳
pagetable
剡 free we
胸 E
pre paging 텄 no
Al al
page Replacement
FIFO
Here Setae 1 2 3 4 1 2 5 23 4 5
1 1 1 4 44 5 55 5 5 5
from1만
1 2 2 2 1 1 1 1 1 1 3
4 4
3
I
2 2 2
v v1 르르 v 7
1 1 1 1 5 5 5 5 4 4
it 2 2 2 2 1 1 1 1 5
유사증가
1 3 1 22 2 2
4 4 4 41 7
V V V v e v v f v w
L Belady's Anomaly
Belady's Anomaly
뱺
he frame
L
2 Optimal Alg 개념적존재 실제 사용불가
順 알뺘함
3 Least Recently Used
1 2 3 4 1 2 5
LRU
23 4 5
왜 LN
Bein
Ait
1 1 1 4 4 4 5 3 1 1
2 2 2 1 1 1 1 4 4
7 2 2 2 2
7 3 I
v V V V V V__v v v 10
1 1 1 1 1 1 1 5
2 2 2 2 2 2 2
1 1 5 5 4 4
4 4 3 3 3
V V 8
v V__V__V v
PT 이에 Alg
承 瀞 鬪
呱
門膨
y y
page Butting
MM
月 Id its
符
Allocation of Francs
i Equal Allocation
ii proportional Allocation
find allocation 고정
fvariabilis 잴
Thrashing
degree
of wallingramming t CPU Utilization
패 쐐 드
닚痲
f hTㄼ degree.tn州凹Many
for
too
D to a
is t.cn
any i 0
aEis
瀧
一
읹
o
O
I
i
working set
process
localityI지역성1
3 6 4 3 3
5
7 7 22 a
m
사서 弧 炭
Virtual memory A storage allocation scheme in which secondary memory can be
addressed as though it were part of main memory. The addresses a
program may use to reference memory are distinguished from the
addresses the memory system uses to identify physical storage sites, and
program-generated addresses are translated automatically to the
corresponding machine addresses.The size of virtual storage is limited by
the addressing scheme of the computer system and by the amount of
secondary memory available and not by the actual number of main storage
locations.
Virtual address The address assigned to a location in virtual memory to allow that location
to be accessed as though it were part of main memory.
Virtual address The virtual storage assigned to a process.
space
Address space The range of memory addresses available to a process.
Real address The address of a storage location in main memory.
a
Reading a page into
main memory may
Reading a segment into
main memory may
require writing a page require writing one or
out to disk more segments out to
disk
Register
n bits Page Table Ptr
Page Table
m bits
Offset
Page
Page#
Frame
+
Frame #
Root page
table ptr
Page
Frame
+ +
TT
4-kbyte page
楡
Root page table table (contains
(contains 1024 PTEs) 1024 PTEs)
2m 1 Frame # Offset
m bits
Inverted Page Table Real Address
(one entry for each
physical memory frame)
Translation
Lookaside Buffer
TLB hit
Offset
sonative reg
as
Load
page
Page Table
TLB miss
Frame # Offset
Real Address
Page fault
Associative Mapping
n The TLB only contains some of the page table entries so we
cannot simply index into the TLB based on page number
n Each TLB entry must include the page number as well as the complete
page table entry
Page # PT Entries
19
511
37
27
14
37 1
211
5 37
90
37 502 37 502
Frame # Offset Translation Lookaside Buffer Frame # Offset
Real Address Real Address
Page Table
Figure 8.8 Direct Versus Associative Lookup for Page Table Entries
Page # Offset
TLB
TLB miss
TLB
hit Cache Operation
Real Address
o
Cache
Miss
Main
Memory
Page Table
Value
n Contemporary programming
techniques used in large
programs tend to decrease the Most obvious on
personal computers
locality of references within a where applications are
process becoming increasingly
complex
Advantages:
Register
Seg Table Ptr
Segment table
d
Segment
Seg #
+
Length Base
In a combined
paging/segmentation system Segmentation is visible to the
a user’s address space is programmer
broken up into a number of
segments. Each segment is
broken up into a number of
fixed-sized pages which are Paging is transparent to the
equal in length to a main programmer
memory frame
Segment Page
Table Table
Offset
Page#
Page
Frame
Seg#
+ +
Virtual Address
Segment Number Page Number Offset
20K
Dispatcher X
35K No access
allowed
50K
Process A
80K
90K Branch instruction
(not allowed)
Process B X
Reference to
data (allowed)
140K
Process C
Reference to
data (not allowed)
X
190K
Demand
Prepaging
Paging
2 2 2 2 2 2 4 4 4 2 2 2
OPT 3 3 3 3 3 3 3 3 3 3 3
1 5 5 5 5 5 5 5 5
F F F
2 2 2 2 2 2 2 2 3 3 3 3
LRU 3 3 3 5 5 5 5 5 5 5 5
1 1 1 4 4 4 2 2 2
F F F F
2 2 2 2 5 5 5 5 3 3 3 3
FIFO 3 3 3 3 2 2 2 2 2 5 5
1 1 1 4 4 4 4 4 2
F F F F F F
2* 2* 2* 2* 5* 5* 5* 5* 3* 3* 3* 3*
CLOCK 3* 3* 3* 3 2* 2* 2* 2 2* 2 2*
1* 1 1 4* 4* 4 4 5* 5*
F F F F F
6 5
(a) State of buffer just prior to a page replacement
n–1 0
page 9 page 19 1
use = 1 use = 1
page 1
use = 1
page 45 2
use = 0
6 5
(b) State of buffer just after the next page replacement
FIFO
35
30 CLOCK
25 LRU
20
OPT
15
10
5
0
6 8 10 12 14
a simpler page
replacement
policy
Free page list Modified page list
List of page
frames available Pages are written
for reading in out in clusters
pages
Local
• Chooses only among the resident pages of the process that generated
the page fault
Global
• Considers all unlocked pages in main memory
Key elements:
n Does not perform well during the transient periods when there is
a shift to a new locality
The number of
The minimum The maximum page faults that
duration of the duration of the are allowed to
sampling sampling occur between
interval interval sampling
instances
Demand Cleaning
A page is written out to secondary memory only when it has been selected for
replacement
Precleaning
Allows the writing of pages in batches
Multiprogramming Level
Reference Page/storage
count unit number
Age
Indicates how long the page has been in memory without being referenced. The length and contents of this
Table 8.6
field are processor dependent.
Copy on write
Set when more than one process shares a page. If one of the processes writes into the page, a separate copy
of the page must first be made for all other processes that share the page. This feature allows the copy
operation to be deferred until necessary and avoided in cases where it turns out not to be necessary.
UNIX SVR4
Modify Memory
Indicates page has been modified.
Reference
Management
Indicates page has been referenced. This bit is set to 0 when the page is first loaded and may be periodically
reset by the page replacement algorithm. Parameters
Valid (page 1 of 2)
Indicates page is in main memory.
Protect
Indicates whether write operation is allowed.
Type of storage
Storage may be swap unit or executable file. In the latter case, there is an indication as to whether the (Table can be found on page 381
virtual memory to be allocated should be cleared first. in the textbook)
Page state
Indicates whether this frame is available or has an associated page. In the latter case, the Table 8.6
status of the page is specified: on swap device, in executable file, or DMA in progress.
Pfdata pointer
Pointer to other pfdata table entries on a list of free pages and on a hash queue of pages.
Reference count
Number of page table entries that point to a page on the swap device.
fro
nt
h
hands p re a d
an
d
a nd
c kh
ba
• Process virtual
memory
Two main • Kernel memory
aspects allocation
Each entry points to one page Each entry points to one page Each entry refers to one
of the page middle directory in the page table virtual page of the process
+
Page table
Page middle +
directory Page frame
in physical
memory
Page
directory
+
+
cr3
register
ed
used timeout used timeout
PG_active = 0 us PG_active = 1
PG_referenced = 1 PG_referenced = 1
used
2-Gbyte user
address space
(unreserved, usable)
0xFFFFFFFF
n These include:
n ASHMem
n This feature provides anonymous shared memory, which abstracts memory as file
descriptors
n A file descriptor can be passed to another process to share memory
n Pmem