CMPT-300 02-01 E2
Model Answer for Assignment 3
We have discussed some issues about memory management. This assignment
is about principles of memory management and their applications.
Question 1 (5 points)
Consider a computer system with enough main memory to hold 5 programs. If
these programs wait for I/O 50% of the time, then, on average, what fraction of
CPU time is wasted? What degree of multiprogramming is necessary to achieve
at least 99% CPU utilization?
Answer
According to the formula on page 193, if p=0.5, then the chance that all five
processes are idle is 1/32. At least 7 processes are needed to achieve at least
99% CPU utilization.
Question 2 (5 points)
Consider a swapping system in which main memory contains the following hole-
sizes in memory order: 10K, 4K, 20K, 18K, 7K, 9K, 12K, and 15K. Which hole is
taken for successive segment requests of (a) 12K, (b) 10K and (c) 9K for First-
Fit? Repeat this exercise for Best-Fit, Worst-Fit, and Next-Fit.
Answer
• First-Fit takes 20K, 10K, and 18K.
• Best-Fit takes 12K, 10K, and 9K.
• Worst-Fit takes 20K, 18K, and 15K.
• Next-Fit takes 20K, 18K, and 9K.
Question 3 (5 points)
Contiguous allocation of files leads to disk fragmentation. What type of
fragmentation is this? Please answer this question by making an analogy with
something discussed in Memory Management.
Answer
Since the wasted storage is between the allocation units (files), and not inside
them, this is clearly external fragmentation. It is precisely analogous to the
external fragmentation of main memory that occurs with a swapping system or a
system using pure segmentation.
Question 4 (5 points)
Modern CPUs have instruction and data caches that keep the most recent
memory accesses. In virtual memory systems these caches are indexed by
virtual address. In such a machine, during a process (context) switch, the
operation system has to flush the CPU caches. Why?
Answer
If the caches are not cleared when a context switch occurs, the newly scheduled
process will be able to see data from the old process, and may even erroneously
execute instructions from that process.