Why virtual memory is needed

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Why virtual memory is needed

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Why does a computer need virtual memory?
A RAM is limited in size, so extra space is needed when it fills up
B The CPU is too slow to run programs without it
2. A student opens a web browser, a music player, a game and a document at the same time. What may happen if RAM becomes full and there is no virtual memory?
A The computer automatically adds more RAM chips
B Programs may fail, freeze or refuse to open
3. Where does virtual memory get its extra space from?
A Secondary storage such as the hard drive or SSD
B The ROM chip on the motherboard
4. True or false: The main purpose of virtual memory is to let a computer run programs and data that are bigger than its RAM.
A True
B False
5. Which sentence best describes a sub-theme of why virtual memory is needed?
A Closing one program always makes RAM bigger
B Many programs open at once can use up all the RAM

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1RAM = 4 GB, programs open = 6 GB AVirtual memory is needed because RAM is limited in size, not because it is too fast. Virtual memory is actually slower than RAM.
2RAM full -> use virtual memory BWhen RAM runs out of space, the computer uses part of secondary storage as extra RAM instead of failing
3RAM is limited in size, so it can only hold so much data at once CIF dataNeeded > ramSize THEN useVirtualMemory
4Many programs open at once can use up all of the RAM DWithout virtual memory programs might fail, but with it the computer uses secondary storage as extra RAM so programs keep running.
5Virtual memory is needed because RAM is too fast EThe programs need more space than RAM has, so virtual memory is needed to hold the extra
6When RAM is full, programs must stop working FtotalUsed ← browser + game + music + video

Definitions

virtual memory

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
IF programsSize _ ramSize THEN useVirtualMemory() ENDIF
2.
IF ramIsFull THEN ________________() ENDIF
3.
IF manyProgramsOpen ___ ramIsFull THEN useVirtualMemory() ENDIF
4.
useVirtualMemory() programFails ← _____ OUTPUT "Programs keep running"
5.
totalMemory ← ramSize _ virtualSize IF programsSize <= totalMemory THEN runPrograms()

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A RAM_SIZE <- 8
B needed <- 12
C IF needed > RAM_SIZE THEN
D STOP all programs
E ENDIF
Question 2
A RAM_SIZE <- unlimited
B needed <- 6
C IF needed > RAM_SIZE THEN
D USE virtual_memory
Question 3
A programsOpen <- 20
B ramFull <- TRUE
C IF ramFull = FALSE THEN
D USE virtual_memory
Question 4
A RAM_SIZE <- 8
B total <- 6 + 5
C IF total < RAM_SIZE THEN
D USE virtual_memory
Question 5
A FOR i <- 1 TO 10
B OPEN program[i]
C IF ramFull = TRUE
D USE virtual_memory
E ENDIF
F NEXT i

Answer Key

Why virtual memory is needed
Section A: Quick Questions
Q1
A — RAM is limited in size, so extra space is needed when it fills up
Q2
B — Programs may fail, freeze or refuse to open
Q3
A — Secondary storage such as the hard drive or SSD
Q4
A — True
Q5
B — Many programs open at once can use up all the RAM
Section B: Match the Pairs
Q1
RAM = 4 GB, programs open = 6 GB → The programs need more space than RAM has, so virtual memory is needed to hold the extra
Q2
RAM full -> use virtual memory → When RAM runs out of space, the computer uses part of secondary storage as extra RAM instead of failing
Q3
RAM is limited in size, so it can only hold so much data at once → IF dataNeeded > ramSize THEN useVirtualMemory
Q4
Many programs open at once can use up all of the RAM → totalUsed ← browser + game + music + video
Q5
Virtual memory is needed because RAM is too fast → Virtual memory is needed because RAM is limited in size, not because it is too fast. Virtual memory is actually slower than RAM.
Q6
When RAM is full, programs must stop working → Without virtual memory programs might fail, but with it the computer uses secondary storage as extra RAM so programs keep running.
Section C: Definitions
Q1
virtual memory — Part of secondary storage used as extra RAM, so a computer can run programs and data bigger than its RAM, with many programs open, without them failing when RAM is full.
Section D: Fill in the Blanks
Q1
IF programsSize > ramSize THEN useVirtualMemory() ENDIF
Q2
IF ramIsFull THEN useVirtualMemory() ENDIF
Q3
IF manyProgramsOpen AND ramIsFull THEN useVirtualMemory() ENDIF
Q4
useVirtualMemory() programFails ← FALSE OUTPUT "Programs keep running"
Q5
totalMemory ← ramSize + virtualSize IF programsSize <= totalMemory THEN runPrograms()
Section E: Spot the Error
Q1
D — When the programs need more than the RAM can hold, the computer uses virtual memory so they can keep running. They are not stopped. The line should be USE virtual_memory.
Q2
A — RAM is limited in size, so it needs a fixed amount such as 4. If RAM were unlimited, virtual memory would not be needed.
Q3
C — Virtual memory is needed when RAM is full, so the condition must be true when ramFull is TRUE. It should be IF ramFull THEN.
Q4
C — Virtual memory is needed when the programs and data together are bigger than RAM. The test should use > and not <.
Q5
C — An IF statement must end its condition with THEN. The line should be IF ramFull = TRUE THEN.