UNIVERSITY OF WISCONSIN-MADISON
Computer Sciences Department | ||
CS 537
Fall 2007 | A. Arpaci-Dusseau | |
Sample Quiz #7 -- Deadlock and Scheduling |
a. Mutual exclusion b. Hold and wait c. No preemption d. Circular wait _____ Impose a total ordering (or ranking) on how resources are acquired _____ When a process requests a resource that is already held, force the process holding the resource to release it _____ Only allow a process to request a resource when the process has none _____ Allow all processes to access the resource simultaneously _____ Require each process to grab all desired resources at once
Can running each of the following code segments lead to deadlock of process 0 and process 1? Simply answer "yes" or "no".
Code Sample 1 Process 0: Process 1: lock1.acquire(); lock1.acquire(); lock2.acquire(); lock2.acquire(); lock1.release(); lock1.release(); lock2.release(); lock2.release(); |
Code Sample 2 Process 0: Process 1: lock1.acquire(); lock2.acquire(); lock2.acquire(); lock1.acquire(); lock1.release(); lock1.release(); lock2.release(); lock2.release(); |
Code Sample 3 Process 0: Process 1: lock1.acquire(); lock2.acquire(); lock2.acquire(); lock2.release(); lock1.release(); lock1.acquire(); lock2.release(); lock1.release(); |
Running which of the above code samples could lead to the situation shown in the following resource-allocation graph? Indicate all of the possible code samples that apply.
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.
a) Consider a process that is at priority 49.
c) Consider a new workload containing a single process; this process repeatedly computes for 20ms and then sleeps for 1000ms. Draw a timeline showing the priority of this process for 3 iterations of its compute/sleep cycle. You can assume that the 1 second update timer begins its cycle at the same time the process enters the system (i.e., the timer expires 1 second after the process begins executing).