Chapter - 05 - Memory Management
Chapter - 05 - Memory Management
Virtual memory
Problems that arise when managing memory
Some cases can occur before and after the X process finished
Memory allocation models
Continuous allocation: the process is loaded into a
continuous memory area
Linker-Loader
Base & Limit
Non-continuous allocation: the process is loaded
into a discontinuous memory area
Segment model
Paging model
Combination model: segment with paging
Linker_Loader Model
absolute address = address that start loading process + relative address
MMU assigns two elements in two segmentation tables of two processes of the
same value
Segment protection
Attribute: R (read), X (execute), W (write),…
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 2 20 page
=> the maximum size of process 220 x 212 byte = 232 byte =4 GB.
Multi-level paging.
Hash Page Table.
Inverse Page Table.
To solve the memory loss problem when the process needs a large page
table
Multi-level paging
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
Consider the process to access page strings in the following order: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
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 pi
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