A2 · Practice questions · Paging, segmentation and virtual memory

Swap it in.

Six original Cambridge-style questions on memory management, including address translation and page replacement traces, with mark-scheme solutions.

Original questions All questions on this page are original work, written in the Cambridge AS & A Level style. They are not from past papers. They test the same concepts and skills the syllabus rewards.
Keep these straight

Pages, segments, swaps.

01
Explain
[4 marks]

Explain the differences between paging and segmentation.

  • Pages are a fixed size; segments are variable sizes. ✓
  • Paging is a physical division of memory; segmentation is a logical division that matches the structure of the program (e.g. procedures, data). ✓
  • A page address is a page number and offset mapped through a page table to a frame; a segment address is a segment number and offset, using a segment table holding a base address and length. ✓
  • Paging can cause internal fragmentation (part-empty last page); segmentation can cause external fragmentation (gaps between segments). ✓
02
Calculate
[3 marks]

A computer uses pages of 4096 bytes. Page 3 of a process is stored in frame 6. Calculate the physical address of logical address 13000, showing your working.

  • Page number = 13000 DIV 4096 = 3. ✓
  • Offset = 13000 MOD 4096 = 13000 − 12288 = 712. ✓
  • Physical address = 6 × 4096 + 712 = 24576 + 712 = 25288. ✓
03
Trace
[4 marks]

A process has three page frames, initially empty. It requests pages in this order: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3. Using FIFO page replacement, show the contents of the frames after each request and state the number of page faults.

  • 7, 0, 1 fill the frames (3 faults); 2 replaces 7 (oldest); 0 is a hit. ✓
  • 3 replaces 0; 0 replaces 1; 4 replaces 2. ✓
  • 2 replaces 3; 3 replaces 0. Final frames: 4, 2, 3. ✓
  • Total: 9 page faults (only the request for 0 at position 5 is a hit). ✓
04
Trace
[3 marks]

Repeat the trace in the previous question using least recently used (LRU) replacement and state the number of page faults.

  • 7, 0, 1 fill the frames; 2 replaces 7; 0 is a hit; 3 replaces 1 (least recently used of 2, 0, 1). ✓
  • 0 is a hit; 4 replaces 2; 2 replaces 3; 3 replaces 0. Final frames: 4, 3, 2 (frame 1 holds 4, frame 2 holds 3, frame 3 holds 2). ✓
  • Total: 8 page faults (two hits, both for page 0). ✓
05
Explain
[4 marks]

Explain how disk thrashing can occur in a system that uses virtual memory, and its effect.

  • Too many processes, or processes needing more pages than they have frames, so RAM is over-committed. ✓
  • A page is swapped out to disk and then needed again almost immediately, causing another page fault. ✓
  • Pages are continually swapped between RAM and disk. ✓
  • The processor spends most of its time waiting for page transfers, so very little useful processing is done and performance drops sharply. ✓
06
Analysis
[3 marks]

Discuss whether FIFO or LRU is the better page replacement algorithm.

  • FIFO is simple: it only needs a queue of the order pages were loaded. ✓
  • But FIFO may remove a page that is heavily used just because it was loaded early, causing extra page faults. ✓
  • LRU usually gives fewer page faults because recently used pages are likely to be used again, but it has more overhead, as the time of every access must be recorded and searched. ✓

Mark this once you have attempted all six and checked your working. It records a Practiced badge on the topic and adds a one-time bonus. Revealing the solutions alone does not count.