Deadlocks in Operating Systems: Understanding the Conditions and Strategies, Lab Reports of Computer Science

The concept of deadlocks in operating systems, a situation where processes are blocked due to resource allocation. It discusses the four necessary conditions for deadlocks, strategies for handling them, and the use of resource allocation graphs for detection. Deadlock Ignorance, Prevention, Avoidance, and Detection & Recovery are the strategies covered.

Typology: Lab Reports

2019/2020

Uploaded on 06/19/2020

nodem-office
nodem-office 🇮🇶

1 document

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
processor management (deadlocks)
Deadlock is a situation where a set of processes are blocked because each
process is holding a resource and waiting for another resource acquired by
some other process.
Consider an example
when two trains are coming toward each other on same track and there is
only one track, none of the trains can move once they are in front of each
other. Similar situation occurs in operating systems when there are two or
more processes hold some resources and wait for resources held by other(s).
For example, in the below diagram, Process 1 is holding Resource 1 and
waiting for resource 2 which is acquired by process 2, and process 2 is
waiting for resource 1.
pf3
pf4
pf5

Partial preview of the text

Download Deadlocks in Operating Systems: Understanding the Conditions and Strategies and more Lab Reports Computer Science in PDF only on Docsity!

processor management (deadlocks)

Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. Consider an example when two trains are coming toward each other on same track and there is only one track, none of the trains can move once they are in front of each other. Similar situation occurs in operating systems when there are two or more processes hold some resources and wait for resources held by other(s). For example, in the below diagram, Process 1 is holding Resource 1 and waiting for resource 2 which is acquired by process 2, and process 2 is waiting for resource 1.

A process in operating systems uses different resources and uses resources in following way.

  1. Requests a resource
  2. Use the resource
  3. Releases the resource

Deadlock Conditions

  1. mutual exclusion The resources involved must be unshareable; otherwise, the processes would not be prevented from using the resource when necessary.
  2. hold and wait or partial allocation The processes must hold the resources they have already been allocated while waiting for other (requested) resources. If the process had to release its resources when a new resource or resources were requested, deadlock could not occur because the process would not prevent others from using resources that it controlled.
  3. no pre-emption The processes must not have resources taken away while that resource is being used. Otherwise, deadlock could not occur since the operating system could simply take enough resources from running processes to enable any process to finish.
  4. resource waiting or circular wait A circular chain of processes, with each process holding resources which are currently being requested by the next process in the chain, cannot exist. If it does, the cycle theorem (which states that "a cycle in the resource graph is necessary for deadlock to occur") indicated that deadlock could occur.

In simple words, The OS reviews each allocation so that the allocation doesn't cause the deadlock in the system. We will discuss Deadlock avoidance later in detail.

4. Deadlock detection and recovery

This approach let the processes fall in deadlock and then periodically check whether deadlock occur in the system or not. If it occurs then it applies some of the recovery methods to the system to get rid of deadlock. We will discuss deadlock detection and recovery later in more detail since it is a matter of discussion.

Resource Graph of (deadlock)

In some cases deadlocks can be understood more clearly through the use of Resource-Allocation Graphs , having the following properties: A set of resource categories, { R1, R2, R3,.. ., RN }, which appear as square nodes on the graph. Dots inside the resource nodes indicate specific instances of the resource. ( E.g. two dots might represent two laser printers. ) A set of processes, { P1, P2, P3,.. ., PN } Request Edges - A set of directed arcs from Pi to Rj, indicating that process Pi has requested Rj, and is currently waiting for that resource to become available. Assignment Edges - A set of directed arcs from Rj to Pi indicating that resource Rj has been allocated to process Pi, and that Pi is currently holding resource Rj. Note that a request edge can be converted into an assignment edge by reversing the direction of the arc when the request is granted. ( However note also that request edges point to the category box, whereas assignment edges emanate from a particular instance dot within the box. )

Figure 1 - Resource allocation graph

  1. If a resource-allocation graph contains no cycles, then the system is not deadlocked. ( When looking for cycles, remember that these are directed graphs. ) See the example in Figure 7.2 above.
  2. If a resource-allocation graph does contain cycles AND each resource category contains only a single instance, then a deadlock exists.
  3. If a resource category contains more than one instance, then the presence of a cycle in the resource-allocation graph indicates the possibility of a deadlock, but does not guarantee one. Consider, for example, Figures 7.3 and 7. below:

at least one of the necessary conditions never holds. A method for avoiding deadlocks that is less stringent than the prevention algorithms requires that the operating system have a priori information on how

. each process will utilize system resources