UNIVERSITY OF WISCONSIN-MADISON
Computer Sciences Department
CS 537
Spring 2000
A. Arpaci-Dusseau
Quiz #4: Wednesday, March 8

Name: Student ID #:

Deadlock and CPU Scheduling

Problem 1: Deadlock (40 points)

Resource allocation graph

a) Consider the resource-allocation graph shown above. Show a sequence of lock.acquire() instructions performed by processes P1, P2, and P3 for locks R1, R2, and R3 that would lead to the state depicted in the resource-allocation graph. If there is more than one possible ordering for two or more acquire instructions, then do not place any artificial contraints on their ordering (i.e. show those instructions could run in a different order by placing them on the same line).














b) Assume that these resources require mutual exclusion, that each process holds onto its current resource until it can acquire the next resource, and that resources cannot be preempted. Does deadlock exist in this system depicted by the resource-allocation graph? If not, explain why not. If so, list all possible processes that could be killed to remove the deadlock.



Problem 2: General Scheduling (30 points)

a) Consider a workload with 5 jobs that each compute for an identical amount of time, x, and that perform no I/O. To minimize the average waiting time of the jobs, should a FCFS scheduler or a RR scheduler be used?





b) Assume that job A is running on the CPU. Describe two circumstances in which a SJF scheduler will keep job A running, but a STCF scheduler will pick a different job.