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

Questiion 1 What is RTOS? What are its requirements? Questiion 2 Explain the structural elements of a real time system mode Questiion 3 What is kernel? Explain abo

Define properties of Real time operating system Real time :- Often used in a dedicated application, this system reads information from sensors and must respond within a fixed a

Explain the difference between internal and external fragmentation. Internal Fragmentation is the area in a region or a page that is not used by the job occupying that region o

Write a XML with database with book details (BOOK ID, Title, Author, subject, publisher year, language, vendor, and price)

Q. How does NTFS handle data structures? How does NTFS recover from a system crash? What is guaranteed after a recovery takes place? Answer: In NTFS all file-system data stru

What are the advantages of Linked allocation? The benefits are a. No external fragmentation b. Size of the file does not require to be declared

Question 1 Explain the following with respect to Resource Management in Distributed Systems- Task assignment Approach Load - Balancing Approach Load - Sharing Approach

Two Level Directory This kind of structure overcomes the problems of assigning unique names to the files. Thus there need not be any confusion among users. In this kind of s