Homework 3

22C:116, Spring 2002

Due Monday Feb 11, 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/
    Familiarize yourself with this package, and if you have a machine that can run C or C++, try downloading it and running some of the test programs that come with the package. The questions here do not, however, require that you run any code.

    Part A: Consider writing a program that contains multiple processes all running the same code. Each process can have local variables on its stack, but you need some place to put the static data of the process. Explain how to use the (rather poor quality) tool provided by the thread manager for solving this problemr. (I count this solution as an excellent example of a kluge.

    Part B: Look at the C code for the thread manager, specifically at the code to for the thread_launch function. Give a very short description of the key items that must be done to launch a new thread.

    Part C: Compare the implementation of the thread_wait operation with the generic description of how the wait operation on a semaphore is implemented, for example, in the notes for lecture 5, and explain the reasons for the significant differences. (I can think of at least 2, the reasons for which are very different.)

  2. Problems from the Text: Do problems 12 and 20 on page 154.

    Do problem 27 on page 155.