Midterm Study Questions

22C:116, Spring 1999

Douglas W. Jones

  1. Consider the problem of passing parameters to a system call. Simple parameters can be passed in a register, but for this problem, the emphasis is on parameters that must be passed in memory such as arrays, I/O buffers or complex records.

    Broadly speaking, the gate crossing mechanisms for system calls may be divided into three categories, each of which presents different problems for parameter passing. For each of these broad categories, there are two issues the kernel must address when it receives a pointer from the user: How does the kernel determine if the pointer is valid -- that is, does the pointer point to an object the user is entitled to manipulate, and how does the kernel access the object referenced by the pointer?

    First, there are systems like the Hawk where the memory management unit is turned off whenever a system call takes place, so user programs run in virtual memory, while kernel code runs in real memory.

    Second, there are systems like Multics, where the kernel and user program share an address space (it was a virtual address space in Multics, but this the problem is the same if it is not virtual).

    Third, there are systems where the user operates in one virtual address space and the kernel operates in another. In such a system, a kernel call can be viewed as switching from one page table to another.

  2. Consider the problem of writing a disk I/O driver on a machine with two or more disks attached to a common DMA controller. Each disk controller contains registers to control the cylinder and surface being addressed by that disk, but the shared DMA controller has only one buffer-address register and one word-count register. When the DMA controller finishes a transfer, it gives an interrupt to a single service routine, so that service routine must handle interrupts for all disks.

    Write pseudocode for a disk interrupt service routine for this system, and then modify it to support a decent disk scheduling algorithm.

  3. The posted solution to problem 2 on homework 3 (see http://homepage.cs.uiowa.edu/~dwjones/opsys/hw/03sol.html) has a significant shortcoming. It organizes the page table as a single run of 220 pages, and it does not allow for multiple page tables, one per user process, for example.

    How would you change the data structures detailed in part A if the page table were divided into segments, where each segment of the page table can be stored either in a page frame or on disk. Assume, for the moment, that there is only one address space.

    How would you change the data structures detailed in part A to allow multiple coexisting address spaces, perhaps one per process, so that the pages occupying the page frames in main memory could, at times, belong to different address spaces.

  4. Consider the problem of memory allocation for a UNIX-like operating system on the Hawk machine, where virtual memory is used as in problem 2 of homework 3, with one address space per user process. When a user program calls malloc() (assuming C) or new (assuming Pascal) or creates a new object (perhaps in C++), a heap manager is called. When the operating system kernel opens a file, it must allocate an open-file description record somewhere, so it calls a heap manager.

    What is the relationship, if any, between the heap manager used to allocate space for user applications and the heap manager user to allocate space for kernel data structures? Do these heap managers have any necessary relationship to the paged virtual memory addressing structure of the machine?

    Does the mechanism for allocating page frames or pages to virtual address spaces have any necessary relationship to these heap managers?