Documente Academic
Documente Profesional
Documente Cultură
Deadlock in Intersections
Consider gridlock in four one-way streets
R1 P2
R2
P3
8
R1
P2
P3 R2
The default weight for a request is 1. Process P1 needs 2 units simultaneously. One unit of R1 is available, but is of no value to P1. Although resource ordering would prevent this deadlock, it would not prevent all such resource deadlocks. For example, if all processes need 2 more units of R1 and P2 and P3 already have one unit, deadlock occurs.
Cars cannot move into an intersection unless the following space is empty. Do Not Block the Box. If the requested resource is not available, the waiting process releases all held resources.
Can try later, but again unbounded waits are possible. Heuristic if you are waiting too long, do a hard reboot
11
Recovery may be possible by reverting to a point before deadlock occurred and hoping that deadlock does not recur. Else choose a victim (this is a heuristic), kill it, and restart it after a pause.
May involve serious loss of work and other overhead.
14
e) An infinite waiting state containing a nonempty set of processes in a circular chain, such that each process is holding a non-shareable, nonpreemptable (unique) resource while waiting for a resource held by the next process in the chain. [1] f) An infinite waiting state containing a chain of processes, such that each process is waiting for one or more non-shareable, non-preemptable resources, of which a required number of units are held by other process(es) in the chain.
15
Deadlock examples
Holt [5] provides an example of a single process in deadlock: process Revenge is suspended waiting for an event that never occurs. Nutt [9] states that a kernel process is in deadlock if it is permanently blocked waiting for a resource that will never become available. No circular wait is specified. In accordance with the Halting Problem, these types of dead state are impossible, in general, to prevent.
16
Deadlock example
producer() { int item; while (TRUE) { produce_item (&item); /* If no slot is empty when down (mutex) is executed */ down (mutex); /* producer() holds the soft resource, mutex, and then */ down (empty); /* blocks on empty. producer() waits for consumer to signal that empty is available*/ enter_item (item); up (mutex); up (full); } } consumer () { int item; while (TRUE) { down (full); down (mutex); /* consumer() blocks, since mutex is locked by producer and cannot execute up (empty),*/ /* a cooperation mechanism. Note that consumer() is not holding empty. */ remove_item (&item); up (mutex); up (empty); consume_item (item); } } /* example from A. Tanenbaum [14. comments are mine*/
17
Deadlock Examples
Silberschatz et al. [11] claim that a deadlock exists if two trains on different tracks approach an intersection and wait for the other to proceed. Stallings [12] gives an example of four cars at different stop signs approaching an intersection, where each gives precedence to the car on its right. No cars or trains are holding resources requested by others.
18
Deadlock examples
Davis and Rajkumar [2] and Flynn and McHoes [4], cite a deadlock example of two programs issuing a seek command to reposition the access mechanism. Each is interrupted before executing its read command. When it then attempts to read it discovers that the other has moved the disk arm. Each then reissues the seek command in turn, but is again interrupted by the other. This sequence continually repeats. Processes are not blocked from resources, which are, indeed, repeatedly preempted.
19
Unacceptable waits
infinite waiting states (definition a)
Communication deadlocks Scheduling deadlocks Interleaved deadlocks Resource deadlock is a subset of this anomaly
Circular chain of processes each waiting for resources held by next/ other processes in the chain (definitions e and f)
20
Communication deadlock
Infinite circular waits with cooperation errors
These circular waits involve at least two synchronous processes.
Examples: Tanenbaums producer/consumer [14], Holt [5] two processes that each request a resource of the other before the other has created it.
Communication deadlock cannot be prevented by pre-allocation of resources, resource ordering, safe states. Can be detected by circular wait, buy restart can not affect recovery.
22
Scheduling deadlocks
Infinite circular waits involving incomplete/incorrect competition mechanisms
Ex: 4 cars at the corners of an intersection with stop signs at each corner [12]; trains at intersection in [11]
Processes do not wait for resources held by others. Scheduling deadlock cannot be prevented by making resources preemptable or denying hold and wait precondition. (requested resource is available) Can be detected by circular wait. Although restart will probably affect recovery, more efficient recovery involves changing some rule temporarily without necessitating backup or repeat of service.
23
Interleaved deadlock
Resource deadlock is a subset of interleaved deadlock. Competing processes are asynchronous.
If resources are unique, a circular chain of processes holding resources is sufficient to define the deadlock If resources are interchangeable, all processes in the chain are waiting for resource unit(s) held by other processes in the set.
24
Linear orders and resource preemption will not prevent these dead states, but resource preallocation will.
27
If process does not complete service within its time constraint, it is dead and has an infinite wait
29
Scheduling deadlock can be corrected in resource service layer (no loss of service)
dynamically change scheduling rules, priorities, etc.
Resource deadlock can be corrected in resource buffer layer by restarting one or more processes
Requires backups in the resource buffer layer
References
[1]]
E.G. Coffman, M. J. Elphick, and A. Shoshani, System Deadlocks, ACM Computing Surveys, vol. 3 , no. 2, pp. 67-78, June 1971. [2] W.S. Davis and T. M. Rajkumar, Operating Systems, A Systematic View, 5th ed., Addison-Wesley, Reading, Mass., p. 123, 2001. [3] E. W. Dijkstra, Cooperating Sequential Processes, Programming Languages, Academic Press, London, 1965. [4] I. M. Flynn and A. M. McHoes, Understanding Operating Systems, Brooks/Cole, Australia, pp. 109-110, 2001. [5] R.C. Holt, Some Deadlock Properties of Computer Systems, ACM Computing Surveys, vol. 4, no. 3, pp. 179-196, Sept. 1972. [6] D. Horner, Operating Systems, Concept and Applications, Scott, Foresman and Co. Glenville, Ill., pp.160, 105, 182, 1989. [7] W. S. Lai, Protocol Traps in Computer Networks- a Catalog. IEEE Transactions on Communications, Com-30, no. 6, pp. 1434 -1448, June 1982. [8] J.C. Mogul and K. K. Ramakrishnan, Eliminating Receive Livelock in an Interrupt-driven Kernel, ACM Trans. on Computer Systems, vol.15, no.3, pp. 217-252, Aug. 1997. [9] G. Nutt, Operating Systems, a Modern Perspective, 2nd edition, Addison-Wesley, Reading, Mass., pp.150, 279, 2000. [10] D. J. Rosenkrantz, R. E., Stearns, and P. M. Lewis, System Level Concurrency Control for Distributed Database Systems, ACM Trans. on Database Systems, vol.3, no.2, pp.178-198, June 1978. [11] A. Silberschatz, P. B. Galvin, and G. Gagne, Operating Systems Concepts, 6th edition, Addison-Wesley, Reading, Mass., pp. 204, 243, 244, 266, 2002. [12] W. Stallings, Operating Systems, Internals and Design Principles, 3rd edition, Prentice Hall, Englewood Hills, NJ, pp. 254, 1998. [13] A. Tanenbaum, Computer Networks, 4th edition, Prentice Hall, Upper Saddler River, NJ. 2003. [14) A. Tanenbaum, Operating Systems, Design and Implementation, 2nd edition, Prentice Hall, Upper Saddle River, NJ, pp. 6769, 1997. [15] D. Tsichritzis, and F. Lochovsky, Data Base Management Systems, Academic Press, London, p. 260, 1977. [16] R. J. Van Glabbeek, Notes on the Methodology of CCS and CSP, Theoretical Computer Science, pp. 329 - 349, 1997.
32