OS function: managing memory

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

OS function: managing memory

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which part of the computer does the OS decide how to share between running programs when it manages memory?
A ROM
B RAM
2. A student opens a web browser and a music player at the same time. What does the OS do with RAM?
A Allocates a separate part of RAM to each program
B Gives all of the RAM to the browser only
3. Why does the OS keep each program's memory separate?
A So one program cannot overwrite another program's data
B So programs can edit each other's data more easily
4. A student closes a game. What should the OS do with the RAM the game was using?
A Keep it reserved for the game forever
B Free it so other programs can use it
5. Which statement is true about memory management?
A It is a function of the operating system
B It is done by the keyboard

Match the Pairs

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

Left columnRight column
1memory management AON program.close: free(program.block)
2allocate(browser, 512MB) BThe OS has not kept the programs' memory separate. Each program must get its own block so they do not overlap.
3The OS keeps each program's memory separate so one program cannot overwrite another program's data CThe OS decides which part of RAM each running program uses, keeps programs apart and frees the space when a program closes
4When a program closes, the OS frees its RAM so other programs can use the space DThe OS has not freed the memory when the program ended. It should release the RAM so it can be reused.
5Two programs are both given RAM addresses 100 to 200 and can overwrite each other's data EThe OS gives the browser its own block of RAM to use while it runs
6A game is closed but the OS keeps its RAM reserved, so free RAM slowly runs out FIF address NOT IN program.block THEN DENY

Definitions

memory management

Fill in the Blanks

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

1.
block ← ________(browser)
2.
IF closed = TRUE THEN ____(block)
3.
IF address < start __ address > end THEN DENY()
4.
IF freeRam _ size THEN WAIT()
5.
block ← allocate(editor) RUN(editor, block) free(_____)

Spot the Error

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

Question 1
A PROGRAM game STARTS
B OS finds free space in RAM
C OS gives game its own block
D game can write to any block
Question 2
A user opens a web browser
B OS allocates ROM to browser
C browser is given its own area
Question 3
A IF program starts THEN
B OS frees its RAM space
C ELSE keep the RAM reserved
D ENDIF
Question 4
A A and B are both running
B OS gives each the same block
C A cannot overwrite B's data
Question 5
A RAM is full
B user opens one more program
C OS gives it unlimited RAM
D computer slows or shows error

Answer Key

OS function: managing memory
Section A: Quick Questions
Q1
B — RAM
Q2
A — Allocates a separate part of RAM to each program
Q3
A — So one program cannot overwrite another program's data
Q4
B — Free it so other programs can use it
Q5
A — It is a function of the operating system
Section B: Match the Pairs
Q1
memory management → The OS decides which part of RAM each running program uses, keeps programs apart and frees the space when a program closes
Q2
allocate(browser, 512MB) → The OS gives the browser its own block of RAM to use while it runs
Q3
The OS keeps each program's memory separate so one program cannot overwrite another program's data → IF address NOT IN program.block THEN DENY
Q4
When a program closes, the OS frees its RAM so other programs can use the space → ON program.close: free(program.block)
Q5
Two programs are both given RAM addresses 100 to 200 and can overwrite each other's data → The OS has not kept the programs' memory separate. Each program must get its own block so they do not overlap.
Q6
A game is closed but the OS keeps its RAM reserved, so free RAM slowly runs out → The OS has not freed the memory when the program ended. It should release the RAM so it can be reused.
Section C: Definitions
Q1
memory management — The OS decides which part of RAM each running program uses, keeps programs from overwriting each other's memory, and frees the space when a program closes.
Section D: Fill in the Blanks
Q1
block ← allocate(browser)
Q2
IF closed = TRUE THEN free(block)
Q3
IF address < start OR address > end THEN DENY()
Q4
IF freeRam < size THEN WAIT()
Q5
block ← allocate(editor) RUN(editor, block) free(block)
Section E: Spot the Error
Q1
D — The OS keeps each program's memory separate, so the game can only use the block it was given. It must not write to any block. The line should read: game uses only its own block.
Q2
B — The OS allocates RAM to running programs, not ROM. ROM is read-only and holds firmware, so the line should say RAM.
Q3
A — The OS frees RAM when a program closes, not when it starts. The condition should be: IF program closes THEN.
Q4
B — If two programs shared one block, they could overwrite each other's data. The OS must give each program its own separate block.
Q5
C — RAM is limited and cannot grow by itself. When it is full the OS cannot allocate enough RAM, so the computer slows down or reports an error. The line should be: OS cannot give it enough RAM.