Homework 6

22C:116, Fall 1998

Due Monday Oct 5, 1998, in class

Douglas W. Jones
  1. Use the UNIX SIGALRM signal to implement a timer service under our thread manager. Users of the thread package would call at(t,s) to schedule a call to signal(s) at time t, where signal is the operation on semaphores you have implemented.

    Do not try to make the scheduler preemptive.

    Test your program with a pair of application threads based on the following pseudocode:

       thread1: semaphore d is initially 0
                repeat
                   at( now + 10 seconds, d )
                   wait( d )
                   output control g to standard error
                   relinquish
                forever
    
       thread2: repeat
                   relinquish
                   read a line of input from standard input
                   relinquish
                   echo the line to standard output
                forever
    
    Use the standard C library I/O routines. Do not try to fix any anomolous behavior of the result

  2. Explain, with reference to the man pages for any kernel calls involved, any anomolous behavior you observe in the result!

  3. Do problem 4 on page 202 in Tannenbaum. You might want to study the UNIX mv shell command and compare this with the UNIX cp shell command before you answer this.

  4. Do problem 7 on page 202 in Tannenbaum!

  5. Do problem 8 on page 202 in Tannenbaum!

  6. Do problem 14 on page 203 in Tannenbaum! Assume that we have a disk scheduler in our disk I/O subsystem, and assume that we are dealing with a file server for a large department and not a single user machine.