Question:

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 ______.

Note: \(1\text{K}=2^{10}\)

Show Hint

Use best fit: pick the smallest hole that still fits the process, split off the leftover as a new smaller hole, and remove a hole completely if the process fits it exactly.
Updated On: Jul 22, 2026
Show Solution
collegedunia
Verified By Collegedunia

Correct Answer: 3

Solution and Explanation

Step 1: List the holes and understand best fit.
The memory has 8 holes of sizes 20 KB, 4 KB, 25 KB, 18 KB, 7 KB, 9 KB, 15 KB, and 12 KB. In the best fit method, a new process is placed in the smallest hole that is still big enough to hold it. This keeps the leftover gap as small as possible.

Step 2: Place P1 (16 KB).
We need a hole of at least 16 KB. The holes of size 20 KB, 25 KB, and 18 KB qualify. Among these, the smallest is 18 KB, so P1 goes into the 18 KB hole.
The leftover space in that hole is
\[ 18 - 16 = 2 \text{ KB} \]
So the 18 KB hole is replaced by a smaller hole of 2 KB, and the hole list becomes:
20 KB, 4 KB, 25 KB, 7 KB, 9 KB, 15 KB, 12 KB, 2 KB.

Step 3: Place P2 (9 KB).
We need a hole of at least 9 KB. The holes 20 KB, 25 KB, 9 KB, 15 KB, and 12 KB qualify. The smallest of these is exactly 9 KB, so P2 fits perfectly into the 9 KB hole with no leftover space.
That hole is fully used up and disappears from the list. The remaining holes are:
20 KB, 4 KB, 25 KB, 7 KB, 15 KB, 12 KB, 2 KB.

Step 4: Count the holes smaller than 8 KB.
Going through the final list 20 KB, 4 KB, 25 KB, 7 KB, 15 KB, 12 KB, 2 KB, the holes smaller than 8 KB are 4 KB, 7 KB, and 2 KB.
That is a total of 3 holes.

Final Answer:
The number of holes of size less than 8 KB after allocating P1 and P2 is
\[ \boxed{3} \]
Was this answer helpful?
0
0

Top GATE CS Operating System Questions

View More Questions