
Here is the simplest example: Program 1 requests resource A and receives it. Programs could request further allocations of resources after they had begun running. Eventually some operating systems offered dynamic allocation of resources. Programs were required to specify in advance what resources they needed so that they could avoid conflicts with other programs running at the same time. Later, operating systems ran multiple programs at once, interleaving them. All of the resources of the system were available to this one program. The earliest computer operating systems ran only one program at a time. Each process is waiting for resource that is held by next member of the chain.Īll four of these conditions must be present for a deadlock to occur.A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting in both programs ceasing to function.
There must be a circular chain of 2 or more processes. Previously granted resources cannot be forcibly taken away from process. Process currently holding resources granted earlier can request more resources. Each resource is either currently assigned to exactly one process or is available. There are four conditions that must hold for deadlock: Question-3 List the conditions that lead to deadlock. In general, deadlocks involve non-preemptable resources. If a process has begun to burn a CD-ROM, suddenly taking the CD recorder away from it and giving it to another process will result in a garbled CD, CD recorders are not preemptable at an arbitrary moment.
A non-preemptable resource, in contrast, is one that cannot be taken away from its current owner without causing the computation to fail. Now A can run, do its printing, and then release the printer. Fortunately, it is possible to preempt (take away) the memory from B by swapping it out and swapping A in. Potentially, we now have a deadlock situation, because A has the printer and B has the memory, and neither can proceed without the resource held by the other. Process B now runs and tries, unsuccessfully, to acquire the printer. Before it has finished with the computation, it exceeds its time quantum and is swapped out. Process A requests and gets the printer, then starts to compute the values to print. Consider, for example, a system with 32 MB of user memory, one printer, and two 32-MB processes such that each process wants to print something. A preemptable resource is one that can be taken away from the process holding it with no ill effects. Resources come in two types: preemptable and non-preemptable. Question-2 Explain preempt able and non-preempt able resource with example. Processes C and D are in deadlock over resources T and U. Process D is requesting / waiting for resource U and process C is requesting / waiting for resource T. As shown in figure Above, resource T assigned to process D and resource U is assigned to process C. Now process D requests resource U and process C requests resource T but none of process will get this resource because these resources are already hold by other process so both can be blocked, with neither one be able to proceed, this situation is called deadlock. Suppose process D holds resource T and process C holds resource U.
A set of processes is deadlocked if each process in the set is waiting for an event that only another process in the set can cause.(3) List the conditions that lead to deadlock.
(2) Explain preempt able and non-preempt able resource with example.Lists of Long Descriptive type Questions that may be asked in Written Exams. Here in this section of Operating System Long Questions and Answers,We have listed out some of the important Long Questions with Answers on Deadlocks which will help students to answer it correctly in their University Written Exam.