 Hello friends, I am Mr. Ajit, assistant professor from Balchank Institute of Technology, Sallapur. Today I am going to discuss about dreadlocks in operating system. Now the objectives are, we have to understand the concept of dreadlock and the required conditions to create dreadlock in the processing. The primary goals are processes and their states, system model followed by the operating system, concepts of dreadlock and conditions responsible to create dreadlock. Now what is process? Process is an instance of computer program is being executed currently. Normally process has about two states. The first is running state and second is the wait state. Now in running state the process is supplied to CPU. It is acquiring all the required resources for execution and the process is executed by the CPU. And second is the waiting state. There are some cases where the processor does not find required resources available. So in that case CPU forces that process from running state to wait state. This one more term is coming here is called multiprogramming. That is multiprogramming. Now in this case the CPU is going to execute number of processes at the same time. Now what are different resources required by a process for execution? Now during execution the process normally require memory, some devices, some IO devices and a CPU. So we have to carefully share all these resources between the processes. Now normally all the process when it get for execution in the CPU, he follows one system model. So for example one process required some resource. So when that process stated for execution and he suppose want some resource for use. So he first request the resource towards the operating system. Now operating system give the control of this resource to the process if it is available. It is suppose not available then process has to wait. Suppose process find the required resource from the operating system. Then he will use that resource for its execution. And after some time means when he complete the process he will again give back the control of that resource back to the operating system. Now here one case is to be remembered the process cannot snatch the resource from other process forcefully to make himself executed from the CPU. So forceful getting resource for use is not allowed. What is deadlock here? If you see carefully from the diagram here that two processes P1 and P2. Now P1 is having a resource one is allocated already by him and whereas P2 is having resource number two. The darker arrows are showing that the resource one is allocated to process P1 already. And P2 is held by resource number process number two. Now for P1's execution the P1 require one more resource that is resource two which is held already by P2. And whereas the P2 also want one more resource for its execution that is resource number two. Now in this case you will find that both processes are waiting to get the other resources for execution. So in this case no process get executed and this kind of situation is called as a deadlock. Now therefore conditions are necessary to create deadlock. The first is mutual exclusion. Second is hold and wait. Third is no preemption. And fourth is circular wait. Now we will see one by one what is the meaning of mutual exclusion. Now this is a case where suppose there are two process are waiting for getting resource to be used here. So when one process is using one resource then other process has to wait because the resource which is available is not shareable. For example a case of printer. Suppose some process use printer for printing here. So in that case other process has to wait. The second condition which is necessary is hold and wait. Now hold and wait is just like human behavior because we know here whenever the things become available to human we grab that and wait for other things to become available here. Similarly the process suppose want to get executed. He will first find the required resources available. He will hold that process hold that resource with him and wait for other resources to become free. And after that he will execute himself. The meaning is that when process become ready for execution he will grab all the required resources available and wait for remaining to become available. Now next is no preemption. For example when process is executing himself and suppose another process want his resource for its execution here. Now in that case the other process is not allowed to stop the first process forcefully. That is he has to wait until the first process complete and then he will get resource released by the first process and then he can start his execution. Let us see some example here. Now actually to create deadlock here we have to create all these conditions simultaneously. That is all these above mentioned conditions should be there occurring at the same time. Just see the example here in my diagram. You are seeing the three processes P1, P2 and P3. Naturally P1 is waiting for resource to release from process P2 here. Similarly the process P2 is waiting to get resources from P3. Now can you say that in this condition can we create deadlock here? Just think a moment here. Now in this case deadlock is not possible. Let us see what happens here. Now we know here the P3 is having its resource available to him. So after some time you find that P3 execute himself completely. Then he will allocate its resources to process P2 and then the process P2 is going to execute himself. And then he will release the resource held by himself to the process P1. That is in this way after some time you find that the process P3 will execute initially then P2 and P3. Sorry P2 and P1. That is in this case we will not find any kind of deadlock there. Now what is the condition required to create deadlock here? Now in this case I just modify the diagram slightly here. Now in this case P1 waits for resource from P2. P2 waits for resource from P3 and P3 waits for resource from P1. Now in this case we are having some loop is present here. It is normally called a circular weight condition there. Just see what happens in this one. Now in this case P2 will not get executed unless P3 is executed here. But we know here P3 is also waiting for getting resources to be released by process P1 here. Now in this case you will see that any of the processes available is not executed at any time here. Now this is the condition we call as a deadlock here. That is we can summarize here that to create deadlock there should be four conditions should be available. First is mutual exclusion. Second is hold and wait. Third is no preemption. And fourth is circular wait. One more thing is that to create deadlock in the system these conditions should be present at the same time here. If anyone is not available they will not be a deadlock here. Now in this we can have the questions like describe deadlock in operating system and describe four required condition responsible for creating a deadlock. These are my references. Thank you friends.