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

Solve a generalized dining philosopher problem, In this project, you will i...

In this project, you will implement the Chandy and Misra's (CM) algorithm using POSIX Threads (Pthreads).   The algorithm  is a distributed algorithm to solve a generalized dining

Calculate the number of processes to avoid race condition, To evade race co...

To evade race condition, the maximum number of processes that may be at the same time inside the critical section is The maximum number of processes which may be at the same t

Multiprogramming, what are the main advantages of multiprogramming

what are the main advantages of multiprogramming

Student, Explain how the os implements virtual memory phenomenon.

Explain how the os implements virtual memory phenomenon.

Explain signal handling, Signal handling A signal is used in UNIX syste...

Signal handling A signal is used in UNIX systems to inform a process that a particular event has occurred. 1. A signal is produced by the occurrence of a particular event.

Principles of operating systems, Objective - Tiny Shell (tish) In this...

Objective - Tiny Shell (tish) In this exercise you will write a small shell program to run different programs in foreground and background mode. Background Usually when

Memory management, 4. Describe priority scheduling algorithm. Consider the ...

4. Describe priority scheduling algorithm. Consider the following set of processes. Show the order in which the algorithm will schedule these processes. Assume preemptive and non-p

Error detection, about error detection in operating system and how does it ...

about error detection in operating system and how does it take place?

What is critical section problem, What is critical section problem? Con...

What is critical section problem? Consider a system consists of 'n' processes. Every process has segment of code called a critical section, in which the process might be changi

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