程序代写代做代考 algorithm cache C502 – Memory Management Quiz

C502 – Memory Management Quiz

Quiz Solutions

Note: The solution notes below only briefly list (some of) the key points that should be included in an
answer. They are by no means complete. In an exam, you are expected to spell out the solution more fully
and include a detailed explanation of your reasoning.

1. Where is the ‘swap space’ located?

(a) Designated area in memory

(b) CPU Cache

(c) Hard disk

Answer: (c) Hard disk – ‘swap space’ is a dedicated area of disk where memory data can be swapped
out into and later swapped back into memory, as necessary.

2. Consider a 16-bit Virtual memory address and a page size of 8 KB. How many pages can a process
potentially have?

(a) 8

(b) 2

(c) 10

(d) 4

Answer: (a) 8. A page size of 8 KB will have 8×1024 addressable bytes, which is 213 and in order to
address these bytes we would need 13 bits. The remaining bits are used for the page number and hence
we potentially have 23 = 8 pages.

Can also calculate as: number of virtual addresses
page size

= 2
16

213

3. What causes a page fault?

(a) The page is not available on disk

(b) The page is faulty

(c) The page is not available in memory

(d) The page is dirty

(e) The page shouldn’t be accessed

Answer: (c) The page is not available in memory. A page fault is caused when there is an invalid-bit
in the page table is set to 0, which indicates that the requested page is not in memory and must hence
be brought into memory.

4. Increasing the RAM size usually helps with performance. Why?

(a) Increase in virtual memory

(b) Faster physical memory

(c) Not as many segmentation faults

(d) Reduced Thrashing

(e) Fewer memory leaks

Answer: (d) Reduced Thrashing. Increasing RAM indicates that we are increasing the physical memory
and not necessarily the virtual memory since virtual memory is independent of the physical memory
and depends on the address size. Increasing RAM doesn’t necessarily lead to a faster memory as that
has to do with the hardware of the RAM. Increasing RAM would allow us to allocate more frames
to processes which in turn would lead to fewer page faults (reduced thrashing) and hence an overall
improvement gain.

5. Assume 3 memory frames and a reference string of 1, 2, 3, 6, 2, 1, 5, 3, 2, 4, 6. How many page faults
do you get when using the Optimal Algorithm?

(a) 4

(b) 5

(c) 6

(d) 7

(e) 8

Answer: (d) 7.

Reference string

1 2 3 6 2 1 5 3 2 4 6

1 1 1 1 5 3 4

2 2 2 2 2 2

3 6 6 6 6

2