Presentation is loading. Please wait.

Presentation is loading. Please wait.

The relation between the process and

Similar presentations


Presentation on theme: "The relation between the process and"— Presentation transcript:

1

2 The relation between the process and
the resource 1- request then a) use or b) wait 2- release Graphical representation of Process Resource DeadLock

3 DeadLock Definition It is a situation where a group of processes are permanently blocked because each process wait for a resource that is held by another process in the same group. That means a cycle directed in one direction occurs between the processes and the resources.

4 Example for processes and resources relation with DeadLock

5 Example for processes and resources relation without DeadLock

6 That means there is a resource that can not be shared by more than one process
1- That means there is a possibility for a process to hold a resource while waiting for another 2- 3- That means there is no possibility to preempt the use of a resource That means a circular relation could happen between processes and resources without possibility of ending that waiting 4-

7 1- 2- 3-

8 Ignore Method In this method we will assume that the deadlock never happens. And if it happened somewhere in the system, we will not take care for it until it causes to hang all the system. Here, we need to restart the system manually. 1-This method is the most simple one since no algorithms used to monitor the deadlock 2-This method is commonly used because the deadlock normally rarely happens.

9 Detection and Recovery Method
This method consists of two steps 1- detect the deadlock when happens 2- recover the system from the deadlock by doing some necessary action First step: In this step, the operating system will use suitable algorithm to monitor and update the relations that happen between the processes and the resources on each request and on each release. Such method is to build and monitor a directed graph that is updating on a request or a release of a resource. For example, Let us assume that such relation occurred at some time. It is clear that there is deadlock condition between the processes G ,D ,E. When the monitor discovers the deadlock then the next step takes place. The most important factor in first step is how frequently The monitoring is done per time. It is better to minimize the number of monitoring because it i is waste of time. However, this depends on how frequently we suspect the deadlock may happen in the computer system.

10 Second Step : It is what the operating system will do after discovering the deadlock. Here, also there are different techniques as below: a) Recovery through killing processes : In this technique the operating system will try to break the cycle of the deadlock by killing one of the processes that caused the deadlock. The selection of the process or processes the will be killed is very sensitive because the killing of a process means that this process will start from the beginning. And hence, if that restart may cause some problems ( e.g. a Data Base process) then the operating system will select other process to be killed. b) Recovery through rollback : In this technique the operating system will build a file contains data about certain points through the life of each process. When a deadlock happens then the operating system will select a process to from the deadlock cycle and return it to the previous point according to the data in the file. So we don’t need to restart the process from the beginning. But here we must take care for some operation that needs to be managed well (e.g. The printing papers after the check point that the process return to, must be cancelled because these papers will be reprinted again).

11 Avoidance Method The avoidance is difference from the prevention of the deadlock. Since prevention means the breaking of one of the 4 necessary conditions that cause the deadlock, while the avoidance of the deadlock means that the deadlock may happen in the computer system but OS must take care to avoid it. The principle behind the deadlock avoidance depends upon the idea of careful resource allocation . In other word, when any process requests a resource then the OS will check if the request leads to safe or unsafe state. The meaning of safe and unsafe state can be explained as in the following figure. The safe state is when there is no possibility for the deadlock to happen under the worst case of resources requests [ ie: each process requests the maximum need of resources]. The unsafe state is when there is a possibility [ even 1%] for the deadlock to happen under also the worst case of resources requests.

12 The Banker’s Algorithm: It is the most famous algorithm that is suggested by Dijkstra in The idea of this algorithm is coming from the bank system. Since the process is similar to the customer while the resource may have the same meaning of the money unit. To understand how this algorithm works to avoid the deadlock we may get the following example: Here, there are 3 processes [p0 , p1 , p2 ] and the maximum number of the required resources for each process is 10 , 4 , 9 Respectively. Also we will assume that the available resources at the beginning is 12 unit. Now we will check the system if it is safe or not in different times, and we will see how the banker’s algorithm will allow the request if it will lead to a safe state otherwise that request will be forbidden . At t0 : the system is safe because in the worst case there is at least a path to serve all the process to use their maximum need, this path is [ p p p2 ] At t1 : the system is safe because in the worst case there is at least a path to serve all the process to use their maximum need, this path is [ p p p2 ] At t2 : the system is unsafe because in the worst case there is no path to serve all the process to use their maximum need. So the last request of p2 will be forbidden.

13 The drawbacks of the Banker’s Algorithm
1- it difficult to know the maximum need of each process at the beginning [ ie before the process starts working] 2- the number of the processes that use the resources may vary varying [ increase or decrease] 3- one or more of the resources may suddenly damage


Download ppt "The relation between the process and"

Similar presentations


Ads by Google