Allocation of Frames

Problem

我們之前討論了當 process 要求存取一個 logical address 時 OS 該如何從 disk 將內容載入到 physical memory 還有該如何管理 frames 才能讓 physical memory 最大化被利用

但是我們還沒有討論我們如何對多個 process 進行資源分配才能讓每個 process 都有足夠卻沒有閑置的資源

Concept

Minimum

  • 每種硬體的 ISA 定義了一群 instruction,這些 instruction 要執行有最低 page 數量需求,因此每個 process 最低的 page 需求由他所使用最複雜的那條 instruction 決定
    • 執行 instruction 可能會 instruction restart,所以必須要有足夠的 frame 同時存取這個 instruction 可能用到的所有 pages
  • Performance:process 被分配到的 frames 越少,page fault 的發生就會越頻繁

Maximum

  • Frame 上限就是 physical memory 的 frame 總數

Allocation Strategy

Fixed Allocation

  • Equal Allocation:每個 process 分配相同數量的 frame
  • Proportional Allocation:依 process size 大小分配成正比的 frame 數量

process size 指的就是 virtual memory size

Global & Local Allocation

Local Replacement

D-OS-Ch10fa-Local_Replacement

Global Replacement

D-OS-Ch10fb-Global_Replacement


Non-Uniform Memory Access

D-OS-Ch10fc-NUMA


Thrashing

D-OS-Ch10fd-Thrashing