ALL > Computer and Education > courses > university courses > graduate courses > modern operating system > ZSTU-(2019-2020-2) Class > student directories > Deep L20192E060107 >
Homework 03: write a review paper about OS deadlock, submit one choice question for the exam database and one dialog for self tutor. Version 0
👤 Author: by shekhdeepgmailcom 2020-05-17 12:47:41
What is Deadlock?

Deadlock is a situation that occurs in OS when any process enters a waiting state because another waiting process is holding the demanded resource. Deadlock is a common problem in multi-processing where several processes share a specific type of mutually exclusive resource known as a soft lock or software.

Example of Deadlock:

  • A real-world example would be traffic, which is going only in one direction.

  • Here, a bridge is considered a resource.

  • So, when Deadlock happens, it can be easily resolved if one car backs up (Preempt resources and rollback).

  • Several cars may have to be backed up if a deadlock situation occurs.

  • So starvation is possible.


How to avoid Deadlocks

Deadlocks can be avoided by avoiding at least one of the four conditions because all these four conditions are required simultaneously to cause deadlock.

  1. Mutual Exclusion: Resources shared such as read-only files do not lead to deadlocks but resources, such as printers and tape drives, require exclusive access by a single process.

  2. Hold and Wait: In this condition, processes must be prevented from holding one or more resources while simultaneously waiting for one or more others.

  3. No Preemption: Preemption of process resource allocations can avoid the condition of deadlocks, where ever possible.

  4. Circular Wait: Circular wait can be avoided if we number all resources, and require that processes request resources only in strictly increasing (or decreasing) order.


Handling Deadlock

The above points focus on preventing deadlocks. But what to do once a deadlock has occurred. The following three strategies can be used to remove deadlock after its occurrence.

  1. Preemption: We can take a resource from one process and give it to others. This will resolve the deadlock situation, but sometimes it does cause problems.

  2. Rollback: In situations where deadlock is a real possibility, the system can periodically make a record of the state of each process and when a deadlock occurs, roll everything back to the last checkpoint, and restart, but allocating resources differently so that deadlock does not occur.

  3. Kill one or more processes: This is the simplest way, but it works.


 

Please login to reply. Login

Reversion History

Loading...
No reversions found.