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
Q. Explain about Deadlocks? Deadlocks for (int i = 0; i // first find a thread that can finish for (int j = 0; j if (!finish[j]) { boolean temp = true; for

Pure and impure interpreters      In a pure interpreter, the source program is maintained in the source form throughout its interpretation. This arrangement acquires substantia

Ask question maxmum words accepted#

Write a brief note on demand paging. A demand paging is alike to a paging system with swapping. The Processes reside on the secondary memory while we want to implement a proces

How is memory management done using linked lists?   Each one node of the l list will have 4 fields as follows 1-this tells whether it s a hole or a process 2-starting ad

List and discuss the various services provided by the operating system. Program execution - system capability to load a program into memory and to run it. I/O operatio

Q. What is the purpose of system calls? Answer: System calls permit user-level processes to request services of the operating system.

draw a state diagram showing the transissions of a process from creation to termination

LINUX VS WINDOWS I/O MANAGEMENT

Q. Dynamically loadable kernel modules give elasticity when drivers are added to a system however do they have disadvantages too? Under what situations would a kernel be compiled