Deadlock detection, Operating System

Deadlocks can be detected while the program is running, by running cycle detection algorithms on the graph that de?nes the current use of resources.

De?ne this graph as follows: it has one vertex for each resource (r1; : : : ; rm) and one vertex for each thread (t1; : : : ; tn). If a resource ri is held by thread tj , then we add an edge from vertex ri to vertex tj . If a thread tk is trying to acquire resource r', then we add an edge from vertex tk to vertex r'.

Given this graph, we can run a cycle detection algorithm. If a cycle is found, there is a deadlock. Detecting a deadlock ismuch easier than recovering froma deadlock. Several possible approaches might be to kill all of the threads in the cycle, or kill the threads one at a time, forcing them to release resources, and hope that this will break the deadlock.

While this may sound easy, it is not. Killing threads generally doesn't release their resources cleanly (locks,memory, ?les, etc). This is essentially the rollback problem, to back out all the actions of a thread. Databases usually include rollback mechanisms, which can be quite complicated, and it is not always possible to roll back all the actions of a thread (consider a thread which outputs hard-copy printed pages).

As a general guideline, do not use functions like pthread cancel(), which kills a thread, unless you really know what you are doing.

Posted Date: 3/12/2013 5:31:38 AM | Location : United States







Related Discussions:- Deadlock detection, Assignment Help, Ask Question on Deadlock detection, Get Answer, Expert's Help, Deadlock detection Discussions

Write discussion on Deadlock detection
Your posts are moderated
Related Questions
Explain about interprocess communication The cooperating processes communicate with each other via an interprocess communication facility. IPC gives a mechanism to permit proce


what is a batch system give me answer in simple words so that i can understand

Q. Several CPU-scheduling algorithms are parameterized for instance the RR algorithm requires a parameter to indicate the time slice. Multilevel response queues require parameters

Q. Some untimely computers protected the operating system by placing it in a memory partition that couldn't be modified by either the user job or the operating system itself. Expl

Q. Error detection in operating system? Error detection- Error detection take places at both the hardware and software levels. At the hardware level every data transfers must b

Banker's Algorithm In this analogy Customers ≡ processes Units ≡ resources, say, tape drive Ba

4. Describe priority scheduling algorithm. Consider the following set of processes. Show the order in which the algorithm will schedule these processes. Assume preemptive and non-p


What is scheduler? A process migrates among the various scheduling queues throughout its life time. The OS must choose processes from these queues in some fashion. This selecti