Memory Allocation Strategy - Problems
Consider the requests from processes in given order 300K, 25K, 125K, and 50K. Let there be two blocks of memory available of size 150K followed by a block size 350K. Which of the memory allocation schemes can satisfy the above requests? Justify your answer. ( univeristy question)
Given:
-
Memory blocks:
- Block 1 = 150K
- Block 2 = 350K
-
Process requests (in order):
- 300K → 25K → 125K → 50K
1️⃣ First Fit
Allocate each process to the first block large enough.
Step-by-step:
- 300K → fits in 350K → remaining = 50K
- 25K → fits in 150K → remaining = 125K
- 125K → fits in remaining 125K → remaining = 0
- 50K → fits in remaining 50K → remaining = 0
✅ All processes allocated successfully
2️⃣ Best Fit
Allocate each process to the smallest sufficient block.
Step-by-step:
- 300K → fits only in 350K → remaining = 50K
- 25K → fits in 50K (better than 150K) → remaining = 25K
- 125K → fits in 150K → remaining = 25K
- 50K → ❌ cannot fit (only 25K + 25K left, not contiguous)
❌ Fails to allocate all processes
3️⃣ Worst Fit
Allocate each process to the largest available block.
Step-by-step:
- 300K → allocated to 350K → remaining = 50K
- 25K → allocated to 150K → remaining = 125K
- 125K → allocated to 125K → remaining = 0
- 50K → allocated to 50K → remaining = 0
✅ All processes allocated successfully
Final Answer:
| Allocation Scheme | Can satisfy all requests? |
|---|---|
| First Fit | ✅ Yes |
| Best Fit | ❌ No |
| Worst Fit | ✅ Yes |
Justification:
- Best Fit fails due to fragmentation—it leaves small unusable gaps.
- First Fit and Worst Fit succeed because they leave usable block sizes for later processes.
Comments
Post a Comment