GATE / CS ARCHIVE

GATE CSE 1998 / QUESTION 7(b)

Best-fit completion timeline

Operating Systems · Memory Allocation & Segmentation · Full GATE CSE 1998 paper

GATE 1998, Q7(b) Descriptive
Report issue

Memory Allocation & Segmentation

Question 7(b), GATE 1998: Fixed partition sizes are 4,8,20,2 KB. Jobs in order have (size KB, execution time): (2,4),(14,10),(3,2),(6,1),(6,4),(10,1),(20,8),(2,6). With best-fit allocation, when does the 20 KB job finish?
Question 7(b), GATE 1998: Fixed partition sizes are 4,8,20,2 KB. Jobs in order have (size KB, execution time): (2,4),(14,10),(3,2),(6,1),(6,4),(10,1),(20,8),(2,6). With best-fit allocation, when does the 20 KB job finish?
Tap to enlarge
Answer & solution

Answer: At time 19 under listed-order, nonpreemptive fixed-partition scheduling. (no official key was published)

Assume all jobs are available at time 0, listed order resolves admission priority, partitions are fixed and not split, runtimes are elapsed times while resident, and loading/switching costs are zero. Best fit places an admitted job in the smallest currently free partition that accommodates it. Call the listed jobs J1 through J8.

At time 0, J1 occupies 2 KB until t=4, J2 occupies 20 KB until t=10, J3 occupies 4 KB until t=2, and J4 occupies 8 KB until t=1. J5, J6 and J7 cannot yet fit. At t=1, J4 finishes and J5 enters the 8 KB partition for four units, finishing at t=5.

The critical resource is the 20 KB partition. J6 needs 10 KB, so it cannot use the 4,8 or 2 KB partitions. J7 needs the entire 20 KB partition. At t=10, J2 releases it. Listed-order priority admits J6 first for one unit, t=10 to 11. Then J7 runs for eight units, t=11 to 19. Thus the requested completion time is 10+1+8=19.

A compact critical-resource diagram is:
20 KB: | J2, 0–10 | J6, 10–11 | J7, 11–19 |
8 KB: | J4, 0–1 | J5, 1–5 |

J8 may enter a smaller partition earlier if the allocator bypasses blocked jobs, or later under strict head-of-line waiting; this does not change the listed-order use of the 20 KB partition. Best fit alone specifies a partition choice, not a scheduling discipline or arrival times. If arbitrary priority allowed J7 ahead of J6 at t=10, it would finish at 18. Therefore 19 is the conventional answer with the stated order assumptions, not a consequence of the phrase “best fit” alone.

Original paper, page 6