Virtual memory and computer performance

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

Virtual memory and computer performance

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Why does a computer slow down when it swaps pages between RAM and virtual memory a lot?
A Secondary storage is much slower than RAM
B Secondary storage is much faster than RAM
2. A computer has very little free RAM and many programs open. What is likely to happen?
A The computer speeds up as it uses more virtual memory
B Heavy swapping makes the computer sluggish
3. Which change would reduce the amount of swapping on a computer?
A Adding more RAM
B Adding more virtual memory
4. True or false: virtual memory is a full replacement for RAM.
A False - it only extends RAM and is slower
B True - it works just as fast as RAM
5. Which statement best describes when virtual memory hurts performance?
A When RAM has plenty of free space
B When pages are swapped in and out all the time

Match the Pairs

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

Left columnRight column
1thrashing ARAM speed >> HDD speed, so swapping = slow
2Upgrade RAM from 4 GB to 16 GB BVirtual memory uses secondary storage, which is much slower than RAM, so it cannot replace RAM.
3Secondary storage is much slower than RAM, so using it as virtual memory slows the computer down CHeavy swapping makes the computer slower, because the CPU must wait for slow secondary storage to move pages.
4Virtual memory is only a backup when RAM is full and is not a replacement for RAM DGives the computer more space for running programs, so fewer pages are swapped to virtual memory and it runs faster
5Virtual memory is faster than RAM, so a computer with lots of virtual memory never needs more RAM EThe computer spends most of its time swapping pages between RAM and secondary storage, so it becomes very slow
6Heavy swapping makes the computer faster because pages move to secondary storage more often FIF RAM_full THEN use virtual_memory

Definitions

thrashing

Fill in the Blanks

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

1.
IF ramFull ____ swapPages() ENDIF
2.
IF swapsPerSecond _ 100 THEN sluggish = TRUE ENDIF
3.
ramSize = ramSize _ 8 swapping = swapping - 1
4.
IF virtualSpeed _ ramSpeed THEN OUTPUT "Not a RAM replacement" ENDIF
5.
state = _________ OUTPUT "Computer is sluggish"

Spot the Error

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

Question 1
A RAM is full
B Pages move to virtual memory
C Virtual memory is inside RAM
D so it is slower than RAM
Question 2
A WHILE swapping is heavy
B computer feels very quick
C storage is slower than RAM
D ENDWHILE
Question 3
A pagesSwapped ← 500
B IF pagesSwapped > 100 THEN
C OUTPUT 'Computer is fast'
D ENDIF
Question 4
A Computer has 1 GB of RAM
B Program needs 3 GB
C VM gives extra space
D VM is as fast as RAM
Question 5
A Many programs are open
B RAM stays almost empty
C Pages are swapped constantly
D Thrashing slows the computer

Answer Key

Virtual memory and computer performance
Section A: Quick Questions
Q1
A — Secondary storage is much slower than RAM
Q2
B — Heavy swapping makes the computer sluggish
Q3
A — Adding more RAM
Q4
A — False - it only extends RAM and is slower
Q5
B — When pages are swapped in and out all the time
Section B: Match the Pairs
Q1
thrashing → The computer spends most of its time swapping pages between RAM and secondary storage, so it becomes very slow
Q2
Upgrade RAM from 4 GB to 16 GB → Gives the computer more space for running programs, so fewer pages are swapped to virtual memory and it runs faster
Q3
Secondary storage is much slower than RAM, so using it as virtual memory slows the computer down → RAM speed >> HDD speed, so swapping = slow
Q4
Virtual memory is only a backup when RAM is full and is not a replacement for RAM → IF RAM_full THEN use virtual_memory
Q5
Virtual memory is faster than RAM, so a computer with lots of virtual memory never needs more RAM → Virtual memory uses secondary storage, which is much slower than RAM, so it cannot replace RAM.
Q6
Heavy swapping makes the computer faster because pages move to secondary storage more often → Heavy swapping makes the computer slower, because the CPU must wait for slow secondary storage to move pages.
Section C: Definitions
Q1
thrashing — When RAM is full, the computer keeps swapping pages to slow secondary storage, so it becomes sluggish. Adding more RAM reduces swapping. Virtual memory is no replacement for RAM.
Section D: Fill in the Blanks
Q1
IF ramFull THEN swapPages() ENDIF
Q2
IF swapsPerSecond > 100 THEN sluggish = TRUE ENDIF
Q3
ramSize = ramSize + 8 swapping = swapping - 1
Q4
IF virtualSpeed < ramSpeed THEN OUTPUT "Not a RAM replacement" ENDIF
Q5
state = thrashing OUTPUT "Computer is sluggish"
Section E: Spot the Error
Q1
C — Virtual memory is space on secondary storage (the drive), not inside RAM. This is why swapping pages is slower than using RAM.
Q2
B — Heavy swapping makes the computer feel sluggish, not quick. The computer keeps waiting for slow secondary storage.
Q3
C — A high number of swapped pages means thrashing, so the computer is slow. The output should say 'Computer is slow'.
Q4
D — Virtual memory is on secondary storage, which is much slower than RAM. It should say VM is slower than RAM.
Q5
B — Thrashing happens when RAM is full. If RAM stayed almost empty there would be no need to swap pages. It should say RAM fills up quickly.