Memory Allocation Strategy
Given five memory partitions of 400Kb, 600Kb, 350Kb, 200Kb, 800Kb (in order),
how would the first-fit, best-fit, and worst-fit algorithms place processes of 520
Kb, 617 Kb, 200 Kb, and 750 Kb (in order)?
Partitions (in order):
P1=400Kb, P2=600Kb, P3=350Kb, P4=200Kb, P5=800Kb
Processes (in order): A=520Kb, B=617Kb, C=200Kb, D=750Kb
First-Fit
Allocate each process to the first partition (from left) that is large enough.
1. A (520): P1 (400) too small → P2 (600) fits → A → P2.
remainder in P2 = 600 − 520 = 80Kb.
2. B (617): P1 400 no, P2 80 no, P3 350 no, P4 200 no, P5 800 fits → B → P5.
remainder in P5 = 800 − 617 = 183Kb.
3. C (200): scan from start → P1 (400) fits → C → P1.
remainder in P1 = 400 − 200 = 200Kb.
4. D (750): no partition remaining ≥750 (P1=200, P2=80, P3=350, P4=200, P5=183) →
not allocated.
Result (First-Fit):
P1 → C (200) (left 200Kb)
P2 → A (520) (left 80Kb)
P3 → free 350Kb
P4 → free 200Kb
P5 → B (617) (left 183Kb)
D not allocated.
Best-Fit
Place each process into the smallest partition that will hold it (minimize leftover).
1. A (520): only P2 (600) and P5 (800) fit → pick P2 (leftover 80) → A → P2 (left
80Kb).
2. B (617): remaining fits only in P5 (800) → B → P5 (left 183Kb).
3. C (200): fits in P1(400, leftover200), P3(350, leftover150), P4(200, leftover0) → best
is exact fit P4 → C → P4 (left 0Kb).
4. D (750): no partition ≥750 remaining → not allocated.
Result (Best-Fit):
P1 → free 400Kb
P2 → A (520) (left 80Kb)
P3 → free 350Kb
P4 → C (200) (exact fit, left 0Kb)
P5 → B (617) (left 183Kb)
D not allocated.
Worst-Fit
Place each process into the largest available partition at the time (maximize leftover).
1. A (520): largest partition is P5 (800) → A → P5 (left 280Kb).
2. B (617): after step1 partitions are P1=400, P2=600, P3=350, P4=200, P5=280 →
none ≥617 → B not allocated.
3. C (200): largest free is now P2 (600) → C → P2 (left 400Kb).
4. D (750): largest available blocks are 400, 400, 350, 280, 200 — none ≥750 → D not
allocated.
Result (Worst-Fit):
P1 → free 400Kb
P2 → C (200) (left 400Kb)
P3 → free 350Kb
P4 → free 200Kb
P5 → A (520) (left 280Kb)
B and D not allocated.