Chapter_05 - Memory Management
Chapter_05 - Memory Management
Virtual memory
Problems that arise when managing
memory
2
Computer 32 bit => virtual address (p,d) has 32 bits => bits
of p + bits of d = 32, but 1 page 4K=212 bytes => d has 12
bit =>p has 20 bit => 1 page table has 220 elements.
=> The system manages the process up to the maximum 220
page => the maximum size of process 220 x 212 byte = 232
byte =4 GB.
Multi-level paging.
Hash Page Table.
Inverse Page Table.
10 10 12
p1 index of first-level page table. p2 index of page table level 2
G H
Ví dụ: Thời gian một lần truy xuất bộ nhớ là 1 micro second và giả sử
40% trang được chọn đã thay đổi nội dung và thời gian hoán chuyển
trang ra/vào là 10 mili second . Tính ETA.
The "victim" page: the page after replacing will cause the
least error page.
The page in the longest memory will be selected as the victim page
The page in the longest memory will be selected as the victim page
Belady Paradox
44
Equal allocation
m page frames and n processes.
Each process is given m/n page frames.
Allocation according to the size ratio
si : the size of the process pi
S = si the total size of all processes
m : the number of page frames available
ai : the number of page frames allocated to the process p i
ai= si/ S x m
Example: Process 1= 10K, Process 2=127K and 62 blank page
frame. Then can grant
Process 1: 10/137 x 62 ~ 4 frame
Process 2: 127/137 x62 ~ 57 frame
Allocate according to the priority ratio:
Replace the page
55
Global replacement
Select the "victim" page from the set of all page
frames in the system.
There are more options available.
The number of page frames assigned to a process
can be change.
Processes cannot control the rate of their page errors.
Local replacement
Only select alternate pages from the set of page
frames provided for the paging error.
The number of page frames assigned to a process will
not change
Stagnant System
56
(thrashing)
Not enough page frames -> frequent
page errors -> lots of CPU time spent
performing page replacement.
Working set model.
Working Set Model
57