Sub topic 13
Frame Allocation and Replacement Scope
This chapter assumes that you know paging, page faults, and basic process management. A frame is a fixed-size block of physical memory that holds one page. A process needs enough frames to keep its actively used pages in memory. When all of its allocated frames are occupied and a new page is needed, a replacement algorithm chooses a victim page.
Frame allocation answers how many frames each process receives. Replacement scope answers where the victim page may come from.
Why Frame Allocation Matters
Suppose physical memory has 12 available frames and three processes have sizes of 10, 20, and 30 pages. The operating system must decide how to distribute the frames.
Common allocation methods include:
| Method | Rule | Main characteristic |
|---|---|---|
| Equal allocation | Divide frames equally | Simple, but ignores process size |
| Proportional allocation | Allocate according to process size | Larger processes receive more frames |
| Priority allocation | Give more frames to higher-priority processes | Supports scheduling goals |
With equal allocation, each process receives 4 frames. With proportional allocation:
- Process 1 receives \(12 \times 10/60 = 2\) frames.
- Process 2 receives \(12 \times 20/60 = 4\) frames.
- Process 3 receives \(12 \times 30/60 = 6\) frames.
Rounding is required when the result is not an integer. The system must also enforce a minimum number of frames needed by the instruction set and the process's current execution.
Global and Local Replacement
Local replacement restricts a process to its own frames. If process A faults, it replaces one of A's pages. Process B cannot take that frame.
Global replacement allows a process to replace a page belonging to any process. A process with many active pages may obtain frames from another process.
Local replacement provides isolation. One process's sudden increase in memory demand cannot directly remove pages from another process. However, local replacement can waste memory. A process may have unused frames while another process suffers frequent faults.
Global replacement usually improves overall memory use because frames can move toward processes that currently need them. Its cost is interference. A process can lose an important page because another process caused a fault. The number of page faults for one process may therefore depend on the behavior of other processes.
Allocation and Replacement Together
Allocation and replacement are separate decisions:
- Allocation determines the current frame budget of each process.
- Replacement chooses a page when that budget is full.
- The replacement policy, such as FIFO or LRU, chooses the victim within the permitted scope.
For example, an LRU policy with local replacement searches only the faulting process's pages. LRU with global replacement searches all resident pages.
A practical system may adjust allocations dynamically. If a process's working set grows, the system can give it more frames. If free memory becomes scarce, it can reduce allocations or suspend a process. Poor allocation causes repeated page faults and may lead to thrashing.
Exercise
There are 24 frames and processes of sizes 12, 24, and 36 pages. How many frames does proportional allocation give each process?
Show answer
The total size is 72 pages. The allocations are 24 × 12/72 = 4, 24 × 24/72 = 8, and 24 × 36/72 = 12 frames.