CSE 451

Introduction to Operating Systems

Spring 1999



Problem Set #2

Due: In class or via email, Wednesday April 21, 10:20 am

1. Let 9 processes, p1 to p9, have the following precedence constraints. Initially,  only p1 and p2 start. p3 and p4 start only after both p1 and p2 finish. p5, p6, and p7 start only when p4 finishes. p8 starts only after p3 and p5 finish. The last process, p9, starts only when p6, p7, and p8 finish. Show how these constraints can be implemented using semaphores. Appropriate wait (P) and signal (V) operations should be inserted at the beginning and end of the code for each process.
 

2. Consider the bounded buffer solution given in class and in the text (Section 6.5.1). What are the effects of the following changes to the producer  and consumer processes (Figures 6.12 1nd 6.13) on correctness or scheduling?  Interchange wait(empty) and wait(mutex) in the producer and wait(full) and wait(mutex) in the consumer.
 

3. Let a bounded semaphore s be a general counting semaphore that cannot exceed a given integer value smax > 0. The corresponding wait (P) and signal (V) operations are defined as

 wait(s):   < await s > 0 ? s := s - 1 >
 signal(s):   < await s < smax ? s := s + 1 > .

Write a Hoare monitor that implements bounded semaphores.



cse451-webmaster@cs.washington.edu