Week 9: Deadlocks Flashcards

1
Q

What are shared resources?

A

Resources shared by processes, classified as:
- Physical (e.g., processor, memory, I/O
- Logical (e.g., data structures, message queues).

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

What are reusable and consumable resources?

A
  • Reusable: Not destroyed by use (e.g., memory, processor).
  • Consumable: Used up after one use (e.g., signals, messages).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the three main synchronisation problems?

A
  • Race conditions: two or more processes competing for a shared resource the result varies according to the order of process execution
  • Deadlocks: a situation where two or more processes are each waiting for resources held by others
  • Starvation: a process never gets access to a required resource
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a deadlock?

A

A situation where two or more processes wait indefinitely for resources held by each other, creating a cycle of dependencies.

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

What are the four conditions for a deadlock to occur?

A
  • Mutual exclusion: Resources cannot be shared.
  • Hold and wait: Processes hold resources while waiting for others.
  • No pre-emption: Allocated resources cannot be forcibly taken.
  • Circular wait: A closed chain of processes exists where each holds at least one resource needed by the next.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is deadlock modelling using directed graphs?

A
  • Processes are represented as circles.
  • Resources are represented as squares.
  • Arrows indicate allocation or waiting for a resource.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Scheduling choices can avoid or cause deadlock. A resource graph can be created & checked at each step. When is a deadlock guaranteed to happen?

A

When it contains a cycle, then there is a deadlock

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

What are the four strategies to deal with a deadlock?

A
  • Deadlock Avoidance: Careful scheduling to ensure safe states.
  • Deadlock Prevention: Alter system conditions to prevent deadlock.
  • Deadlock Detection and Recovery: Identify and resolve deadlocks.
  • Ostrich Algorithm: Ignore the problem if its occurrence is infrequent.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why must the OS keep track of the current state to avoid deadlocks?

A

To determine whether it is safe or unsafe

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

What is a safe state vs. an unsafe state?

A
  • Safe state: No deadlock and all resource requests can eventually be met.
  • Unsafe state: Deadlock may occur depending on process behaviour.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the banker’s algorithm?

A

A deadlock avoidance algorithm that evaluates resource allocation states to ensure safe system operation.

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

We have three 2D tables:
- Allocation table
- Max table
- Available table.

The Allocation table holds the amount of each resource each process is currently using.
The Max table holds the amount of each resource each process requires to finish.
The Available table holds the amount of each resource that is currently available for allocation.

For row=1 (the first row) we create a table Need that each row includes Max[row] - Allocation[row]

Then, for each row in the Need table, we check if Need[row] <= Available[row]. If no row satisfies this then the system is in an unsafe state. If a row satisfies this, then, Available += Allocation[row], and For each resource in Need[row] the amount becomes 0.

This is repeated until all the rows of Need have their resources of 0 amounts.

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