Skip to main content

DeadLock In Operating System

      ⇰  DEADLOCK :-

As we know in a multiprogramming environment several processes may compete for a finite number of resources. If a process requests resources and if the resources are not available at that time, the process enters a state called  waiting state. Sometimes, a waiting process is never again able to change state or never out from waiting state, because the resources it has requested are held by or taken by other waiting processes before this process.This situation is called a Deadlock.


    ⇰  DEADLOCK CHARACTERIZATION:-

In a deadlock processes never finish executing and system resources are tied up  and also  preventing other jobs from starting. Here are some features that characterize deadlocks. A deadlock situation can arrive if the following four conditions hold simultaneously in any operating system :-

1. Mutual exclusion :- A process must hold at least one resource in a nonsharable mode so that only one process can use the resource at a time. If another process requests that resource, the requesting process must be delayed until the resource has been released.
System Software Mutual Exclusion Techniques


2. Hold and wait :-  A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes.
Deadlock Prevention And Avoidance - GeeksforGeeks


3. No preemption :- Resources cannot be preempted means a resource can be released only voluntarily (when procss want) by the process holding it, after that process has completed its task.
Operating Systems: Deadlocks


4. Circular wait :- For this condition  a set {P0, P1, ..., Pn} of waiting processes must exist such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, ..., Pn−1 is waiting for a resource held by Pn, and Pn is waiting for a resource held by P0 ,making a circular chain of waiting processes.

CS 111: Lecture 10 Scribe Notes - Spring 2014


⇒   To ensure that deadlocks never occur, the system can use either a deadlock prevention or a deadlock-avoidance scheme. Deadlock prevention provides a set of methods to ensure that at least one of the necessary conditions cannot hold. Deadlock avoidance requires that the operating system be given additional information in advance concerning which resources a process will request
and use during its lifetime. 


    ⇰  DEADLOCK PREVENTION :-

As we know for deadlock to occur, each of the four necessary conditions must hold.We can prevent the occurance of deadlock by ensuring that at least one of these conditions cannot hold. Let us examine of the four necessary conditions separately :-

  Mutual Exclusion :- For deadlock to occur mutual exclusion condiyion must hold means atlest one resource must be in non- sharable.Sharable resources do not require mutually exclusive access and thus cannot be involved in a deadlock. Read-only files are a good example of a sharable resource. In general we cannot prevent deadlocks by denying the mutual-exclusion condition, because some resources are intrinsically nonsharable.

 Hold and wait :- To ensure that hold & wait condition never occurs in the system, we must guarantee that, whenever a process request a resource, it does not hold any other resources. One protocal that we can use require each process to request and bew allocated all its resources before it begins execution.
    An alternate protocol allows a process to request resources only  when it has non.A process may request some resources and use them. Before it can request any additional resources, it must release all the resouces that it is currently allocated.


 No preemption :- This is the third condition for deadlkock to occur , says no preemption of resources that have already been allocated. To mensure that this condition does not hold, we can use some protocole. As if a process is holding some resources and request another resource that cannot be immediatly allocated to it, then all resources from this process are preempted. The preempted resources are added to the list of resources. The process will be restarted only when it can regain its old resources as well as the new once that it was requesting.


 → Circular wait :- This is the forth and final condition for deadlock to occur. One way to ensure that this condition never holds is to impose a total ordering of all resource types and to require that each process requests resources in an increasing order of enumeration.

Deadlock in Operating System | Lecture Notes in Computer Science
Share, Follow and please comment if you find anything incorrect, or to share more information about the topic discussed above.

Comments

  1. Short and simple!!!! Excellent Bro

    ReplyDelete
  2. Replies
    1. I am preparing for that. You will got posts soon on that topics.

      Delete

Post a Comment

Please comment.

Popular posts from this blog

Process Scheduling And Types of Process Schedular :-

        ⇰ PROCESS SCHEDULING Process Scheduling  is a task  of Operating System that schedules processes of different states like new, ready, waiting, terminated  and running.This scheduling helps in allocation of CPU time for each process, and Operating System allocates the CPU time for each procss. And the process scheduling plays important role to keep the CPU busy all the time.  ⏩   Followings are some objectives of Process Scheduling :-  i > To increase the amount of users within acceptable response times.  ii > To maintain the balance between response and utilization of system. iii > To decrease the enforce priorities and  give reference to the processes holding the key resources.      ⇰  PROCESS SCHEDULAR A scheduler carries out the pro cess scheduling work. Schedulers are often implemented so they keep all computer resources busy and  allows multiple users to share system resources  to achieve  multiprogramming .  There are  mainy three types of pro

Tokens and its types in 'C'

   Tokens are the smallest individual unit of a program or in simple words it is a main part of C program.Tokens are the building blocks of any program. The smallest individual and basic unit of a C programming is called c tokens.      *    Normally there are six types of tokens in C:- i> Keywords:-          Keywords are special words that are used to give a special meaning to the program and can't be used as variable and constant.They are basically a sequence of characters that have fixed to mean. For example:-                 auto     double      long     break                 float    short        char     if                while    continue   int       void etc. All keywords must be written in lower case.It is 32 in number. ii> Identifiers:-         The identifiers are basically a token. It can be a variable's name or a label's name. So identifiers are actually a user defined data. But there are certain rules to frame an identifier. They are as follo

Process & Its state And process control block :-

                ⇰  PROCESS :- A process can be thought of as a program in execution. Means when any program is executed it becomes process. A processwill need certain resources such as CPU time , memory, files and I/O devices to complete its task. These resources are allocated to the process either when it is created or at the time of execution.             A process is the unit of work in most systems. A system consistes of a collection of processes. All these processes may execute concurrently. Traditionally a process contained only a single thread. Most modern operating ststems now supports processes that have multiple threads.         The operating system is responsible for several important works of process management as - the creation and deletion of process, the schrduling of process, communication and deadlock handling of process. Process is broudly divided into two types:-  i> System  Process. ii> User Process. Early computers allowed only one program be ex