DEADLOCKS Flashcards

1
Q

What is a deadlock?

A

A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting in both programs ceasing to function.

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

Illustrate the occurrence of a deadlock

A

*See notes for illustration

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

Differentiate between starvation and deadlock

A

Research babe ;)

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

What are the conditions that are necessary for a Deadlock to occur

A
  • Mutual Exclusion- A resource can only be shared in mutually exclusive manner. It implies, if two process cannot use the same resource at the same time.
  • Hold and Wait- A process waits for some resources while holding another resource at the same time.
  • No preemption- The process which once scheduled will be executed till the completion. No other process can be scheduled by the scheduler meanwhile.
  • Circular Wait- All the processes must be waiting for the resources in a cyclic manner so that the last process is waiting for the resource which is being held by the first process.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are some strategies for handling deadlock

A
  1. Deadlock ignorance
    2.Deadlock prevention
    3.Deadlock avoidance
    4.Deadlock detection and recovery
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe deadlock ignorance

A
  • Most widely used approach.
    -Used mainly for a single end user system where the user uses the system only for browsing and all other normal stuff.
    -In this approach, the Operating system assumes that deadlock never occurs. It simply ignores deadlock.
  • There is always a tradeoff between Correctness and performance.
    The performance of the system decreases if it uses deadlock handling mechanism all the time if deadlock
    happens 1 out of 100 times .
  • In these types of systems, the user has to simply restart the computer in the case of deadlock. Windows and Linux are mainly using this approach.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe deadlock prevention

A
  • Deadlock happens only when Mutual Exclusion, hold and wait, No preemption and circular wait holds
    simultaneously.
    -If it is possible to violate one of the four conditions at any time then the deadlock can never occur
    in the system.
  • The idea behind the approach is very simple that we have to fail one of the four conditions but there can be a big argument on its physical implementation in the system.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe deadlock avoidance

A
  • In deadlock avoidance, the operating system checks whether the system is in safe state or in unsafe state at every step which the operating system performs.
    -The process continues until the system is in safe state. Once the system moves to unsafe state, the OS has to backtrack one step.
  • In simple words, The OS reviews each allocation so that the allocation doesn’t cause the deadlock in the system.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe deadlock detection and recovery

A

This approach let the processes fall in deadlock and then periodically check whether deadlock occur in the system or not. If it occurs then it applies some of the recovery methods to the system to get rid of deadlock.

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

Describe how to prevent mutual exclusion and give an example

A
  • Mutual section from the resource point of view is the fact that a resource can never be used by more than one process simultaneously which is fair enough but that is the main reason behind the deadlock.
    -The resource is thus made to function in a way that is not mutually exclusive
    -A good example is the spooling on a printer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the issues involved with preventing mutual exclusion specifically spooling

A
  • This cannot be applied to every resource.
  • After some point of time, there may arise a race condition between the processes to get space in that spool.
  • We cannot force a resource to be used by more than one process at the same time since it will not be fair enough and some serious problems may arise in the performance. Therefore, we cannot violate mutual exclusion for a process practically.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can one prevent the hold and wait condition?

A

-Hold and wait condition lies when a process holds a resource and waiting for some other resource to complete its task. Deadlock occurs if more than one process hold and wait in a cyclic order
-To prevent this a process must be assigned all the necessary resources before the execution starts. A process must not wait for any resource once the
execution has been started.

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

What are the issues involved in preventing hold and wait

A
  • Practically impossible.
  • Possibility of getting starved will be increases due to the fact that some process may hold a resource for a very long time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can one prevent no preemption

A

Deadlock arises due to the fact that a process can’t be stopped once it starts. However, if we take the resource away from the process which is causing deadlock then we can prevent deadlock.

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

What are some of the issues that arise when trying to prevent no preemption

A

-If we take a resource away which is being used by the process then all the work which it has done till now can become inconsistent.
-Consider a printer is being used by any process. If we take the printer away from that process and assign it to some other process then all the data which has been printed can become inconsistent and ineffective and also the fact that the process can’t start printing again from where it has left which causes performance inefficiency.

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

How can one prevent circular wait

A

-To violate circular wait, we can assign a priority number to each of the resource. A process can’t request for a lesser priority resource.
-This ensures that not a single process can request a resource which is being utilized by some other process and no cycle will be formed.
-This is practically possible