Deadlock detection, Operating System

Assignment Help:

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.


Related Discussions:- Deadlock detection

Nested Macro calls, . Nested Macro calls are expanded using the

. Nested Macro calls are expanded using the

How does user specify block to be fetched in direct access, How does user s...

How does user specify block to be fetched in direct access? By specifying the relative block number, relative to first block in file, which is block 0.

What is page fault, Problem: a) The CPU can access 2 storage devices di...

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

Explain file allocation using i nodes, File allocation using I nodes. T...

File allocation using I nodes. This method is used to decrease the size of the table in the above method. Every file will have an I-node list. Allow a file have 15 pointers a

Producer-consumer using condition variables, Now let us present an implemen...

Now let us present an implementation of a producer-consumer system using condition variables. This implementation works. dequeue() lock(A) while (queue empty) { wait(A, C)

Explain the various page replacement strategies, Explain the various page r...

Explain the various page replacement strategies. Page replacement-basic scheme with diagram Optimal page replacement LRU page replacement FIFO page replacement LRU

Explain the various database applications used in linux, Question 1 Descri...

Question 1 Describe about the shells of Linux operating system Question 2 Describe briefly about GNOME desktop Question 3 Write note on the following- Encryp

Describe swapping technique in unix systems, Describe swapping technique in...

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

How does ntfs handle data structures, Q. How does NTFS handle data structur...

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

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd