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
Describe swapping technique in UNIX systems. Swapping is used to control memory contention among processes. If there is excessively much memory contention, processes are swappe

Define Name of some language processors?   Name of some language processors are as follow: Assembler, Compiler and Interpreter

Developing Code with Threads Writing code to support a thread-based implementation is very straightforward. Simple APIs are presented to the developer for each threads package.

What are the methods for handling deadlocks ? The technique for handling the deadlocks are: We are able to use protocol to prevent or avoid the deadlock, make sure tha

File structure Certain files must conform to a needed structure that is understood by the operating system. The operating system may consist that an executable file has a parti

We can view an operating system as a resource allocator. Explain. We can outlook an operating system as a resource allocator. A computer system has Many resources (software and

A-  In a table format, compare between Programmed I/O, Interrupt -driven I/O, and Direct Memory Access (DMA) in terms of basic idea, Advantages, disadvantages, and the operating en

Problem: a) The CPU can access 2 storage devices directly. What are these 2 storage devices? b) Define 2 key issues involved in memory management. c) How do processes sha

What is internal fragmentation? Consider holes of 20k assume the process requests 18 bites. If we allocate accurately the request block, we are left with a hole of 2k. The over

What do you mean by semaphore?  Semaphore : A synchronization variable that acquires on positive integer values. Invented by the Dijkstra P (semaphore): an atomic proce