Homework #2


1. List three examples of deadlock that are not related to a computer system environment. (10 points)

2. Is it possible to have a deadlock involving a single process? Explain. (10 points)

3. Consider the traffic deadlock depicted below.

          | | |          |   |
      ____| V |__________|   |_____
            | <- <- <- <- <- <- <-    31st Street
      ----| V |----------| ^ |-----
          | | |          | | |
          | V |          | ^ |
          | | |          | | |
     _____| V |__________| ^ |_____
     ->->->->->->->->->->->|          33rd Street
     -----|   |----------| ^ |-----
          |   |          | | |
         State Street   Michigan Ave.

a) Show that the four necessary conditions for deadlock hold in this example. (10 points)
b) State a rule that would avoid deadlocks in this system. (10 points)

4. Consider a system consisting of four resources of the same type that are shared by three processes, each of which needs at most two resources. Is the system deadlock free or not? Prove your answer. (10 points)

5. Consider a computer system that runs 5000 jobs per month with no deadlock-prevention or deadlock-avoidance scheme. Deadlock occur about twice a month, and the operator must terminate and rerun about ten jobs per deadlock.. Each job is worth about $2 and the jobs tend to be about half-done when they are aborted. A systems programmer has estimated that a deadlock-avoidance algorithm could be installed in the system with an increase in the average execution time per job of 10%. Since the system currently has 30% idle time, all 5000 jobs per month could still be run, although the turnaround time would increase by about 20% on the average.

a) What are the arguments for installing the deadlock-prevention algorithm? (10 points)
b) What are the arguments against installing the deadlock-prevention algorithm? (10 points)

6. Consider the following snapshot of system:

         A B C D      A B C D
    ---|----------------------
    P0 | 0 0 1 2      0 0 1 2           A= (1, 5, 2, 0)
    P1 | 1 0 0 0      1 7 5 0
    P2 | 1 3 5 4      2 3 5 6
    P3 | 0 6 3 2      0 6 5 2
    P4 | 0 0 1 4      0 6 5 6
    ---|----------------------
         Assigned     Needed
a) Is the system in a safe state? (10 points)
b) If a request from process P1 arrives for (0,4,2,0), can the request be granted immediately? (10 points)

7. Problem 14, page 263 in the textbook. (10 points)


Maximum mark: 100 points (100%)