Lecture 13&14- Deadlocks Flashcards

1
Q

Definition of deadlock

A

Deadlock is a situation when one or more processes get stuck

e.g. infinite loop

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

What are the 4 ways to handle deadlocks?

A

Ignore.
Detect and fight.
Avoid.
Prevent.

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

What is Deadlock detection?

A

The operating system runs a special software that can recognise that a deadlock has happened.

Once a deadlock has been detected, special measures are taken to its elimination.

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

What are the ways of elimination of the detected deadlock?

A

Preemption. A resource is (temporarily) taken from one of the processes currently holding it and transferred to another process. Example: part of data is recorded on a disc and a
block of RAM gets free.

Drawback: some resources are non-preemptable (e.g. printer).

Rollback. Each program is checkpointed periodically. The program is rolled back to a point in time prior to deadlock
and the allocation of resources is changed.
Killing processes. Normally this is done manually as the system cannot decide which process to kill.

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

What is Deadlock avoidance?

A

The system has a smart scheduling policy of running programs so that deadlocks are avoided.

For example, such smart system would not let the programs in the last example to get into a deadlock.

Requires knowledge about future operations of processes.

This knowledge is not easy to get.

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

What is Deadlock prevention?

A

A system is designed in a way that deadlocks in principle cannot occur.

Imposes strict requirements on programs running in this system.

Programs of the last example will be impossible to run.

Difference from deadlock avoidance: in the latter deadlocks are possible in principle but the system tries to foresee and
avoid them.

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

Dealing with deadlocks in real systems?

A

A standard principle of engineering: a potential trouble has to be explicitly dealt with only if the negative effect of letting it happen significantly overweights the price of its elimination.

Deadlocks do not do much harm to common users of personal computers.

Therefore OS like Linux and Windows ignore deadlocks(although there are Linux utilities that allow to detect deadlocks).

On the other hand, deadlocks can have devastating effects on real-time safety critical systems (medical equipment, air crafts, etc.) and large database systems (banking salary
computation).

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

What are the Processes and resources?

A

The standard terminology related to deadlocks involves two main notions processes and resources.

We have met both these notions in the previous lectures.

The notion of resource is very broadly understood: block of memory, printer, scanner, etc.

A process during its execution can hold resources and release them.

A deadlock occurs if there is a group of processes each wants to get a resource currently being held by another process of
this group.

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

How to Detecting a deadlock with a single resource of each type?

A

Single resource of each type means: one printer, one disc, one scanner, etc.

The OS looks at the current state of the processes in the given moment of time of time and decides if there is a deadlock.

What is the information used by the system:
The list of processes.
The list of resources
The relationship between the given process and the given resource: holding, requesting, neither of them.

We will see a deadlock detection algorithm based on the above information

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

What is the deadlock detection algorithm?

A

The input is represented in the form of a graph
Nodes correspond to processes and resources.
There is an arc from the node corresponding to resource R to
the node corresponding to process P if P is currently holding R.

There is an arc from P to R if P is requesting R.

The system is in a deadlock if an only if the above graph has a directed cycle

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

How use of deadlock avoidance?

A

Each time a resource request is made the system analyses the safeness of the state occurring after the requests has been
granted.

If the considered state is not safe then the request is either denied or delayed.

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

What is Deadlock prevention?

A

Four necessary conditions of deadlock existence.
1 Mutual exclusion. Each resource can be assigned to at most
one process.

2 Hold and wait. Processes currently holding the resources may request more resources.

3 No preemption. Resources granted cannot be forcibly taken away before the process has released them.

4 Circular wait. There is a circular chain of processes waiting for a resource held by the next member of the chain.

A system preventing deadlocks makes one of these condition
impossible to occur.

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

How to Elimination of the Hold-and-Wait condition?

A

Each program asks for all the resources at the beginning of its run.

This approach is possible only in batch systems: in interactive systems the user requests are unpredictable.

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

How to Elimination of the circular wait condition?

A

All the resource units are thoroughly enumerated.

The process can ask resources only according to the enumeration order: a process can ask for a new resource only if its number is greater than the numbers of the resources
already held.

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

What is Livelocks and starvation?

A

Live lock is just a deadlock where a process performs infinite loop and not blocked.

Starvation is a situation where a process never gets an opportunity to run. Occurs due to the poor scheduling policy

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