GATE / CS ARCHIVE

SUBJECT COLLECTION

Operating Systems · Memory Allocation & Segmentation

10 questions, newest first

GATE CSE has asked 10 questions on Memory Allocation & Segmentation (Operating Systems) from 1994 to 2026, in 7 of the 46 papers; the most recent is in GATE CSE 2026 Set 2. In the last five years it carried 0.2 marks per 100-mark paper on average, against 0.1 since 2003. Since 2014 the questions have been 2 MCQ and 1 NAT. 2 groups of questions here are solved the same way; “One per method” keeps the newest of each.

Browse topics
2 marks · NAT
Report issue

Best-fit allocations and remaining holes

Memory Allocation & Segmentation

Question 55, GATE 2026: Nonadjacent free holes have sizes 20,4,25,18,7,9,15,12 KB. Allocate a 16 KB process and then a 9 KB process by best fit. How many remaining holes are smaller than 8 KB?
Tap to enlarge
Answer & solution

Official answer: 3

Givens and goal

Nonadjacent free holes have sizes 20,4,25,18,7,9,15,12 KB. Allocate a 16 KB process and then a 9 KB process by best fit. How many remaining holes are smaller than 8 KB?

Approach

At each arrival choose the smallest currently adequate hole, then update the list.

Step-by-step solution

1. For the 16 KB request the adequate holes are 18,20,25 KB. Best fit chooses 18 KB, leaving an 18−16=2 KB fragment. The 15 KB and smaller holes cannot accommodate it.
2. Afterward the hole sizes are 20,4,25,2,7,9,15,12 KB. For the 9 KB request, the 9 KB hole is an exact fit and is removed entirely; it does not remain as a zero-size hole.
3. The final positive hole sizes are 20,4,25,2,7,15,12 KB. Those strictly less than 8 KB are 4,2,7 KB, giving three holes.
4. No coalescing is performed because the original holes are nonadjacent and these operations only split or consume them. The answer is 3. Always recompute the available holes after the first allocation rather than assigning both requests independently to the original list.

Original paper, page 39 · Answer key

1 mark · MCQ
Report issue

Memory Allocation & Segmentation

Question 11, GATE 2020: Allocate one process into a memory hole, with no exact fit. Which comparison of newly remaining holes is always true? A first-fit remainder > next-fit remainder; B worst-fit remainder > first-fit remainder; C best-fit remainder ≤ first-fit remainder; D next-fit remainder ≤ best-fit remainder.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Worked explanation

Let p be the process size and let H be the set of adequate hole sizes. Best fit chooses hB=min H. If first fit chooses hF∈H, then hB≤hF, and subtracting p gives hB−p≤hF−p. This is exactly C and allows equality. For counterexamples to strict claims A and B, take a single adequate hole: all policies choose it, so no remainder is strictly larger. D fails with adequate holes of sizes 10 and 20 for a process of size 6 when next fit chooses 20: its remainder 14 exceeds best fit’s 4. The cursor position matters for next fit, not for the minimum defining best fit.

Derivation and answer

Best fit chooses the smallest adequate hole. Subtracting the same process size from that hole and from the first-fit hole preserves the ≤ relation, so the best-fit remainder is never larger. Strict inequalities in the other options can fail when policies select the same hole. Thus C.

Original paper, page 6 · Answer key

2 marks · MCQ
Report issue

Memory Allocation & Segmentation

Question 41, GATE 2015: Free partitions 200, 400, 600, 500, 300, 250 KB. Allocate processes 357, 210, 468, 491 KB in order using bestfit. Which original partitions stay unused? A200, 300; B200, 250; C250, 300; D300, 400.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Best fit assigns 357 to 400, 210 to 250, 468 to 500, and 491 to 600. Original partitions 200 and 300 remain unused, A. Splitting residual space does not alter these choices.

At each request choose the smallest remaining partition large enough.357 fits 400, 500, 600; choose 400.210 fits 250, 300, 500, 600; choose 250.468 fits 500 or 600; choose 500.491 then uses 600. The unused original partitions are 200 and 300. If partitions are split, the resulting remnants 43, 40, 32 and 109 are all too small to change these subsequent choices, so the answer remains the same.

Original paper, page 40 · Answer key

2 marks · MCQ
Not in GATE 2027 syllabusReport issue

Maximum resident overlay path

Memory Allocation & Segmentation

Question 2.16, GATE 1998: Overlay tree: root 2 KB; children A 4, B6, C8; A has D6, E8; B has F2; C has G4. Minimum partition size among 12, 14, 10, 8 KB?
Question 2.16, GATE 1998: Overlay tree: root 2 KB; children A 4, B6, C8; A has D6, E8; B has F2; C has G4. Minimum partition size among 12, 14, 10, 8 KB?
Tap to enlarge
Your answer
Answer & solution

Answer: B: 14 KB (no official key was published)

Only one sibling overlay branch needs to coexist at a time, but a descendant must coexist with its ancestors. Compute root-to-leaf sums: root-A-D=2+4+6=12; root-A-E=2+4+8=14; root-B-F=2+6+2=10; root-C-G=2+8+4=14 KB. The largest is 14 KB, so B. Summing every module would ignore overlay sharing; allocating only the largest individual module would omit resident ancestors. Module sizes were cross-checked in the clearer alternate diagram.

