Lecture 9 - Deadlock Flashcards

1
Q

What is deadlock?

A

Permanent blocking of a set of process because they are all waiting for each other to do something

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

How does deadlock usually occur?

A

When a set of blocked processes each holds a resource and is waiting to acquire a resource held by another process in the set

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

What is the difference between preemptable resources and non preemptable resources?

A

Preemptable - can be taken away from a process with no ill effects

non preemptable - will cause process to fail if taken away

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

If a resource allocation graph contains no cycles, there is no ________

A

deadlock

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

If a resource allocation graph contains a cycle, then

a) if only one instance per resource type ___________
b) if several instances per resource type _____________

A

definite deadlock

possible deadlock

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

What are the 4 conditions for deadlock?

A

Mutual exclusion - only one process may access the resource at a time

Hold and wait - processes hold resources already allocated to them while waiting for others

No preemption - resources only release their resources when they have finished the task

Circular wait - circular chain of processes exists

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

What can the OS do to deal with deadlock?

A

Prevent it (prevent at least one of the 4 conditions)

Dynamically avoid it - carefully allocating resources

Detect the deadlock and recover from it

Ignore it all together

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

How can mutual exclusion be reduced?

A

Make resources shareable - e.g. by spooling

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

How can “hold and wait” be reduced?

What is the problem with this technique?

A

Make processes request all resources they will ever need before starting.

Problem: process may not know what it will need when it starts

ties up resources and stops other processes from using them

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

What is two phase locking?

A

Phase I: try to lock all resources at beginning

Phase II: if successful, use the resources and release them, otherwise release all resources and start over

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

How can circular wait be reduced?

A

Assign an order to resources

Always acquire resources in that order

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

How does the Banker’s algorithm work?

A

say that the system is in a safe state iff system need not deadlock, i.e. there is some order in which the processes can execute so that each process gets all resources it needs when it starts, so it can finish and release them, and then another process can do the same etc..

If the current allocation state is safe and a process wishes to get resources:

if the next state will also be safe, grant the request

Otherwise consider another request instead

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

Why is detecting and recovering from deadlocks a good solution?

A

Awkward and costly to prevent them

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

How is recovery from deadlock usually done?

A

Kill one process at a time, attempting to save the state so it can try again later

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

What is the ostrich algorithm?

A

Ignoring deadlock problem altogether

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

Why is the ostrich algorithm often reasonable?

A

Resources are plentiful in modern systems - cheap hardware

modern OSs virtualize most physical resources anyway

17
Q

Which deadlock solution do windows and Unix use?

A

Ostrich algorithm!!