📝 Frames Allocation algorithms (9 MCQs)
Distributing Physical Frames Among Processes
Frame allocation algorithms determine how the operating system distributes available physical memory frames among executing processes. The memory manager must satisfy minimum architectural requirements while balancing memory utilisation and page-fault rates. Common approaches include equal allocation, proportional allocation according to process size, and priority-based allocation. The choice affects how much physical memory each process receives and how effectively its working set remains resident.
Why Frame Distribution Affects Multiprogramming Performance
Physical memory is shared by operating system components and multiple processes with different memory requirements. Giving too many frames to one process can leave others with insufficient space, increasing their fault rates. Giving every process the same number can also be inefficient when their address spaces differ significantly. Allocation policies attempt to distribute frames according to system goals and process requirements.
Equal, Proportional and Priority-Based Allocation
Equal allocation divides available frames evenly among eligible processes. Proportional allocation distributes frames according to process sizes or another defined weighting factor. Priority allocation assigns more frames to higher-priority processes, depending on the system policy. In every approach, the memory manager must preserve minimum requirements and adjust allocations when processes enter or leave the system.
Calculating Proportional Frame Allocation
Suppose 60 frames are available for two processes requiring address spaces of 100 and 200 pages. Proportional allocation assigns 20 frames to the first process and 40 to the second, assuming all 60 frames are distributable. This result reflects the ratio of their sizes rather than assigning each process an identical number of frames.
Memory Balance and Allocation Trade-Offs
Equal allocation is simple but ignores differences in process size and locality. Proportional allocation accounts for memory requirements but does not guarantee equal page-fault rates. Priority allocation supports important workloads but may disadvantage lower-priority processes. Dynamic systems may adjust allocations using page-fault frequency or working-set estimates, balancing responsiveness with overall memory utilisation.
Common Confusions About Allocation Policies
'Equal allocation gives every process frames according to its size' is incorrect because equal allocation divides frames evenly. 'Proportional allocation always uses process priority' is incorrect because it normally considers process size or assigned weights. 'A larger allocation automatically eliminates page faults' is incorrect because future references may still access nonresident pages.
Exam Focus: Equal and Proportional Allocation Calculations
Calculate equal allocations by dividing available frames by the number of processes, accounting for any remainder. For proportional allocation, multiply the available frame count by each process size divided by total process size. Practise priority-weighted distributions and compare the policies in fairness, memory efficiency, and potential page-fault behaviour.
Key Terms of Frame Allocation
- Equal allocation - Divides frames evenly.
- Proportional allocation - Distributes frames by process size.
- Priority allocation - Favours higher-priority processes.
- Frame pool - Collection of allocatable frames.
- Allocation ratio - Share assigned to a process.
- Minimum frames - Required execution allocation.
📝 All Frames Allocation algorithms MCQs
Q1. What does the valid‑invalid bit in a page‑table entry indicate?
📖 Explanation: The valid‑invalid (or present) bit tells the operating system if the page is resident in a frame. When the bit is set to 1, a memory reference can be satisfied directly; when it is 0, the CPU raises a page‑fault trap, causing the OS to bring the page in. Options B, C, and D describe unrelated attributes, so they are incorrect.
Q2. A process accesses pages 0,2,4,2,0,5 sequentially. The system has 3 free frames and uses demand paging. How many page faults will occur?
📖 Explanation: The first three distinct pages (0,2,4) each cause a fault and fill the three frames. The next accesses to 2 and 0 hit those frames, incurring no faults. The final reference to page 5 requires a replacement, producing a fourth fault. Thus the total is four faults. Options A, C, and D miscount either hits or replacements, making them wrong.
Q3. Why does marking a page invalid have no effect if the process never accesses that page?
📖 Explanation: If a page is never referenced, the CPU never checks its valid‑invalid status, so no page‑fault trap is generated and the marking does nothing. Option A is false because loading occurs only on a fault. Option B is incorrect; the CPU does examine the bit when a reference occurs. Option D is unrelated to virtual memory mechanisms.
Q4. In a demand‑paging system, which algorithm chooses the page with the longest future reference interval?
📖 Explanation: The Optimal algorithm (also called Bélády’s algorithm) evicts the page that will not be used for the longest period in the future, minimizing faults. FIFO removes the oldest loaded page regardless of future use, LRU removes the least recently used, and Second‑chance is a practical approximation of FIFO. Therefore only option C correctly describes the optimal strategy.
Q5. Consider a system with 8 frames and a reference string \\\langle 1,2,3,4,1,2,5,1,2,3,4,5 \\rangle \. Using the Clock algorithm with reference bits initially 0, how many page faults occur?
📖 Explanation: Starting with empty frames, the first eight distinct references (1‑4, then 5) generate faults, filling all frames. The Clock pointer cycles, giving each page a second chance; when 1 and 2 are referenced again, their bits are set, preventing immediate eviction. The final references cause two more faults as pages 3,4,5 replace previously cleared pages, totaling nine faults. Options A, C, and D either underestimate or overestimate the replacements.
Q6. How does the valid‑invalid bit interact with a page‑replacement algorithm when a page is evicted from a frame?
📖 Explanation: When a page is removed from physical memory, the OS must indicate that it is no longer present, so the valid‑invalid bit is cleared (set to 0). The frame becomes available for another page, and the page‑table entry retains the frame number until it is reused. Options A and D describe impossible behaviors, and B fails to mark the page as absent.
Q7. What is the main advantage of demand paging over pre‑paging regarding memory utilization?
📖 Explanation: Demand paging brings a page into memory only when a process actually references it, which conserves RAM and reduces unnecessary I/O. Pre‑paging loads a fixed set of pages regardless of need, potentially wasting space. Option A is opposite; pre‑paging increases I/O. Option B is inaccurate, and option D is unrelated to paging strategy.
Q8. A program attempts to write to a page that is marked invalid. What immediate action does the operating system take?
📖 Explanation: When a reference hits an invalid page, the hardware raises a page‑fault trap, prompting the OS to locate the needed page in backing store and load it into a free frame. Only after the page is valid can the write proceed. Termination occurs only after repeated faults or illegal access, not immediately. Ignoring the write would corrupt data, and swapping out another page is part of the replacement process, not the initial response.
Q9. If a system's page‑fault rate is 0.02 and it makes 500 memory references per second, how many page faults occur per second?
📖 Explanation: The number of faults per second equals the fault rate multiplied by total references: \0.02 \\times 500 = 10\. Therefore ten faults occur each second. Option A underestimates by a factor of two, option C overestimates by double, and option D is far too high. This calculation directly applies the definition of fault rate to quantify system performance.