Rss Feed
Showing posts with label OS8. Show all posts
Showing posts with label OS8. Show all posts
Resource-Allocation Graph

Resource Allocation Graph SLIDE # 8:

In slide #9 the graph shows that the R1 is holding for the instance in P2, the P2 is requesting



for instance in R3 then R3 is holding an instances of P3. The R2 has 2 instances whis is holding



the instances of P1 and P2. Then the R4 is null.







Resource Allocation Graph SLIDE # 9:

In slide #9 the graph shows that R1 is holding for the instance in P2, the P2 is requesting


for instance in R3, then R3 is holding an instance in P3, P3 is requesting for instance is R2, then


R2 has 2 instances which is holding the instances of P1 and P2. The R4 is null.



Resource Allocation Graph SLIDE # 10:

In slide #10 the graph shows that P1 is requesting for instance in R1 which has 2 instances. The

R1 is holding the instances of P2 and P3. P3 is requesting instance from R2. R2 contains 2


instances which holding the instances of P1 and P4.



Resource Allocation Graph SLIDE # 20:

In slide #20 the graph shows that R1 is holding the instances of P1, then P1 is requesting for a

resource in R2, P2 is requesting intance for R1 and P2 is requesting for a resource in R2.

Resource Allocation Graph SLIDE # 21:

In slide #21 the graph shows that R1 is holding the instances of P1, then P1 is requesting for a resource in R2, then R2 is holding the instances of P2 and P2 is requesting instance of R1.

DEADLOCK

RESOURCE ALLOCATION GRAPH

A set of vertices V and a set of edges E.

�V is partitioned into two types:

* P = {P1, P2, …, Pn}, the set consisting of all the processes in the system.

* R = {R1, R2, …, Rm}, the set consisting of all resource types in the system.

� Request edge – directed edge P1 ® Rj

� Assignment edge – directed edge Rj ® Pi

�Process

�Resource Type with 4 instances

�Pi requests instance of Rj

�Pi is holding an instance of Rj
How would you know if there is a deadlock based on the Resource Allocator Graph?
� If graph contains a cycle :
* if only one instance per resource type, then deadlock.
* if several instances per resource type, possibility of deadlock.





DEADLOCK

DEADLOCK RECOVERY


{} Recovery from Deadlock: Process Termination {}


Abort all deadlocked processes.


Abort one process at a time until the deadlock cycle is eliminated.


In which order should we choose to abort?

* Priority of the process.

* How long process has computed, and how much longer to completion.

* Resources the process has used.

* Resources process needs to complete.F How many processes will need to be terminated.

* Is process interactive or batch?


Abort all deadlocked processes - this method clearly will break the deadlock cycle, but at a great expense, since these processes may have computed for a long time, and the results of these partial computations must be discarded, and probably must be recomputed later.


Abort one process at a time until the deadlock cycle is eliminated - this method incurs considerable overhead, since, after each process is aborted, a deadlock-detection algorithm must be invoked to determine whether any processes are still deadlock.


Minimum cost


{} Recovery from Deadlock: Resource Preemption {}


Selecting a victim – minimize cost.

Rollback – return to some safe state, restart process for that state.

Starvation – same process may always be picked as victim, include number of rollback in cost factor.




DEADLOCK

DEADLOCK DETECTION
� An algorithm that examines the state of the system to determine whether a deadlock has occurred

� An algorithm to recover from the deadlock
Allow system to enter deadlock state
Detection algorithmn
Recovery scheme

DEADLOCK

DEADLOCK PREVENTION

The case of never enter.

Restrain the ways request can be made (at least one of the necessary conditions should not be true).

Mutual Exclusion – not required for sharable resources; must hold for nonsharable resources.In general not possible to prevent deadlock by this, some resources are intrinsically non-sharable

Hold and Wait – must guarantee that whenever a process requests a resource, it does not hold any other resources.

* Require process to request and be allocated all its resources before it begins execution, or allow process to request resources only when the process has none.

* Low resource utilization; starvation possible.

No Preemption –

* If a process that is holding some resources requests another resource that cannot be immediately allocated to it,then all resources currently being held are released.

* Preempted resources are added to the list of resources for which the process is waiting.

* Process will be restarted only when it can regain its old resources, as well as the new ones that it is requesting.

Circular Wait – impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration.

DEADLOCK

METHOD FOR HANDLING DEADLOCKS
Never enter (prevention & avoidance), detect/recover, ignore…
We can use a protocol to ensure that the system will never enter a deadlock state.
We can allow the system to enter a deadlock� state and then recover
We can ignore the problem all together, and pretend that deadlocks never occur in the system.
This solution is the one used by most operating systems, including UNIX.
Deadlock prevention is a set of methods for ensuring that at least one of the necessary conditions cannot hold.
Deadlock avoidance, on the other hand, requires that the operating system be given in advance additional information concerning which resources a process will request and use during its lifetime.
Ensure that the system will never enter a deadlock state.
Allow the system to enter a deadlock state and then recover.
Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems, including UNIX.

DEADLOCK

DEADLOCK CHARACTERIZATION
Deadlock can arise if four conditions hold simultaneously.

Mutual exclusion - only one process at a time can use a (non-sharable) resource.

Hold and wait - a process holding at least one resource is waiting to acquire additional resources held by other processes.

No preemption - a resource can be released only voluntarily by the process holding it, after that process has completed its task.

Circular wait - there exists a set {P0, P1, …, P0} of waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that is held by P2, …, Pn–1 is waiting for a resource that is held by Pn, and P0 is waiting for a resource that is held by P0.