Download Memory Management in Operating Systems: Principle, Memory Hierarchy, and Paging - Prof. B. and more Study notes Operating Systems in PDF only on Docsity! CMSC 321: Operating Systems Lecture 11 Memory Management Reading: Silberschatz Chs. 8 and 9 Memory Management? • Principle Operation: bring programs into RAM for execution • Memory Hierarchy: speed/cost vs size; volatility– . OS di d• must coor nate an manage – transparent to user Dynamic Partitioning • Partitions: vary # and length • When program brought in allocate amt needed, no more • Problems? Dynamic Partitioning • Partitions: vary # and length • When program brought in allocate amt needed, no more • Problems? external fragmentation Dynamic Partitioning Algs • How to place programs into memory? – Best-fit: find partition that results in least waste – First-fit: scan from beginning until program fits – Next-fit: scan starting from last placement • Which is best? – first-fit: simplest, best, fastest – best-fit: usually worst performer (why?) – next-fit: slightly worse than first-fit
Paging
Frame
Main memory Mat memory
Rumer
i ih
J 1
a a
a a
4 4
& =
G &
z z
& a
a by
dit ib
11 Ui
1z 1
13 {¥
14 14
Ge Pilleea Avaiiitle Prams ifs Load Prooess A
Main menwory
Al
AQ
SEES
SWS
TC
Z
<=
BoanBSe Sot u am nauwnee
—
(be Lowi Press if
Paging
ain meMery
el) Lowe Progess C
‘lak memeary
A
Al
AQ
Ad
le
ain Aer y
AM
Al
Load Peopes 2
Pa
ing
ake Mey
A
A.l
Aa
OF) Lowel Process
Sed | ba] |
}
J
ze
3
Pracess A
page table
oO
J
x
Process 6
page table
| 7 @| 4
1 8 i 5
2| 9 2|_6
#| 10 | 11
Process C 4|_12
page table Process D
page table
13
14
Free frame
list
Hierarchical: Two-Level Scheme
-Kliyte rot
page table
ee ta he user
moe to Pulls
yes We
WUT
4-hyle user
Acres space
Addr. Trans. — 2 Level
Virtual Address
10 bits | 10 bits | 12 bits
Frame # Offset
Root page
table ptr
)
Page
" Frame
)
’
4-kbyte page
table (contains
Root page table °
(contains 1024 PTEs) 1024 PTEs)
LYN
Program Paging Mechanism Main Memory
Page Size • Factors to consider: – 1. internal fragmentation small pages : less IF small pages : more pages/process – larger page tables – 2. secondary memory large pages : more efficient xfers – 3. effect on page fault rate l f l l kas page size increases, princip e o oca ity wea ens fewer pages available in memory (More on this later) – 4. program complexity OOP, threads reduce locality