本文共 3671 字,大约阅读时间需要 12 分钟。
Virtual memory can be implemented via:
Bring a page into memory only when it is needed
invalid reference -->abort
not-in-memory -->bring to memory
Pure demand paging–never bring a page into memory unless page will be needed
With each page table entry a valid–invalid bit is associated
(1 --> in-memory, 0–> not-in-memory)
trap to OS
OS looks at another table to decide:
Effective Access Time (EAT) =(1 –p) x memory access + p(page fault overhead + [swap page out ] + swap page in + restart overhead)
Copy-on-Write (COW) allows both parent and child processes to initially share the same pages in memory.
If either process modifies (修改) a shared page, only then is the page copied
FIFO Replacement –Belady’s Anomaly :
more frames --> less page faults
Replace page that will not be used for longest period of time.
**Used for measuring how well your algorithm performs.**最优算法,主要是作为度量
Counter implementation :
Every page entry has a counter; every time page is referenced through this entry, copy the clock into the counter.
When a page needs to be changed, look at the counters to determine which are to change.
缺点:开销太大
Stack implementation –keep a stack of page numbers in a double link form
Additional-Reference-Bits Algorithm
Second chance
Keep a counter of the number of references that have been made to each page
LFU(least frequently used) Algorithm: replaces page with smallest count.
MFU(most frequent used) Algorithm: based on the argument that the page with the smallest count was probably just brought in and has yet to be used
Two major allocation schemes.
Global replacement –process selects a replacement frame from the set of all frames; one process can take a frame from another.
Local replacement –each process selects from only its own set of allocated frames.
两周置换各有利弊,分析应用场合
抖动 颠簸
If a process does not have “enough” pages, the page-fault rate is very high. This leads to:
Thrashing=a process is busy swapping pages in and out
Process migrates from one locality to another.
Localities may overlap
Why does thrashing occur? Σsize of locality > total memory size
Pages must sometimes be locked into memory
转载地址:http://umgwi.baihongyu.com/