Memory Management MCQs for NSCT

By the NSCT Exam Editorial Team · Updated 2026-11-24 · Facts checked against official sources on 2026-11-24

Memory management is how the operating system shares main memory between processes. It maps each process's logical addresses to physical ones, keeps processes from touching each other's memory, and uses virtual memory to run programs larger than RAM. It is topic 8 of the Operating Systems area, which carries 5% of the NSCT according to HEC's Areas of Competencies. OS was the weakest area in 2026, with candidates averaging 33.8% accuracy, per the HEC NSCT report and APP.

Most marks here come from numericals, so this page follows Silberschatz's Operating System Concepts and gives a number for every idea.

Contiguous allocation and fragmentation

In the simplest scheme each process gets one contiguous block, guarded by a base register and a limit register. A free block is called a hole, and the OS chooses one for each request using one of three strategies:

Strategy Picks Note
First fit First hole big enough Fast, and usually as good as best fit
Best fit Smallest hole big enough Leaves tiny leftover holes
Worst fit Largest hole Leaves big leftovers, but usually performs worst

For example, with holes of 250, 600, 200, 750 and 500 KB, a 340 KB request goes to 600 under first fit, 500 under best fit and 750 under worst fit. External fragmentation means enough free memory exists in total, but not in one piece. Internal fragmentation is unused space inside an allocated block. Compaction can cure external fragmentation, but only if relocation happens at run time.

Paging

Paging splits logical memory into fixed-size pages and physical memory into frames of the same size. A page table maps each page to a frame. An address splits into a page number p and an offset d: with a 2^n-byte page, d is the low n bits.

Example: pages are 1,024 bytes, and page 3 is in frame 7. Logical address 3085 gives p = 3085 div 1024 = 3 and d = 13, so the physical address is 7 × 1024 + 13 = 7181.

Paging removes external fragmentation but leaves internal fragmentation in each process's last page. Every access would need two memory references (one for the page table, one for the data), so a TLB (translation look-aside buffer) caches recent mappings:

EAT = h × (TLB + mem) + (1 − h) × (TLB + 2 × mem)

With a 20 ns TLB, 100 ns memory and a 90% hit ratio: 0.9 × 120 + 0.1 × 220 = 130 ns. Textbooks differ here: Silberschatz's 10th edition ignores TLB time, which gives 110 ns for the same figures. So always use the convention the question states.

Large address spaces use hierarchical paging. On a 32-bit system with 4 KB pages and 4-byte entries, a single-level table is 4 MB, so it is split 10 / 10 / 12. Inverted page tables keep one entry per frame instead. Exam angle: in hex, with 4 KB pages, the last three hex digits are the offset, so 0x2ABC with page 2 in frame 5 becomes 0x5ABC. See paging and address translation for more drills.

Segmentation

Segmentation divides a program into variable-sized logical units, such as code, data, stack and heap. An address is (segment, offset), and the segment table gives each segment a base and a limit. If the offset is less than the limit, the physical address is base + offset; otherwise the hardware traps.

Example: segment 2 has base 4300 and limit 400. (2, 53) maps to 4353, but (2, 450) traps.

Paging Segmentation
Unit size Fixed Variable
Programmer sees it? No Yes
Fragmentation Internal External

Exam angle: the trap is checked against the limit before the base is added. Never add base + offset first.

Virtual memory

Virtual memory separates logical memory from physical memory, so a process can run with only part of itself loaded. Under demand paging, a page is loaded only when it is first used. A reference to a page marked invalid causes a page fault. The OS then finds a frame, reads the page from disk, updates the table and restarts the instruction.

EAT = (1 − p) × memory access + p × fault service time

With 100 ns memory, a 10 ms fault time and p = 0.0001, the EAT is about 1,100 ns, eleven times slower. Copy-on-write lets a parent and child share pages after fork() until one of them writes. Thrashing happens when processes have fewer frames than their working set, so they spend more time paging than computing. The fix is to run fewer processes, not more.

Page replacement

When no frame is free, a victim page must go:

For 1, 3, 0, 3, 5, 6, 3, 4, 1, 0, 3, 6 with 3 frames, FIFO gives 11 faults, LRU 10 and Optimal 8. Belady's anomaly means more frames can cause more faults under FIFO. On 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5, FIFO gives 9 faults with 3 frames but 10 with 4. LRU and Optimal are stack algorithms, so this cannot happen to them. Drill these on the page replacement page.

Common traps

Worked examples

Understanding. Which kind of fragmentation does pure segmentation suffer from? Answer: external. Segments vary in size, so free memory breaks into holes between them. Nothing is wasted inside a segment, because each one is allocated exactly its own length.

Application. A machine has 16-bit addresses and 512-byte pages, and page 9 is in frame 3. What is the physical address of 0x1234? Answer: 1588 (0x634). 0x1234 = 4660. Page = 4660 div 512 = 9 and offset = 52. Physical address = 3 × 512 + 52 = 1588.

Analysis. A system uses two-level paging, with a 10 ns TLB, 100 ns memory and a 95% hit ratio. TLB time counts on both hits and misses. What is the EAT? Answer: 120 ns. A hit costs 10 + 100 = 110 ns. A miss costs 10 + 3 × 100 = 310 ns (two table levels plus the data). EAT = 0.95 × 110 + 0.05 × 310 = 104.5 + 15.5 = 120 ns. A high hit ratio is what makes multi-level tables affordable.

Practise

The quiz below has 100 Memory Management questions, which you can filter by tier and difficulty.

Practise: 100 questions

