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

What is multiprogramming, Q. What is Multiprogramming? Multiprogrammin...

Q. What is Multiprogramming? Multiprogramming When two or more programs are in memory at the same instance, sharing the processor is referred to multiprogramming opera

Basic server model, Suppose we want to program a Web server; we could easil...

Suppose we want to program a Web server; we could easily do so without using concurrency, as follows: while(true) wait connection read from socket and parse url look up url cont

Batch oriented and interactive operating system., properies of Batch orient...

properies of Batch oriented and interactive operating system.

Explain fifo page replacement, FIFO page replacement This is the easie...

FIFO page replacement This is the easiest page replacement algorithm. At this juncture the 1 st page entering is the 1 st to leave that is the oldest page leaves. To execute

What is a file, What is a file? A file is a named collection of related...

What is a file? A file is a named collection of related information that is recorded on secondary storage. A file having either programs or data. A file has particular "structu

Explain lru enhanced second chance algorithm, Enhanced Second chance algori...

Enhanced Second chance algorithm In this a modify bit is as well used. Now if the ordered pair of reference and modify is (0,0) neither recently used nor modified - the best

What do you mean by best fit, What do you mean by best fit? Best fit al...

What do you mean by best fit? Best fit allocates the smallest hole that is big sufficient. The entire list has to be searched, until it is sorted by size. This strategy creates

Scheduler that select process from secondary storage device, A scheduler th...

A scheduler that selects processes from secondary storage device is known as                    Medium term scheduler is a scheduler that selects processes from secondary stor

Explain schemes for defining the logical structure, What are the most commo...

What are the most common schemes for defining the logical structure of a directory? The most common schemes for explaining the logical structure of a directory Single-L

Write knowledge base relevant propositional statement, Suppose a logic-base...

Suppose a logic-based agent in the wumpus world has found that locations (1,1) and (2,1) do not contain a stench, but that locations (3,1) and (2,2) do contain a stench. Can the ag

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