Deadlocks (week 7) Flashcards

1
Q

define deadlocks

A

A deadlock is a situation where in a group
of two or more processes/threads, each
process holds at least one resource while
making a request on another, and all
requests cannot be satisfied because the
requested resource is held by another
process that is being blocked, waiting for
another resource.

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

how can deadlocks occur

A

–> multiprogramming environment where processes share the resources.

–> deadlocks can also occur between threads in the same process

–> Resource managers can also be involved in a deadlock with an application process

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

what are the 4 conditions for the deadlocks to happen

A

–> Mutual exclusion
–> Hold and Wait
–> Circular wait
–> No preemption

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

explain what is mutual exclusion in the scenario of deadlocks

A

–> Once a process has been allocated a
particular resource, the threads in the process have exclusive use of the resource.

–> No other processes can use a resource while it is allocated to a process.

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

explain what is hold and wait in the scenario of deadlocks

A

A process may hold a resource at the same
time it requests another one.

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

explain what is circular wait in the scenario of deadlocks

A

A situation can rise in which process p1 holds resource R1 while one of its threads requests resource R2, and process p2 holds R2 while one of its threads requests resource R1.

There may be more than two processes involved in the circular wait.

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

explain what is non preemption in the scenario of deadlocks

A

Resources can be released only by the explicit action in a process, rather than by the action of an external authority.

This assumption includes the case in which a process places a request for a resource and the resource is not available. Then the process cannot withdraw its request.

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

what are the 4 approaches to addressing deadlocks

A

prevention
avoidance
detection & recovery
manual intervention

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

what is prevention

A

–> Design the system so that
deadlock is impossible

–> Address the 4 conditions so that at least one of them does not hold. (mutual exclusion, hold and wait, circular waiting, no preemption)

–> Most common strategy is to design the resource managers so that they are guaranteed to violate at least one of the conditions.

–> for example windows NT assures that there is no circular waiting

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

what is avoidance

A

–> Manage deadlocks by allow resource
allocation only if it is satisfied that
deadlocks will not occur

–> implemented using Banker’s Algorithm.

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

what is Detection and Recovery

A

–> it is an aggressive strategy

–> Disregards deadlocks, but aims to detect
when it does occur and takes additional
steps to remove it. (recovery)

–> Therefore, we need both a detection
mechanism and a recovery mechanism.

–> For detection, an algorithm similar to
Banker’s algorithm can be used.

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

when to invoke the deadlock detection algorithm

A

–> Invoke each time a request for allocation cannot be granted immediately.

–> Invoke at regular time intervals, eg, once per hour

–> Invoke when CPU utilization drops below 40%

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

what is the advantage of Invoking deadlock detection algorithm each time a request for allocation cannot be granted immediately.

A

able to identify the specific process
that caused the deadlock

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

what is the disadvantage of Invoking deadlock detection algorithm each time a request for allocation cannot be granted immediately.

A

overhead in computation time (as you are using the cpu to check for deadlocks instead of running regular processes)

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

Resources allocated to deadlocked
processes will be _______ until the deadlock is broken.

A

idle

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

what are the 2 options to breaking deadlocks (deadlock recovery ) for the manual intervention method

A

–> Process termination
–> Resource Preemption

17
Q

what are the 2 ways of doing process termination

A

there are 2 ways of doing process termination

–> abort all the deadlocked process
–> Abort one process at a time until the deadlock cycle is broken

18
Q

why is aborting all the deadlocked process expensive

A

This method is expensive since processes may have computed for a long time, and all results must be discarded, and recomputed again.

19
Q

why is Aborting one process at a time incurring overhead

A

This method incurs overhead since after each process is aborted, deadlock detection algorithm must be invoked to check whether any process is still deadlocked.

20
Q

Aborting a process may not be _______

give an example of why this is the case

A

simple

process may be in the midst of updating a file

21
Q

what must be defined in partial termination method

A

a policy must be defined as to which process to terminate

22
Q

Factors to determine which process is chosen in process termination

A

–> The priority of process
–> How long the process has computed and how much longer to go
–> How many and what type of resources the process has used
–> How many more resources the process needs in order to complete
–> How many processes will need to be terminated
–> Whether the process is interactive or batch

23
Q

how does Resource Preemption work ?

A

Preempt some resources from processes and give these resources to other processes until the deadlock cycle is broken

24
Q

what happens to the resource allocated for processes when either process termination or resource preemption
methods occur

A

the system reclaims all resource allocated to the terminating processes.

25
Q

what are 3 issues to be addressed in resource preemption

A

–> Selecting a victim
–> Rollback
–> Starvation

26
Q

what does it mean to select a victim

A

It means which resources and processes to preempt?

the answer to that is that it depends on cost, amount of time
process execute thus far, number of resources holding, etc.

27
Q

what does the rollback issue mean

A

If we preempt a resource from a process, what should be done to the process?

Either total rollback or rollback enough to break deadlock

28
Q

what does Starvation mean

A

How to ensure starvation will not occur? That is, how can we guarantee that resources will not always be preempted from the same process?

A common solution is to include the number of rollbacks in the cost factor.

29
Q

what Combined Approach to Deadlock Handling do internal resources do

A

internal resources are used by the system and prevention is done through resource ordering

30
Q

what Combined Approach to Deadlock Handling do central memory do

A

central memory is the memory used by a user job and prevention is done through preemption

31
Q

what Combined Approach to Deadlock Handling do Job resources do

A

job resources is the devices that can be assigned, for example, tape drive, files

deadlocks are addressed though avoidance

31
Q

what Combined Approach to Deadlock Handling do Job resources do

A

job resources is the devices that can be assigned, for example, tape drive, files

deadlocks are addressed though avoided

32
Q

what Combined Approach to Deadlock Handling does Swappable space do

A

swappable space is the Space on backing store for each user job

deadlocks are addressed though Preallocation

33
Q

how to disallow hold and wait condition

A

–> Require a process to request all of its resources when it is created.

–> Require the process to release all currently held resources prior to requesting any new ones.

34
Q

give the characteristics of Requiring a process to request all of its resources when it is created.

A

–> Easy implementable in batch systems.

–> Not easy in interactive systems as processes do not ‘announce’ their resource requirements at runtime

35
Q

give the characteristics of requiring the process to release all currently held resources prior to requesting any new ones

A

–> More suitable for interactive systems.

–> Have processes request for resources based on a particular operation and then release it when proceeding onto another operation with a new set of resources.

–> Or, when a process requires a new resource, it releases all of its current resources and then acquires the old resources along with the new one.

36
Q

how to disallow circular wait (technique 1)

A

–> Use a process-resource model to detect cycles in the graph.

–> Choose a resource request strategy by which no cycle will be
introduced

–> Cycle condition will reflect circular wait if each resource type
has only one instance (non-sharable).

37
Q

how to disallow circular wait (technique 2)

A

–> Total order on all resources, then can only ask for Rj if Ri < Rj for all Ri the process is currently holding

–> Number each resource uniquely

–> A process wishing to obtain resources must obtain them in ascending or decreasing order

–> If new resource is not in the correct order, release all currently held resources and re-obtain them in the correct order.

38
Q

how to disallow preemption

A

If a process requests for a resource and the resource is not available, its currently held resources can be preempted by the OS and given to other resources.