Interactive quiz loading. The first 10 questions are shown below.

  1. Which hardware unit converts the logical (virtual) addresses generated by the CPU into physical addresses at run time?

    1. Direct memory access (DMA) controller
    2. Arithmetic logic unit (ALU)
    3. Memory-management unit (MMU)
    4. Program counter
    Show answer

    Answer: C. Memory-management unit (MMU)

    The MMU maps every logical address to a physical one, using a relocation register in simple schemes or the page table (with a TLB) in paging. The program only ever sees logical addresses.

  2. Which kind of fragmentation does pure paging eliminate, and which can it still suffer?

    1. It eliminates internal fragmentation but can still have external fragmentation
    2. It eliminates both kinds of fragmentation
    3. It suffers from both kinds equally
    4. It eliminates external fragmentation but can still have internal fragmentation
    Show answer

    Answer: D. It eliminates external fragmentation but can still have internal fragmentation

    Any free frame can hold any page, so free memory is never too scattered to use (no external fragmentation). But a process's last page is usually only partly full, and that unused space inside the frame is internal fragmentation.

  3. In pure segmentation, a logical address consists of:

    1. A page number and a frame number
    2. A base register value and a limit register value
    3. A frame number and an offset within that frame
    4. A segment number and an offset within that segment
    Show answer

    Answer: D. A segment number and an offset within that segment

    Segmentation matches the programmer's view: code, stack, heap and so on are separate segments. An address is (s, d); the segment table supplies base and limit for segment s, and d is checked against the limit.

  4. What is a translation look-aside buffer (TLB)?

    1. A small, fast associative cache of recent page-table entries
    2. A disk area that holds pages swapped out of memory
    3. A register holding the base address of the page table
    4. A queue of processes waiting for free frames
    Show answer

    Answer: A. A small, fast associative cache of recent page-table entries

    Each memory reference would otherwise need an extra memory access to read the page table. The TLB keeps recent page-to-frame mappings in fast associative hardware, so on a hit the frame number is found almost instantly.

  5. Under demand paging, when does a page fault occur?

    1. When the TLB is full
    2. When two processes try to share the same frame
    3. When a process references a page whose page-table entry is marked invalid because the page is not in memory
    4. When a page is written for the first time after being loaded
    Show answer

    Answer: C. When a process references a page whose page-table entry is marked invalid because the page is not in memory

    The valid-invalid bit marks pages not currently in memory. Touching such a page traps to the OS, which finds a free frame (or a victim), reads the page from backing store, updates the table and restarts the instruction.

  6. Belady's anomaly, where adding frames increases page faults, can occur with which algorithm?

    1. LRU
    2. FIFO
    3. Optimal (OPT)
    4. LRU and Optimal, but not FIFO
    Show answer

    Answer: B. FIFO

    LRU and Optimal are stack algorithms: the pages held with n frames are always a subset of those held with n + 1, so more frames can never mean more faults. FIFO lacks this property, so its fault count can rise with more frames.

  7. What is thrashing?

    1. Rapid switching between user mode and kernel mode
    2. Repeated TLB misses caused by a small TLB
    3. A state where processes spend more time paging than executing because they lack enough frames
    4. Compaction running too frequently
    Show answer

    Answer: C. A state where processes spend more time paging than executing because they lack enough frames

    When the frames given to processes are fewer than their working sets, they fault constantly. CPU utilisation falls, and a naive scheduler may add even more processes, making it worse. Silberschatz describes exactly this cycle.

  8. The working-set model is based on which principle?

    1. First come, first served
    2. Belady's anomaly
    3. Locality of reference
    4. Mutual exclusion
    Show answer

    Answer: C. Locality of reference

    Programs move from one locality (a set of pages used together) to another. The working set is the set of pages referenced in the last Δ references; giving each process enough frames for its working set prevents thrashing.

  9. In demand paging, a page is brought into memory:

    1. Only when it is first referenced
    2. All at once when the process is created
    3. Only when the process terminates
    4. Whenever the TLB is flushed
    Show answer

    Answer: A. Only when it is first referenced

    Demand paging uses a lazy pager: nothing is loaded until it is needed. Pages that are never touched are never read from disk, which saves I/O and memory and allows more processes in memory.

  10. What does copy-on-write do when a process calls fork()?

    1. The child gets a full private copy of every page immediately
    2. The child's pages are written to disk and loaded on demand
    3. Parent and child share the same pages until one of them writes, and only then is that page copied
    4. Parent and child share pages permanently, including writes
    Show answer

    Answer: C. Parent and child share the same pages until one of them writes, and only then is that page copied

    Copying the whole address space is wasteful because the child often calls exec() straight away. With copy-on-write, shared pages are marked read-only; a write traps, and the OS copies just that page for the writer.

FAQs

What is the difference between a logical and a physical address?

A logical (virtual) address is generated by the CPU while a program runs. It is what the program sees. A physical address is the actual location in RAM. The MMU translates one to the other at run time, using a relocation register, page table or segment table. Under compile-time or load-time binding the two are the same.

Why is LRU hard to implement exactly?

True LRU must record the order of every memory reference. Hardware would need either a timestamp on each page-table entry or a stack updated on every access, both of which are costly. Real systems approximate it with reference bits, for example the second-chance (clock) algorithm. Clock behaves like FIFO when every reference bit is set.

What is the working set of a process?

It is the set of pages the process referenced in its most recent Δ (delta) memory references, a window of fixed size. It approximates the current locality. If the total working-set size of all processes exceeds the available frames, thrashing follows, so the OS should suspend a process until there is room.

Is a bigger page size always better?

No. Bigger pages mean smaller page tables, fewer TLB misses and more efficient disk I/O. But they waste more space to internal fragmentation (about half a page per process on average) and may load data that is never used. Page size is a trade-off, and modern systems often support several sizes.

Next step

Continue with File System Management MCQs, go back to the Operating Systems hub, or try a timed NSCT mock test.