Demand Paging === - [前情提要 : Paging]() **Lazy swapper (又稱 pager)** : 只當 Process 需要某個 Page 時才把此 Page 從 Secondary memory(ex. disk) load 進 Main memory **Pure Demand Paging** : 一開始全部 Page 都在 Secondary memory ## Valid-Invalid Bit 每個 Page table 都有一個 Valid-Invalid Bit 欄位  - **VI Bit 為 v** : Frame 存在於 Main Memory - **VI Bit 為 i** : Frame 存在於 Secondary Memory ## Page Fault 當 Process access 了一個不存在於 Main memory 的 Page, 就會造成一次 Page Fault 順帶一提, 在前面幾章有提到 PCB (Process Control Block), 裡面有一部分放的是 **Memory Management Information**, 而 Page Table就是屬於此區的。 ### Step 整個 Page Fault 後的過程概念如下 1. 發生 Page Fault, Trap to operating system 2. OS 查看 PCB 裡的 Page Table: - **Invalid reference** : Page Number 超出 Page Table 範圍 => Abort - **Not-In-Memory** : VI Bit 為 i => Load into main memory 3. 取得一個 Free frame(若沒有 Free frame, 則要挑一個Victim frame to swap out) 4. Swap page 進此 free frame 5. Reset page table 6. 從造成 Page fault 的指令重新繼續執行 process ## Performance - Effective Access Time (EAT) **EAT** = (1 - p) * `memory access` + p * (`page fault overhead` + `swap page out` + `swap page in` + `restart overhead`) **p**: Page Fault Rate **Page Fault Overhead**: 判斷 Page Fault 是 Valid 的, 並尋找 Free frame/Victim frame 這整個過程的時間 **Swap page out**: Swap out victim Frame 的時間 **Swap page in**: 將要的 Page swap 進 Main Memory 的時間 **Restart overhead**: 從造成 Page fault 的指令重新繼續執行 process 的時間 # ###### tags: `OS`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up