Introdution

  • Generally, file resources when shared as read-only, never lead to deadlock condition.

Definition

  • The deadlock is a situation of an operating system in which no process got blocked and no process proceeds.
  • A deadlock is a situation where each of the computer process waits for a resource which is being assigned to/used by some another process at the same time. In this situation, none of the process gets executed since the resource it needs, is held by some other process which is also waiting for some other resource to be released.
  • Deadlock is a situation that occurs usually in a multitasking/multi processing operating system where several processes share a specific type of mutually exclusive resource.

Characteristics

  • Deadlock is an infinite process.
  • Every deadlock shows starvation situation.

Conditions for Deadlock

There are four typical or necessary conditions for deadlock . These are –

  • Mutual Exclusion(Mutex) :
    • It is a special type of binary semaphore which is used for controlling access to the shared resource.
    • It assures that a resource can only be shared in mutually exclusive manner to avoid deadlock i.e. two or more processes cannot use the same resource at the same time.
  • Hold and Wait :
    • In this method, generally a process waits for some resources (that it wants to use further)while holding and use another resource at the same time.
  • No preemption : 
    • In this method, the process once scheduled will be executed till the completion. At that time, no other related processes can be scheduled by the scheduler.
  • Circular Wait :
    • All the processes in the process queue 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 and so on.
    • In another words, circular wait is a situation in which one process is waiting for the resource, which is held/use by the second process, which is also waiting for the resource held/use by the third process and so on. This will continue until the last process is waiting for a resource held/use by the first process. This constitutes a circular chain and finally circular wait condition.

Advantages

  • To run an operating system smoothly.

Disadvantages

  • It delays process initiation.

Handling of Deadlock

There are following ways to handle a deadlock situation in an os –

(a) Deadlock Ignorance :
  • In simple case, deadlock Ignorance is the most widely used approach among all the mechanism by many operating systems mainly for end user uses.
  • In this approach, the operating system assumes that deadlock never occurs or ignorable.
  • This approach is best suitable for a single end user system where User uses the system only for browsing and all other normal work.
  • To get rid of simple ignorable deadlock, the user may simply restart the computer system . 
(b) Deadlock Detection & Recovery :
  • A deadlock detection is a method to find out whether deadlock occurred in an operating system or not.
  • This is done by checking the status of the resource scheduler that helps OS to keep track of all the resources which are allocated to different processes during execution time. If single resource is allocated/used/shared by single process at a time then deadlock did not occur.
  • When a deadlock is detected in a system then it applies some of the recovery methods to the system to get rid of deadlock.
(c) Deadlock Prevention :
  • Deadlock prevention is a method to do all those related activities that try to remove deadlock situation after it occurrence.
  • It is better to prevent a deadlock before it can occur.
  • In this method, the system checks every process (with its allocated resource) before it is executed to make sure that it wouldn’t lead the deadlock situations.
  • In deadlock prevention, all the four conditions for deadlock is checked and managed.
(d) Deadlock Avoidance :
  • Deadlock avoidance is a precautionary/earlier method to do all those related activities that try to prevent deadlock situation before it occurrence.
  • It is better to avoid a deadlock instead of taking action after the deadlock has occurred. 
  • Deadlock avoidance is the simplest and most useful model that each process declares the maximum number of resources of each type that it may need.

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.