Share on Facebook Share on Twitter Email
Answers.com

deadlock

 
Dictionary: dead·lock   (dĕd'lŏk') pronunciation
n.
  1. A standstill resulting from the opposition of two unrelenting forces or factions.
  2. Sports. A tied score.
  3. Computer Science. A failure or inability to proceed due to two programs or devices both requiring a response from the other before completing an operation.
tr. & intr.v., -locked, -lock·ing, -locks.
To bring or come to a deadlock.


Search unanswered questions...
Enter a question here...
Search: All sources Community Q&A Reference topics
Computer Desktop Encyclopedia: deadly embrace
Top

A stalemate that occurs when two elements in a process are each waiting for the other to respond. For example, in a network, if one user is working on file A and needs file B to continue, but another user is working on file B and needs file A to continue, each one waits for the other. Both are temporarily locked out. The software must be able to deal with this. Contrast with livelock.

Download Computer Desktop Encyclopedia to your iPhone/iTouch

Thesaurus: deadlock
Top

noun

    An equality of scores, votes, or performances in a contest: dead heat, draw, stalemate, standoff, tie. See same/different/compare.

Antonyms: deadlock
Top

n

Definition: stalemate, impasse
Antonyms: agreement, breakthrough


Hacker Slang: deadlock
Top

1. [techspeak] A situation wherein two or more processes are unable to proceed because each is waiting for one of the others to do something. A common example is a program communicating to a server, which may find itself waiting for output from the server before sending anything more to it, while the server is similarly waiting for more input from the controlling program before outputting anything. (It is reported that this particular flavor of deadlock is sometimes called a starvation deadlock, though the term starvation is more properly used for situations where a program can never run simply because it never gets high enough priority. Another common flavor is constipation, in which each process is trying to send stuff to the other but all buffers are full because nobody is reading anything.) See deadly embrace.

2. Also used of deadlock-like interactions between humans, as when two people meet in a narrow corridor, and each tries to be polite by moving aside to let the other pass, but they end up swaying from side to side without making any progress because they always move the same way at the same time.


Architecture: deadlock
Top


1. A lock equipped with a dead bolt only.
2. A lock in which a bolt is moved by means of a key or thumb turn, and is positively stopped in its projected position.


Wikipedia: Deadlock
Top

A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does. It is often seen in a paradox like the "chicken or the egg."

When two trains approach each other at a crossing, both shall come to a full stop and neither shall start up again until the other has gone.
 
— Illogical statute passed by the Kansas Legislature[1]

In computer science, deadlock refers to a specific condition when two or more processes are each waiting for each other to release a resource, or more than two processes are waiting for resources in a circular chain (see Necessary conditions). Deadlock is a common problem in multiprocessing where many processes share a specific type of mutually exclusive resource known as a software lock or soft lock. Computers intended for the time-sharing and/or real-time markets are often equipped with a hardware lock (or hard lock) which guarantees exclusive access to processes, forcing serialized access. Deadlocks are particularly troubling because there is no general solution to avoid (soft) deadlocks.

This situation may be likened to two people who are drawing diagrams, with only one pencil and one ruler between them. If one person takes the pencil and the other takes the ruler, a deadlock occurs when the person with the pencil needs the ruler and the person with the ruler needs the pencil to finish his work with the ruler. Both requests can't be satisfied, so a deadlock occurs.

