Deadlock Flashcards

1
Q

Deadlock

A

A deadlock involves processes waiting for each other, resulting in a complete halt where processes enter an infinitely waiting state waiting for each other

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Livelock

A

Is a situation where a request for an exclusive lock is denied repeatedly
* Hence, causing starvation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Deadlock Characterization

A

Deadlock can arise if four conditions hold simultaneously:
* Mutual exclusion: only one process at a time can use a resource
* Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes
* Circular wait: there exists a set {P0 ,P1, …, Pn } 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 Pn is waiting for a resource that is held by P0.
* No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Resource-Allocation Graph

A

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 Pi -> Rj
* assignment edge – directed edge Rj ->Pi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Deadlock Prevention

A

Make sure to prevent one of the four causes of the deadlock

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Deadlock Prevention by Mutual Exclusion

A

Sharable resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Deadlock Prevention by Hold and Wait

A

Must guarantee that whenever a process requests a resource, it does not hold any other resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Deadlock Prevention by Preemption

A

Use time quantum method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Deadlock Prevention by Circular Wait

A

Impose a total ordering of all resource types, and require that each process requests resources in an increasing order of enumeration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Deadlock Avoidance

A

Requires that the system has some additional a priori information available.
* Requires that each process declare the maximum number of resources of each type that it may need
* The deadlock-avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular-wait condition
* Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Safe state

A

– System is in safe state if there exists a sequence <P1 , P2 , …, Pn> of ALL the processes in the systems such that for each Pi , the resources that Pi can still request can be satisfied by currently available resources + resources held by all the Pj, with j < I
– That is:
* If Pi resource needs are not immediately available, then Pi can wait until all Pj have finished
* When Pj is finished, Pi can obtain needed resources, execute, return allocated resources, and terminate
* When Pi terminates, Pi +1 can obtain its needed resources, and so on

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Resource-Allocation Graph Scheme

A

– Claim edge Pi  Rj indicated that process Pj may request resource Rj – represented by a dashed line
– Claim edge converts to request edge when a process requests a resource
– Request edge converted to an assignment edge when the resource is allocated to the process
– When a resource is released by a process, assignment edge reconverts to a claim edge
– Resources must be claimed a priori in the system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Deadlock Detection

A

For single instance per resource:
- Maintain wait-for graph
- Periodically invoke an algorithm that searches for a cycle in the graph. If there is a cycle, there exists a deadlock
- An algorithm to detect a cycle in a graph requires an order of n2 operations, where n is the number of vertices in the graph

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Recovery from Deadlock: Process Termination

A
  • Abort all deadlocked processes
  • Abort one process at a time until the deadlock cycle is eliminated
  • In which order should we choose to abort?
    1. Priority of the process
    2. How long process has computed, and how much longer to completion
    3. Resources the process has used
    4. Resources process needs to complete
    5. How many processes will need to be terminated
    6. Is process interactive or batch?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Resource Preemption when Recovery from Deadlock by Termination

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly