Assignment 2, due Sept 6

Part of the homework for 22C:116, fall 2002
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

  1. Background: There is a user-level thread package written in C and callable from C or C++ programs on-line at:
    http://homepage.cs.uiowa.edu/~dwjones/opsys/threads/
    This thread package contains many features typical of the process manager of an operating system, except that they operate at the user level and are coded in machine independent form.

    Advance Warning: You will have to add features to this thread package in next week's assignment. The code you will need to write is small, but time spent studying the thread package this week will be important preparation for next week's assignment.

    Part A: What changes to the the external interface to the thread package (not the source code) would be required in order to allow code running in one thread to force the termination of another thread (the thread_kill operator)? These changes will, if implemented, result in changes and additions to the header file of the package. For this week, focus on describing the nature of the change to the specification.

    Part B: If a running thread forces the termination of some other thread, this implies that the thread being killed must be either ready or waiting. What decisions made in designing the internal data structures of the thread manager, as it is currently written, make the kill operation difficult to implement. What changes would you suggest to simplify the kill operation?

    Part C: In examining the source code and header files for the thread package, note that the header file threads.h is not included by the implementation threads.c, and furthermore, some of the declarations in threads.h do not match the corresponding declarations in threads.c. These oddities are deliberate, and taken together, they accomplish something very useful. Explain this!

  2. A Problem: It is common practice to speak of operating systems having a process table. The thread package discussed above has no such table, but instead, maintains dynamically linked lists of processes. Discuss the factors that might force an operating system designer to move to using process tables instead of free-form lists as in the thread package.

  3. A Problem: Do problem 14 on page 68 of the text.