 I am Arjun Gundale from Department of Electronics. Now these are objectives of this video that we must be able to describe different methods of deadlock handling and describe deadlock start with the basics, a process. Process is a program under execution. Now whenever CPU sedates a process for execution, the process normally requires some resources and these resources are granted by the operating system for its execution. Now following are some of the resources may require by the process for the execution. First is the CPU, then the memory, IO devices, for example printers and the scanners and external devices which are put on IO boards. Now out of these resources mentioned here, some are shareable and some are non shareable. For example, CPU can be shareable because we can process two process at the same time on the CPU but whereas the devices like printers and the scanners are not shareable because once we start the printing, we can't hold the printing process in between and we can not allocate this printer to the other process so that the system takes at most care while allocating these resources to different processes. Now this one more thing is very essential in the operating system, a deadlock. I can define this deadlock as it is a situation in which two computer programs sharing the same resources and effectively preventing each other from accessing the resource. If you see carefully the diagram on the right hand side, the P1 is holding resource 1 whereas the P2 is holding the resource number 2. Now process number 1 require one more resource that is resource 2 for its execution but is already held by process P2 whereas process P2 requires resource 1 for its execution and which is already hold by process P1 so that the process P1 and P2 are not able to execute their task that is they are ceasing each other's execution in the process. This condition is normally called as a deadlock and in the operating system we have to take at most care to avoid such kind of deadlocks because that is halting all the system. Now there are four required conditions to create deadlock in the system. The first is called mutual exclusion that is it mean that only one process at a time can use the resource because we know there are resources which are non-sharable so that once some process start its use of the resource the other should not take it for the working there. Second is the hold and wait. The process may hold allocated resources while awaiting for more. This one more condition is essential is that there will be no pre-emission in between. That is the other process should not release the resources hold by one process forcefully. And last is and at most important is circular weight. A closed loop is existing in the processing such that the process holds at least one resource treated by other process or the next process. So that process has to wait until the resource is made available by other process in the system. All these four conditions should be occurring simultaneously and they should be occurring at the same time. And these are the required and sufficient condition to create the deadlock. Policies we are using the first is deadlock prevention. Now in this policy it is work on this policy here. This allow one of the four required condition. Second is deadlock avoidance. So we are going to avoid the unnecessary requirement by the processes leading to deadlock. Then this one more method is deadlock detection. Now like in this method whenever process require a resource the system allocate resources to that process here. But at the same time the operating system check for deadlock in the system regularly. I suppose that finds the deadlock in the system so that he will take the resource allocated to that process once again. And finally we get one more policy is used here is ignore the problem here. Now there are some conditions are in the system where deadlock is quite rare to occur. So in that case we are never going to consider about the condition that is deadlock here. So in this case we are going to ignore the deadlock condition. Let us focus more on deadlock prevention there. As I said here eliminate one of the four conditions that creates deadlock here. The first is mutual exclusion here. Now in this case as I said here I cannot stop process in between and I cannot allocate the resource to the other. Second is hold and wait. Naturally to avoid deadlock here we have to make this condition false. So normally we adopt following steps here in the system. The first step says that only selected process for execution can initiate the resource request here. As we all know here the process can initiate a request of resources at any time. But in this case when Cp is any process for execution only that process can raise the request of resource request here. So that it will reduce the context between number of process to request for resources there. Second is only those process can be allowed to raise resource request who are currently holding zero resources here. And finally suppose some process is holding some resources here and he wants some more resources for execution in the future. So it is only allowed to require or raise the request only when he first releases his all resources to the system. And then he can initiate a fresh request in the system there. So in this way we are going to avoid this case which is called the hold and wait condition there. Then this one more condition which lead the deadlock here which is called no preemption. So we have to make this condition false means we have to make preemption possible there. Just see what the first step says that whenever some process holds the resources and waiting for some more resources in the recent future here. In that case we say that to the system or the process that he first release all the processes or all the resources held by that process first. And then he can go for the fresh request here. This one more thing is very essential is called deadlock prevention. Now in this deadlock prevention we use a circular weight as a main condition. That is in this method what we do we are going to give some sequence numbers to all the devices all the resources available here. For example if a number cps number 1 memory could be 2 printer s3 and the devices on the IO side may be up to n here. Now in this method we put rule here that is every process can request a resource when required only in the increasing order. That is 1, 2, 3, 4, 5 like this here but not as some example 1, 3, 2 and so on here. Now can we remove this deadlock here by only sequencing the devices. So we can explain this situation by taking some example here. So example the again the process shows here there are 2 processes P1 and P2. P1 is holding resource 1, P2 is holding resource number 2. Now P1 expect resource number 2 for execution whereas P2 require resource number 1 for its execution. As I said here we number resources as number resource 1 and resource number 2. Let us see a case of P1 here. Now P1 already holds the resource 1 and he want resource number 2. So he can raise the request in the system because the P1 holds resource 1 and expect resource number 2. So number 2 is greater than number 1 here so it is allowed here. Whereas the process P2 is holding resource number 1 and the process to require resource number 1 for execution. So in this case P2 is not allowed to raise the request here because already P2 has got resource number 2 and he expect resource number 1 for execution here that is not satisfying the condition. That is resource number 2 only can demand the resource 2 onwards here that is resource 3, 4, 5 like this here. Just see what is the use of this case here. So in this case we see that the system is avoiding the looping here. That is we can avoid the circular weight in the system here that is going to avoid deadlocks here. This one more thing is available to deadlock prevention here or deadlock handling I can see here. It is called deadlock avoidance here. Now in this case the maximum requirements of each resource may be stated in advance. That is we force processors to define requirement in advance here and we use two following conditions to control this deadlock here. Suppose a process defines that he want 10 resources for the execution. But system always confirm that after allocating these 10 resources can we avoid deadlock here. It is suppose possible he will allocate here otherwise he can defer. That is suppose the 10 resources can create deadlocks in the system the OS will not allow this resource allocation here. And secondly this one more way of prevention is that do not grant incremental resource allocation that leads the deadlock here. So in this way we are going to avoid deadlock occurrence references. Thank you friends.