Consider contiguous allocation of physical memory to processes using variable…
2026
Consider contiguous allocation of physical memory to processes using variable partitioning scheme. Suppose there are 8 holes in the memory of sizes 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, and 12 KB. Assume that no two holes are adjacent. Two processes P1 of size 16 KB and P2 of size 9 KB arrive in that order, and they are allocated memory using the best-fit technique. After allocating space to P1 and P2, the number of holes of size less than 8 KB is ____________. (answer in integer)
Attempted by 16 students.
Show answer & explanation
Correct answer: 3
Step-by-Step Best-Fit Allocation
Initial holes: 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, 12 KB.
Process P1 (16 KB): Find the smallest hole >= 16 KB.
Candidates: 20 KB, 25 KB, 18 KB.
Best fit is 18 KB.
Remaining hole from 18 KB: 18 - 16 = 2 KB.
Current holes: 20 KB, 4 KB, 25 KB, 2 KB, 7 KB, 9 KB, 15 KB, 12 KB.
Process P2 (9 KB): Find the smallest hole >= 9 KB.
Candidates: 20 KB, 25 KB, 9 KB, 15 KB, 12 KB.
Best fit is exactly 9 KB.
Remaining hole from 9 KB: 9 - 9 = 0 KB (hole disappears).
Final holes: 20 KB, 4 KB, 25 KB, 2 KB, 7 KB, 15 KB, 12 KB.
Count holes with size < 8 KB: 4 KB, 2 KB, 7 KB.
Total count = 3.