🎓 BookMCQ
← Back to 8. Main Memory

📝 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.
2
Easy
5
Medium
4
Hard

📝 All Fragmentation in contiguous memory allocation MCQs

Q1. What information does the limit register store for a process?

A.The highest physical address the process can reach
B.The size of the addressable range for the process ✅
C.The starting address of the process in memory
D.A flag indicating read‑only pages
💡 Difficulty: easy | ✅ Correct: B

📖 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?

A.Because hardware checks are faster and avoid costly context switches ✅
B.Because the OS cannot read physical addresses
C.Because user programs can modify OS code directly
D.Because hardware provides better debugging information
💡 Difficulty: easy | ✅ Correct: A

📖 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 300040300040 and a limit register of 120900120900. Which of the following addresses will be permitted?

A.420939420939 ✅
B.421000421000
C.300039300039
D.420940420940
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The legal range runs from the base up to base + limit − 1, i.e., 300040300040 through 300040+120900−1=420939300040+120900-1 = 420939. Address 420939420939 lies at the upper bound and is allowed. 421000421000 exceeds the limit, 300039300039 is below the base, and 420940420940 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 100000100000 limit 5000050000; P2 base 150000150000 limit 4000040000; P3 base 200000200000 limit 3000030000. Which situation most likely indicates external fragmentation?

A.P2 cannot access address 190000190000
B.P1 cannot access address 149999149999
C.P3 cannot access address 230000230000
D.All processes have overlapping address ranges ✅
💡 Difficulty: medium | ✅ Correct: D

📖 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?

A.It occurs when the limit register rounds the allocated size up to the nearest power of two ✅
B.It is caused by unused memory within the allocated range that the limit register defines
C.It happens when the base register is misaligned
D.It is eliminated entirely by hardware checks
💡 Difficulty: medium | ✅ Correct: A

📖 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 250000250000 and its limit register to 7500075000, what is the highest legal physical address the process can reference?

A.324999324999 ✅
B.325000325000
C.324999324999
D.325001325001
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The highest legal address is computed as base + limit − 1. Substituting the given values: 250000+75000−1=324999250000 + 75000 - 1 = 324999. 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?

A.They cannot stop the operating system from allocating overlapping regions ✅
B.They only protect address ranges but do not control how those ranges are placed in physical memory
C.They lack the ability to enforce read‑only permissions
D.They are too slow to check each memory access
💡 Difficulty: hard | ✅ Correct: A

📖 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 100000100000 limit 4000040000; P2 base 140000140000 limit 3000030000; P3 base 170000170000 limit 2500025000. Which address will cause a protection fault for P2?

A.169999169999
B.170000170000
C.139999139999
D.170001170001 ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: P2's legal range spans from 140000140000 to 140000+30000−1=169999140000+30000-1 = 169999. Any address above 169999169999 is illegal. Therefore 170001170001 (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?

A.It eliminates both internal and external fragmentation ✅
B.It reduces external fragmentation but may increase internal fragmentation
C.It increases external fragmentation while reducing internal fragmentation
D.It has no impact on fragmentation
💡 Difficulty: hard | ✅ Correct: A

📖 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?

A.The hardware replaces virtual memory entirely ✅
B.The OS must translate virtual addresses before the hardware checks base/limit limits
C.The base/limit registers are used only when virtual memory is disabled
D.The hardware checks only physical addresses, ignoring virtual mappings
💡 Difficulty: hard | ✅ Correct: A

📖 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 500000500000 and limit 200000200000. The process attempts to write to address 699999699999. Which of the following best describes the system’s response?

A.The write succeeds because the address is within the limit ✅
B.The write fails because the address exceeds the highest legal address by one
C.The write succeeds but is redirected to a different process’s memory
D.The write triggers a hardware protection fault
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The legal range ends at 500000+200000−1=699999500000 + 200000 - 1 = 699999. Since the attempted address equals the highest legal address, it is permitted; however, the question states the process attempts to write to 699999699999 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.

🔗 Related Topics (MCQs)