Deadlocks Flashcards

1
Q

A deadlock is a set of __________ each holding a resource and waiting to acquire a resource held by another _______

A

processes, process

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

What are 2 reasons why deadlocks occur?

A
  • Complex dependencies

- Encapsulation

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

Complex dependencies can cause deadlocks because it’s easy to create _________ _____________

A

circular dependencies

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

____________ can cause deadlocks because each module hides its implementation details without coordinating with other modules

A

Encapsulation

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

What four conditions if held simultaneously MAY cause a deadlock?

A
  • Mutual exclusion
  • Hold and wait
  • No preemption
  • Circular Wait
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is mutual exclusion?

A

Threads requiring exclusive control of resources

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

What is hold and wait?

A

hreads are already holding resources but also are waiting for additional resources being held by other threads

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

What does no preemption mean?

A

resource released only voluntarily by the thread holding it

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

What is circular wait?

A

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

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

What are 3 methods to avoid or recover from deadlocks?

A
  • Prevention (ensure one condition does not hold)
  • Avoidance
  • Detection and recovery
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

To prevent circular wait, we enforce that each thread requests resources in a ________ _______. We impose a _______ ________ on all resource types

A

consistent order, total ordering

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

To prevent hold and wait, we acquire ____ locks ___________

A

all, atomically

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

A disadvantage in preventing hold and wait is that we must know which locks to acquire in ________ and it decreases _________

A

advance, concurrency

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

To prevent no preemption, we make processes that fail to get a lock _____ __ all already-holding lock and _______

A

give up, retry

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

To prevent no preemption, we can specify a _______ for a thread if it does not get all its locks

A

timeout

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

Preventing no preemption can cause a __________, where all threads are __________ steps

A

livelock, repeating

17
Q

To solve a livelock, we can add random ______ between retries

A

delays

18
Q

To prevent mutual exclusion, we can use ________ algorithms using ______ instructions

A

lock-free, atomic

19
Q

Lock-free algorithms may achieve high ________ and prevent creation of ________, but are very ____________, as threads must handle data races explicitly

A

performance, deadlocks, error-prone

20
Q

Avoiding deadlocks by scheduling works in 2 steps. What are they?

A
  1. Know which locks might be requested by which threads

2. Schedule threads in a way that guarantees no deadlocks can occur

21
Q

A disadvantage of avoiding deadlock by scheduling is that it requires _______ _______ about all participating threads and resources

A

global knowledge

22
Q

Review deadlock avoidance slides

A

Review deadlock avoidance slides

23
Q

A disadvantage of avoiding deadlock by scheduling is that it can possibly _______ the time needed to complete jobs

A

increase

24
Q

A _______ and ________ solution allows deadlocks to occur, then take actions to resolve it

A

detect, recover

25
Q

In detect and recover, a deadlock _______ runs periodically

A

detector

26
Q

In detect and recover, a possible deadlock detector maintains a _____ that summarizes _________ and check for _______

A

graph, dependencies, cycles

27
Q

In detect and recover, once a deadlock is detected, the system can _____ system or ______ some threads/victims

A

restart, preempt

28
Q

Detect and recover is common in _______ _______

A

database systems