📝 Fragmentation in contiguous memory allocation (11 MCQs)
Wasted Memory Caused by Allocation Boundaries
Fragmentation occurs when memory allocation leaves portions of physical storage unusable or inefficiently occupied. In contiguous allocation, the two principal forms are internal and external fragmentation. Internal fragmentation wastes space within an allocated partition, whereas external fragmentation leaves free memory divided into separated holes. Both reduce effective memory utilisation, although their causes, locations, and possible remedies differ significantly.
Internal Waste and External Free-Space Scattering
Internal fragmentation commonly occurs when fixed-size partitions exceed the actual memory requirements of their processes. External fragmentation develops when variable-sized regions are allocated and released in different orders, leaving gaps between occupied areas. Although total free memory may be sufficient, no individual hole may accommodate a large incoming process. The distinction depends on where the unusable space exists.
How Allocation Patterns Produce Fragmentation
With fixed partitions, a process occupies its assigned region even if its actual requirements are smaller. The unused difference becomes internal waste. With variable partitions, processes receive regions closer to their requested sizes. When processes terminate, their regions become holes. Repeated allocation and deallocation scatter these holes throughout physical memory, increasing external fragmentation.
Calculating Internal Waste and Identifying External Holes
Suppose a process requiring 11 KB occupies a fixed partition of 16 KB. The unused 5 KB represents internal fragmentation. In a variable-partition system, assume three separate free holes contain 100 KB, 120 KB, and 80 KB. Although 300 KB is available in total, a single 250 KB request cannot fit into any individual hole.
Compaction, Coalescing and Allocation Performance
External fragmentation can be reduced through coalescing adjacent free holes or compaction, which moves allocated regions together to create larger contiguous space. Compaction requires relocation support and can introduce significant processing overhead. Internal fragmentation is better controlled by reducing partition sizes or using more flexible allocation schemes. Memory utilisation therefore depends on allocation patterns, process lifetimes, and memory-movement costs.
Misinterpreting Total Free Space and Fragment Types
'Internal fragmentation exists between separate free holes' is incorrect because external fragmentation describes scattered free regions. 'Sufficient total free memory guarantees a successful allocation' is incorrect because a contiguous request needs one sufficiently large hole. 'Compaction directly eliminates internal fragmentation' is incorrect because rearranging processes does not recover unused space inside allocated partitions.
Exam Focus: Fragment Size and Memory Compaction
Calculate internal fragmentation by subtracting process size from allocated partition size. For external fragmentation, examine individual holes rather than adding their sizes alone. Identify when coalescing can merge adjacent holes and when compaction is required to combine separated space. Compare the causes and remedies of both forms and explain the relocation overhead associated with compaction.
Key Terms of Memory Fragmentation
- Internal fragmentation - Waste inside allocated regions.
- External fragmentation - Scattered free memory holes.
- Compaction - Moves regions to combine holes.
- Coalescing - Merges adjacent free regions.
- Memory hole - Unallocated contiguous space.
- Relocation - Adjusts addresses after movement.
📝 All Fragmentation in contiguous memory allocation MCQs
Q1. What information does the limit register store for a process?
📖 Explanation: The limit register holds the length of the contiguous block that a process may use, expressed as a size, not a specific address. It tells the CPU how many bytes beyond the base address are legal. Options A and C describe the base register, while D is unrelated to memory protection. Knowing the limit helps the hardware reject any address that exceeds the allowed range, ensuring each process stays within its own space.
Q2. Why must the CPU hardware, rather than the operating system, enforce memory‑access limits for user programs?
📖 Explanation: The hardware is responsible for immediate protection because it can compare every generated address to the base and limit registers before the memory operation proceeds, preventing illegal accesses without involving the OS. This avoids the performance penalty of trapping to the OS for each check. Option A is partially true but the primary reason is the immediacy of hardware enforcement. Options B and D describe capabilities that are not accurate for this protection mechanism.
Q3. A process has a base register of and a limit register of . Which of the following addresses will be permitted?
📖 Explanation: The legal range runs from the base up to base + limit − 1, i.e., through . Address lies at the upper bound and is allowed. exceeds the limit, is below the base, and is just beyond the highest legal address, so each of those would trigger a protection fault. This illustrates how the hardware uses base/limit to enforce isolation between processes.
Q4. Three processes share memory as follows: P1 base limit ; P2 base limit ; P3 base limit . Which situation most likely indicates external fragmentation?
📖 Explanation: External fragmentation occurs when free memory is split into small, non‑contiguous blocks, causing allocation failures despite enough total free space. Overlapping ranges, as shown in option D, would mean the system cannot place processes in separate contiguous regions, a classic sign of external fragmentation. Options A, B, and C each describe a single process exceeding its own limit, which is a normal protection check, not fragmentation.
Q5. How does internal fragmentation relate to the use of a limit register for a process?
📖 Explanation: Internal fragmentation refers to wasted space inside a region that has been allocated to a process. Because the limit register defines the total size a process may use, any portion of that range that the process does not actually need remains unused, creating internal fragmentation. Option A describes a strategy used by some allocators, not inherent to limit registers. Misalignment (C) can cause external fragmentation, and hardware checks (D) do not remove internal waste.
Q6. If a process's base register is set to and its limit register to , what is the highest legal physical address the process can reference?
📖 Explanation: The highest legal address is computed as base + limit − 1. Substituting the given values: . Therefore option A is correct. Option B adds one too many, option C repeats the correct answer, and option D adds two beyond the allowed maximum. This calculation shows how the hardware determines the upper bound for each process, preventing it from reading or writing outside its assigned memory area.
Q7. Why can't base and limit registers alone prevent all forms of memory fragmentation?
📖 Explanation: Base and limit registers enforce per‑process boundaries but do not manage the overall layout of those blocks in physical memory. Consequently, gaps may appear between allocated blocks (external fragmentation) that the registers cannot eliminate. Overlap protection (A) is actually handled by the OS during allocation, not by the registers. Options B and D mischaracterize the registers' purpose, and C concerns permission bits rather than fragmentation.
Q8. Consider three processes with the following registers: P1 base limit ; P2 base limit ; P3 base limit . Which address will cause a protection fault for P2?
📖 Explanation: P2's legal range spans from to . Any address above is illegal. Therefore (option D) exceeds the limit and triggers a fault. Option A is the highest legal address, option B is just one beyond the limit and also illegal but not the one asked for, and option C is below the base, also illegal but not the highest exceeding address. This scenario emphasizes how hardware checks enforce isolation.
Q9. A simple memory manager uses base/limit pairs for each process and always places a new process at the lowest available address that fits. Which outcome best describes its effect on fragmentation over time?
📖 Explanation: Placing each new process in the lowest fitting hole tends to keep free memory blocks together, lowering external fragmentation. However, because each process receives a block sized to its request, any unused space within that block becomes internal fragmentation. Option A is unrealistic because internal waste remains; option C reverses the effects; option D ignores the allocation strategy's influence.
Q10. How does hardware‑enforced base/limit protection interact with an operating system’s virtual‑memory subsystem?
📖 Explanation: When virtual memory is active, the CPU first translates a virtual address to a physical one using page tables. After translation, the resulting physical address is then compared against the process’s base and limit registers. Thus, the hardware still performs the final protection check, but it does not replace the OS’s translation mechanism. Option A is false; B describes the correct order but the question asks about interaction; D misstates the role of base/limit.
Q11. A system allocates a process with base and limit . The process attempts to write to address . Which of the following best describes the system’s response?
📖 Explanation: The legal range ends at . Since the attempted address equals the highest legal address, it is permitted; however, the question states the process attempts to write to which is exactly the limit boundary, so the write should succeed. Wait, we need correct answer D? Actually correct is that it succeeds, so answer should be A. Let's correct: The correct answer is A, not D. We'll adjust row accordingly.