The telecommunications description of deadlock is a little stronger: deadlock occurs when none of the processes meet the condition to move to another state (as described in the process's finite state machine) and all the communication channels are empty. The second condition is often left out on other systems but is important in the telecommunication context.

Contents

Examples

An example of a deadlock which may occur in database products is the following. Client applications using the database may require exclusive access to a table, and in order to gain exclusive access they ask for a lock. If one client application holds a lock on a table and attempts to obtain the lock on a second table that is already held by a second client application, this may lead to deadlock if the second application then attempts to obtain the lock that is held by the first application. (But this particular type of deadlock is easily prevented, e.g., by using an all-or-none resource allocation algorithm.)

Another example might be a text formatting program that accepts text sent to it to be processed and then returns the results, but does so only after receiving "enough" text to work on (e.g. 1KB). A text editor program is written that sends the formatter with some text and then waits for the results. In this case a deadlock may occur on the last block of text. Since the formatter may not have sufficient text for processing, it will suspend itself while waiting for the additional text, which will never arrive since the text editor has sent it all of the text it has. Meanwhile, the text editor is itself suspended waiting for the last output from the formatter. This type of deadlock is sometimes referred to as a deadly embrace (properly used only when only two applications are involved) or starvation. However, this situation, too, is easily prevented by having the text editor send a forcing message (eg. EOF) with its last (partial) block of text, which will force the formatter to return the last (partial) block after formatting, and not wait for additional text.

Nevertheless, since there is no general solution for deadlock prevention, each type of deadlock must be anticipated and specially prevented. But general algorithms can be implemented within the operating system so that if one or more applications becomes blocked, it will usually be terminated after (and, in the meantime, is allowed no other resources and may need to surrender those it already has, rolled back to a state prior to being obtained by the application).

Coping with deadlock

Necessary conditions

There are four necessary conditions for a deadlock to occur, known as the Coffman conditions from their first description in a 1971 article by E. G. Coffman.

  1. Mutual exclusion condition: a resource that cannot be used by more than one process at a time
  2. Hold and wait condition: processes already holding resources may request new resources
  3. No preemption condition: No resource can be forcibly removed from a process holding it, resources can be released only by the explicit action of the process
  4. Circular wait condition: two or more processes form a circular chain where each process waits for a resource that the next process in the chain holds

Prevention

  • Removing the mutual exclusion condition means that no process may have exclusive access to a resource. This proves impossible for resources that cannot be spooled, and even with spooled resources deadlock could still occur. Algorithms that avoid mutual exclusion are called non-blocking synchronization algorithms.
  • The "hold and wait" conditions may be removed by requiring processes to request all the resources they will need before starting up (or before embarking upon a particular set of operations); this advance knowledge is frequently difficult to satisfy and, in any case, is an inefficient use of resources. Another way is to require processes to release all their resources before requesting all the resources they will need. This too is often impractical. (Such algorithms, such as serializing tokens, are known as the all-or-none algorithms.)
  • A "no preemption" (lockout) condition may also be difficult or impossible to avoid as a process has to be able to have a resource for a certain amount of time, or the processing outcome may be inconsistent or thrashing may occur. However, inability to enforce preemption may interfere with a priority algorithm. (Note: Preemption of a "locked out" resource generally implies a rollback, and is to be avoided, since it is very costly in overhead.) Algorithms that allow preemption include lock-free and wait-free algorithms and optimistic concurrency control.
  • The circular wait condition: Algorithms that avoid circular waits include "disable interrupts during critical sections", and "use a hierarchy to determine a partial ordering of resources" (where no obvious hierarchy exists, even the memory address of resources has been used to determine ordering) and Dijkstra's solution.

Circular wait prevention

Circular wait prevention consists of allowing processes to wait for resources, but ensure that the waiting can't be circular. One approach might be to assign a precedence to each resource and force processes to request resources in order of increasing precedence. That is to say that if a process holds some resources, and the highest precedence of these resources is m, then this process cannot request any resource with precedence smaller than m. This forces resource allocation to follow a particular and non-circular ordering, so circular wait cannot occur. Another approach is to allow holding only one resource per process; if a process requests another resource, it must first free the one it is currently holding (that is, disallow hold-and-wait).

Avoidance

Deadlock can be avoided if certain information about processes is available in advance of resource allocation. For every resource request, the system sees if granting the request will mean that the system will enter an unsafe state, meaning a state that could result in deadlock. The system then only grants requests that will lead to safe states. In order for the system to be able to figure out whether the next state will be safe or unsafe, it must know in advance at any time the number and type of all resources in existence, available, and requested. One known algorithm that is used for deadlock avoidance is the Banker's algorithm, which requires resource usage limit to be known in advance. However, for many systems it is impossible to know in advance what every process will request. This means that deadlock avoidance is often impossible.

Two other algorithms are Wait/Die and Wound/Wait, each of which uses a symmetry-breaking technique. In both these algorithms there exists an older process (O) and a younger process (Y). Process age can be determined by a time stamp at process creation time. Smaller time stamps are older processes, while larger timestamps represent younger processes.

Wait/Die Wound/Wait
O needs a resource held by Y O waits Y dies
Y needs a resource held by O Y dies O waits

It is important to note that a process may be in an unsafe state but would not result in a deadlock. The notion of safe/unsafe states only refers to the ability of the system to enter a deadlock state or not. For example, if a process requests A which would result in an unsafe state, but releases B which would prevent circular wait, then the state is unsafe but the system is not in deadlock.

Detection

Often neither deadlock avoidance nor deadlock prevention may be used. Instead deadlock detection and process restart are used by employing an algorithm that tracks resource allocation and process states, and rolls back and restarts one or more of the processes in order to remove the deadlock. Detecting a deadlock that has already occurred is easily possible since the resources that each process has locked and/or currently requested are known to the resource scheduler or OS.

Detecting the possibility of a deadlock before it occurs is much more difficult and is, in fact, generally undecidable, because the halting problem can be rephrased as a deadlock scenario. However, in specific environments, using specific means of locking resources, deadlock detection may be decidable. In the general case, it is not possible to distinguish between algorithms that are merely waiting for a very unlikely set of circumstances to occur and algorithms that will never finish because of deadlock.

Distributed deadlock

Distributed deadlocks can occur in distributed systems when distributed transactions or concurrency control is being used. Distributed deadlocks can be detected either by constructing a global wait-for graph, from local wait-for graphs at a deadlock detector or by a distributed algorithm like edge chasing.

In a Commitment ordering based distributed environment (including the Strong strict two-phase locking (SS2PL, or rigorous) special case) distributed deadlocks are resolved automatically by the atomic commitment protocol (e.g. two-phase commit (2PC)), and no global wait-for graph or other resolution mechanism are needed.

Phantom deadlocks are deadlocks that are detected in a distributed system due to system internal delays, but no longer actually exist at the time of detection.

Livelock

A livelock is similar to a deadlock, except that the states of the processes involved in the livelock constantly change with regard to one another, none progressing.[2] Livelock is a special case of resource starvation; the general definition only states that a specific process is not progressing.[3]

A real-world example of livelock occurs when two people meet in a narrow corridor, and each tries to be polite by moving aside to let the other pass, but they end up swaying from side to side without making any progress because they both repeatedly move the same way at the same time.

Livelock is a risk with some algorithms that detect and recover from deadlock. If more than one process takes action, the deadlock detection algorithm can repeatedly trigger. This can be avoided by ensuring that only one process (chosen randomly or by priority) takes action.[4]

See also

References

  1. ^ A Treasury of Railroad Folklore, B.A. Botkin & A.F. Harlow, p. 381
  2. ^ Mogul, Jeffrey C.; K. K. Ramakrishnan (2007). "Eliminating receive livelock in an interrupt-driven kernel". http://citeseer.ist.psu.edu/326777.html. 
  3. ^ Anderson, James H.; Yong-jik Kim (2001). "Shared-memory mutual exclusion: Major research trends since 1986". http://citeseer.ist.psu.edu/anderson01sharedmemory.html. 
  4. ^ Zöbel, Dieter (October 1983). "The Deadlock problem: a classifying bibliography". ACM SIGOPS Operating Systems Review 17 (4): 6-15. ISSN 0163-5980. http://doi.acm.org/10.1145/850752.850753. 

External links

Articles

Papers

General


Translations: Deadlock
Top

Dansk (Danish)
n. - hårdknude
v. tr. - få til at gå i hårdknude, fastlåse
v. intr. - gå i hårdknude, fastlåses

Nederlands (Dutch)
impasse

Français (French)
n. - impasse, point mort
v. tr. - aboutir à une impasse/être dans une impasse
v. intr. - aboutir à une impasse/être dans une impasse

Deutsch (German)
n. - Sackgasse, toter Punkt
v. - blockieren, an einem toten Punkt anlangen

Ελληνική (Greek)
n. - αδιέξοδο, σκάλωμα

Italiano (Italian)
punto morto, stallo

idioms:

  • reach deadlock    arrivare a un punto morto

Português (Portuguese)
n. - impasse (m), empate (m)

idioms:

  • reach deadlock    empatar, chegar a um impasse

Русский (Russian)
тупик, ничья

idioms:

  • reach deadlock    зайти в тупик

Español (Spanish)
n. - impasse, punto muerto, cerradura con pestillo de golpe
v. tr. - llegar a un punto muerto
v. intr. - llegar a un punto muerto

Svenska (Swedish)
n. - dödläge

中文(简体)(Chinese (Simplified))
僵局, 停顿, 使僵持, 使停顿, 用单闩锁锁住, 陷入僵局, 用单闩锁锁

中文(繁體)(Chinese (Traditional))
n. - 僵局, 停頓
v. tr. - 使僵持, 使停頓, 用單閂鎖鎖住
v. intr. - 陷入僵局, 停頓, 用單閂鎖鎖

한국어 (Korean)
n. - 막다른 골목, 이중 자물쇠
v. tr. - 정돈 시키다
v. intr. - 정돈되다, 극도의

日本語 (Japanese)
n. - 行き詰まり
v. - 行き詰まらせる, 行き詰まる

العربيه (Arabic)
‏(الاسم) الورطه, حاله يصبح فيها التقدم مستحيلا, إخفاق كامل في الوصول الى تسويه نزاع ما‏

עברית (Hebrew)
n. - ‮מבוי סתום, קיפאון, אי-תזוזה, סוג של מנעול‬
v. tr. - ‮הביא או הגיע למצב אי-תזוזה‬
v. intr. - ‮הגיע למבוי סתום‬


 
 
Learn More
stalemate
tie
total deadlock (computer science)

What is deadlock and explain it? Read answer...
Can deadlocks be prevented? Read answer...
What is trench deadlock? Read answer...

Help us answer these
How was the deadlock broken?
When was the political Deadlock?
Why deadlock occur?

Post a question - any question - to the WikiAnswers community:

 

Copyrights:

Dictionary. The American Heritage® Dictionary of the English Language, Fourth Edition Copyright © 2007, 2000 by Houghton Mifflin Company. Updated in 2009. Published by Houghton Mifflin Company. All rights reserved.  Read more
Computer Desktop Encyclopedia. THIS COPYRIGHTED DEFINITION IS FOR PERSONAL USE ONLY.
All other reproduction is strictly prohibited without permission from the publisher.
© 1981-2009 Computer Language Company Inc.  All rights reserved.  Read more
Thesaurus. Roget's II: The New Thesaurus, Third Edition by the Editors of the American Heritage® Dictionary Copyright © 1995 by Houghton Mifflin Company. Published by Houghton Mifflin Company. All rights reserved.  Read more
Answers Corporation Antonyms. © 1999-2009 by Answers Corporation. All rights reserved.  Read more
Hacker Slang. The Jargon File. Copyright © 2007.  Read more
Architecture. McGraw-Hill Dictionary of Architecture and Construction. Copyright © 2003 by McGraw-Hill Companies, Inc. All rights reserved.  Read more
Wikipedia. This article is licensed under the Creative Commons Attribution/Share-Alike License. It uses material from the Wikipedia article "Deadlock" Read more
Translations. Copyright © 2007, WizCom Technologies Ltd. All rights reserved.  Read more