← IGCSE Computer Science Paper 1

Pages moving between RAM and virtual memory

Data is split into fixed-size pages. Idle pages are moved out of RAM into virtual memory, then swapped back into RAM when the CPU needs them.

Understanding Pages moving between RAM and virtual memory in IGCSE Computer Science Paper 1

What it does: Swapping in is the reverse of swapping out: the needed page is brought from virtual memory back into RAM so the CPU can use it. Idle pages are swapped out to free space in RAM. Pages the CPU is actively using stay in RAM. Virtual memory is an area of secondary storage that is used as an extension of RAM. Data is divided into equal-sized blocks called pages, so each one can be swapped in or out of RAM as a single unit.

Common mistakes: The idle page must be one that is currently in RAM so it can be swapped out. P4 is not in RAM (RAM holds P1, P2 and P3). It should be a RAM page such as idle ← P2. Pages are fixed-size blocks of data, so the page size must be a constant value such as 4096, not a random number.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 314–324) and word search (Modules 304–324).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
In paging, how is data divided up?
Into variable-size files chosen by the userInto fixed-size blocks called pages
Matches
Pages are different sizes so they fit any gap in RAM
↓
Pages are all the same fixed size, not different sizes
Applying
Meanings
Term
paging
Meaning
Data is split into fixed-size pages. Idle pages are moved out of RAM into virtual memory, then swapped back into RAM when the CPU needs them.
Practice
needed ← Page4
Testing
Gaps
SWAP idlePage FROM RAM TO
Check Answer
Spots
1RAM ← [P1, P2, P3]
2idle ← P4

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Octopus' badge — Multi-Tasker, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. In paging, how is data divided up?
A. Into variable-size files chosen by the user
B. Into fixed-size blocks called pages ✓
Data is split into pages that are all the same size, which makes them easy to move between RAM and virtual memory.
2. Which pages are moved out of RAM into virtual memory?
A. Pages that are not currently needed (idle) ✓
B. Pages the CPU is using right now
Idle pages are swapped out to free space in RAM. Pages the CPU is actively using stay in RAM.
3. The CPU needs a page that is stored in virtual memory. What happens?
A. The page is swapped back into RAM ✓
B. The CPU runs the page directly from the hard drive
The CPU can only work with data in RAM, so the needed page is moved back from virtual memory into RAM.
4. RAM is full and a new page is needed. What does the computer do first?
A. Deletes the oldest page permanently
B. Moves an idle page out to virtual memory to make room ✓
Idle pages are not deleted. They are saved in virtual memory so they can be swapped back later.
5. Where is virtual memory located?
A. On secondary storage, such as a hard drive or SSD ✓
B. Inside the CPU
Virtual memory is an area of secondary storage that is used as an extension of RAM.

Match the Pairs

page → A fixed-size block of data that can be moved between RAM and virtual memory
swap out → Move an idle page from RAM to virtual memory to free up space
A page the CPU needs is in virtual memory, so it is copied back into RAM → swap in
Data is split into equal-sized blocks so it can be moved easily → paging
Pages are different sizes so they fit any gap in RAM → Pages are all the same fixed size, not different sizes
The CPU runs a page straight from virtual memory → The page must be swapped back into RAM before the CPU can use it

Key Term

paging
Data is split into fixed-size pages. Idle pages are moved out of RAM into virtual memory, then swapped back into RAM when the CPU needs them.

Fill in the Blanks

1. SWAP idlePage FROM RAM TO virtualMemory
Hint: Type the place where a page that is not currently needed is moved out to.
2. SWAP page2 FROM virtualMemory TO RAM
Hint: Type the memory the CPU can use directly, where a needed page is swapped back to.
3. IF page3Needed = TRUE THEN SWAP page3 FROM virtualMemory TO RAM ENDIF
Hint: Type the keyword that comes after the condition and starts the swap-in step.
4. numPages ← dataSize DIV pageSize
Hint: Type the operator for whole-number division, which tells how many fixed-size pages the data fills.
5. WHILE ramFull = TRUE DO SWAP idlePage FROM RAM TO virtualMemory ENDWHILE
Hint: Type the loop keyword that keeps swapping pages out for as long as RAM is full.

Spot the Error

Question 1
A RAM ← [P1, P2, P3]
B idle ← P4
C MOVE idle FROM RAM TO VM
Line B — The idle page must be one that is currently in RAM so it can be swapped out. P4 is not in RAM (RAM holds P1, P2 and P3). It should be a RAM page such as idle ← P2.
Question 2
A pageSize ← RANDOM(1, 9)
B pages ← CEIL(size / pageSize)
C OUTPUT pages
Line A — Pages are fixed-size blocks of data, so the page size must be a constant value such as 4096, not a random number.
Question 3
A IF CPU needs page P5 THEN
B IF P5 is in VM THEN
C SWAP P5 OUT OF RAM
D ENDIF
E ENDIF
Line C — The CPU needs P5 and it is in virtual memory, so it must be swapped INTO RAM. Swapping it out of RAM is the wrong direction.
Question 4
A FOR each page in RAM
B IF page is in use THEN
C MOVE page TO VM
D ENDIF
E ENDFOR
Line B — Only idle pages (not currently needed) should be moved out to virtual memory. Moving pages that are in use would slow the program. It should be IF page is idle THEN.
Question 5
A RAM_FULL ← TRUE
B IF RAM_FULL = FALSE THEN
C MOVE idle page TO VM
D ENDIF
Line B — Idle pages are moved to virtual memory to free space when RAM is full. The condition should be IF RAM_FULL THEN, not when RAM is not full.

Student with a class code? Join your class →