Original paper, page 5

Descriptive
Report issue

Best-fit completion timeline

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

2 marks · MCQ
Report issue

Worst external fragmentation

Memory Allocation & Segmentation

Question 2.18, GATE 1996: A 1000-Kbyte variable-partition memory has two allocated partitions of 200 and 260 Kbytes, with no compaction. What smallest integer-Kbyte request could be denied?
Tap to enlarge
Your answer
Answer & solution

Answer: B: 181 Kbytes (no official key was published)

Free space totals 1000−200−260=540 Kbytes. Two occupied contiguous partitions divide linear memory into at most three free holes. Therefore at least one hole has size at least 540/3=180 Kbytes, so every request of at most 180 Kbytes can fit somewhere. This bound is attainable by arranging hole 180,allocation 200,hole 180,allocation 260,hole 180. In that layout a request of 181 Kbytes fails despite sufficient total free memory. Thus 181 is the smallest integer request that could fail; the question asks a possible worst layout, not a guarantee for every layout.

Original paper, page 6

Descriptive
Report issue

Trace first fit and best fit

Memory Allocation & Segmentation

Question 5(a), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Draw both memory allocation sequences.
Question 5(a), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Draw both memory allocation sequences.
Tap to enlarge
Answer & solution

Answer: First fit admits all jobs; best fit cannot admit J6. (no official key was published)

Use half-open address intervals in K so that [0,200) has size 200. Both algorithms initially allocate J1=[0,200), J2=[200,550), J3=[550,850), leaving [850,1000) free. When J1 finishes, the holes are [0,200) and [850,1000).

First fit: J4 takes [0,120), leaving holes [120,200) of size 80 and [850,1000) of size 150. J5 cannot fit in 80, so it occupies [850,1000). J6 then exactly fills [120,200). Final low-to-high layout is J4:120 | J6:80 | J2:350 | J3:300 | J5:150.

Best fit: J4 takes the smaller adequate hole [850,1000), occupying [850,970) and leaving 30K. J5 takes [0,150), leaving [150,200) of size 50. J6 needs 80K but neither the 50K nor 30K hole suffices. Final layout is J5:150 | free:50 | J2:350 | J3:300 | J4:120 | free:30, with J6 waiting.

The total free space is 80K, equal to J6’s request, but it is split into nonadjacent holes. This is external fragmentation, not a shortage of aggregate space.

Original paper, page 6

Descriptive
Report issue

Compare allocation outcomes

Memory Allocation & Segmentation

Question 5(b), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Which policy performs better for this sequence?
Question 5(b), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Which policy performs better for this sequence?
Question 5(b), GATE 1995: 1000K of contiguous free memory receives J1=200K, J2=350K, J3=300K; J1 finishes; then J4=120K, J5=150K and J6=80K arrive, in that order. Assume allocations start at the low-address end of a selected hole, free holes coalesce, no compaction and first fit searches from the lowest address. Which policy performs better for this sequence?
Tap to enlarge
Answer & solution

Answer: First fit. (no official key was published)

First fit places the 120K job in the initial 200K hole, preserving an 80K remainder. It then puts the 150K job in the separate 150K hole and admits the final 80K job into the exact remainder. Consequently every arriving job is resident at the end, filling all 1000K.

Best fit uses the 150K hole for the 120K request, leaving 30K. The later 150K request takes 150K out of the 200K hole, leaving 50K. Although 50+30=80, the final 80K request requires one contiguous region and cannot be admitted without relocation or compaction. First fit therefore performs better on the stated admission/utilization criterion. This trace is a counterexample to the intuition that the locally smallest leftover always leads to the best future allocation. It is not a proof that first fit dominates best fit for every workload.

Original paper, page 6

Not in GATE 2027 syllabusReport issue

Overlaying versus virtual address space

Memory Allocation & Segmentation

Question 1.21, GATE 1994: Which is true: nested macro definitions are impossible; overlays allow a program larger than address space; virtual memory exceeds address space; or high-level interrupt routines are impossible?
Tap to enlarge
Your answer
Answer & solution

Answer: B under the total-program-overlay interpretation (no official key was published)

An overlay design keeps only selected mutually exclusive program portions resident at once and loads others into reused addresses. Its total stored program can therefore exceed the simultaneously addressable space, provided each active configuration fits. Virtual memory can exceed installed physical RAM, but it does not by itself enlarge the architecture’s virtual address space. Nested macros and high-level interrupt routines are possible in suitable tools, so the blanket impossibility claims fail.

Original paper, page 3

Report issue

First fit versus best fit

Memory Allocation & Segmentation

Question 1.24, GATE 1994: The pictured heap has allocated lengths 50,300,600 separating free holes of lengths 150 and 350. Can requests 300,25,125,50 be satisfied by first fit, best fit, both or neither?
Tap to enlarge
Your answer
Answer & solution

Answer: B: first fit but not best fit (no official key was published)

Both policies allocate the first request in the 350 hole, leaving free lengths [150,50]. First fit places 25 in the first hole, leaving [125,50], then 125 there, leaving [0,50], and finally fits 50. Best fit places 25 in the 50 hole, leaving [150,25], then 125 in the 150 hole, leaving [25,25]. The final 50 fits neither hole, though total free space is 50. Hence only first fit succeeds.

Original paper, page 3