
ECE391: Computer Systems Engineering Fall 2007
Study Guide
Sample Questions for the Second Midterm
This guide contains example questions to help you study for the coming midterm. As was the case with the previous
guide, most of these questions are short answer, whereas the test will include a larger portion of questions that require
some code or analysis of code. The questions here are also not as carefully designed for clarity, in part so as to
encourage you to think about different angles. On tests, we try to make our questions more precise.
You may bring two 8.5x11” sheets (both sides) of handwritten notes to the test. No other materials are allowed. No
calculators or other electronic devices are allowed.
Topics emphasized in exam 2: Virtual Memory, Interrupts, and System Calls
1. Explain how a virtual address is translated to a physical address using a two-level page table hierarchy. Count the
number of memory accesses involved.
2. How does use of virtual memory prevent a malicious program from contaminating or destroying another program’s
memory?
3. Give an example of how memory fragmentation can negatively impact a system without virtual memory.
4. How does the Linux kernel track the number of uses of a file structure, memory map, or other structure shared
between multiple tasks? Why does it do so?
5. Explain the advantages and disadvantages of using a 4-MB page size rather than a 4-kB page size to support paging.
6. Virtual memory is useful for protection, sharing, avoiding fragmentation, and avoiding code and data relocation.
Compare the effectiveness of segmentation with that of virtual memory for these four goals.
7. Explain the advantages of abstracting a memory map as a set of contiguous regions rather than relying directly
on the page tables for descriptive information. Hint: don’t forget one the original goals of using virtual memory, in
addition to any other advantages.
8. Explain the tradeoffs between handling translation lookaside buffer (TLB) misses in hardware and handling them
in software (via an exception mechanism).
9. Why are I/O ports protected using a processor’s hardware privilege level support?
10. Explain the purpose and benefits of stack swapping. What additional support is necessary for tracking stack
pointers when more than one program is allowed to exist at a time?
11. Memory allocation systems that use exponentially-sized bins (e.g., powers of two) rather than fitting memory
exactly to the requested size waste space by returning more memory than is necessary. Extra memory returned in this
manner is then waste space. Calculate the minimum and maximum amount of memory wasted in terms of the total
memory requested from such a system, given power-of-two bin sizes. Next, make reasonable assumptions about the
distribution of requested sizes and calculate the expected waste space (again in terms of the requested space).
12. In the MP2 code, the maze game provides a virtual world of maze pixels, and the mode X code maps that world
into mode X planes before storing the pixels to be displayed in the build buffer. As a result, planes in the build buffer
must be remapped into the VGA planes when displaying a new screen. Consider two alternatives. First, one might
instead draw a graphical image in a form convenient to C in the build buffer, then map to planes when copying to
video memory. Second, one might map the window being displayed (a sub-portion of the virtual world provided by
the maze) into logical planes, allowing the mapping to video memory to occur without plane-to-plane remapping.
Explain why neither alternative is attractive.
13. Using the game controller from MP2 as an example, give two reasons for performing port I/O in the context of a
device driver rather than allowing applications to access the device’s ports directly.
14. How does software disablement of hard interrupts work in Linux? Also comment on how happens if the system’s