Homework 4

22C:116, Spring 2002

Due Monday Feb 18, 2002, in class

Douglas W. Jones

Assume the usual general instructions!

  1. Background: Look at the user-level thread package found in:
    http://homepage.cs.uiowa.edu/~dwjones/opsys/threads/
    The UNIX setitimer(ITIMER_REAL) kernel call sets the current process's programmable interval timer, and the UNIX getitimer(ITIMER_REAL) kernel call inspects it. When the timer expires, the kernel delivers a SIGALRM signal to the process. The sigaction(SIGALRM) kernel call (or the older sigvec(SIGALRM) interface) allow a process to override the default handler for this signal.

    There are two ways the kernel could call a signal handler. One way would be for the handler to be called using the stack that was currently in use by the process. The other way is to reserve a small secondary stack that is used only by signal handlers, so that the handlers don't push or pop anything on the stack of whatever function is currently executing. In the UNIX system, this is done using the sigaltstack() (or the older sigstack()) kernel call.

    Part A: If you wanted to make the example thread manager do preemptive context switching between user threads, using the processes interval timer to define the thread manager's time slice, and using a SIGALRM handler to do the context switching, should the signal handler be called on the current thread's own stack, or should it be called on a secondary stack reserved for signal handlers?

    Part B: Propose the code for the SIGALRM handler for a preemptive thread manager.

  2. Problems from the Text:
    Do problem 4 on page 263.
    Do problem 17 on page 265.
    Do problem 29 on page 266
    Do problem 31 on page 266
    Do problem 35 on page 267
    Do problem 38 on page 267