Tutorial Week 5


  1. For each of the following scenarios, one or more dining philosophers are going hungry. What is the condition the philosophers are suffering from?

    1. Each philosopher at the table has picked up his left fork, and is waiting for his right fork
    2. Only one philosopher is allowed to eat at a time. When more than one philosophy is hungry, the youngest one goes first. The oldest philosopher never gets to eat.
    3. Each philosopher, after picking up his left fork, puts it back down if he can't immediately pick up the right fork to give others a chance to eat. No philosopher is managing to eat despite lots of left fork activity.

  2. What is starvation, give an example?

  3. Two processes are attempting to read independent blocks from a disk, which involves issuing a seek command and a read command. Each process is interrupted by the other in between its seek and read. When a process discovers the other process has moved the disk head, it re-issues the original seek to re-position the head for itself, which is again interrupted prior to the read. This alternate seeking continues indefinitely, with neither process able to read their data from disk. Is this deadlock, starvation, or livelock? How would you change the system to prevent the problem?

  4. Describe four ways to prevent deadlock by attacking the conditions required for deadlock.

  5. Answer the following questions about the tables.

    1. Compute what each process still might request and display in the columns labeled "still needs".
    2. Is the system in a safe or unsafe state? Why?
    3. Is the system deadlocked? Why or why not?
    4. Which processes, if any, are or may become deadlocked?
    5. Assume a request from p3 arrives for (0,1,0,0)
      1. Can the request be safely granted immediately?
      2. In what state (deadlocked, safe, unsafe) would immediately granting the request leave the system?
      3. Which processes, if any, are or may become deadlocked if the request is granted immediately?
    r1 r2 r3 r4
    2 1 0 0
    current allocation maximum demand       still needs    
    process r1 r2 r3 r4 r1 r2 r3 r4 r1 r2 r3 r4
    p1 0 0 1 2 0 0 1 2
    p2 2 0 0 0 2 7 5 0
    p3 0 0 3 4 6 6 5 6
    p4 2 3 5 4 4 3 5 6
    p5 0 3 3 2 0 6 5 2