CS FundamentalsHardGATE CS (PYQ pattern)

Free memory consists of three holes (start, size in KB): (0, 300), (400, 200), (700, 500); everything else is allocated. Operations in order: allocate A = 150, allocate B = 180, free A, allocate C = 120, allocate D = 260, allocate E = 200 (KB). A chosen hole is split (allocation at its low end), freed blocks merge with adjacent holes, ties go to the lower address, and there is no compaction. Under first-fit, best-fit and worst-fit, which requests fail?

  1. A. Only best-fit fails, when E (200 KB) arrives
  2. B. No policy fails any request
  3. C. Only worst-fit fails, when D (260 KB) arrives
  4. D. First-fit and worst-fit both fail at D

Correct answer: C. Only worst-fit fails, when D (260 KB) arrives

Worst-fit puts A and B into the 500 KB hole (leaving 170), A's release leaves a separate 150 KB hole, C takes 120 of the 300 hole, and the largest hole is then 200 < 260, so D fails. First-fit: A at 0, B at 400, A's release merges back to 300, C at 0, D and E fit in the 500 hole (260 + 200 of it remaining 240). Best-fit: A in 200, B in 300, freeing A re-forms 200, C fits the 180 left at 180, D goes to 700, E fills the 200 hole exactly.

More Operating Systems questions

Exams that ask this topic