 In this lecture, we are going to focus on the research allocation graph and deadlock detection. Friends, at this end of video, you are able to explain different components of resource allocation graph and you are also able to define or identify any condition which is available to create deadlock here. Now friends, I will start my video with this simple concept of process execution. So, process require help of different resources to complete its execution. So, when I invoke the process here, so I am going to raise a request of different resources to the operating system and this OS is going to allocate those resources to the process. Now, if running process get all the resources from the operating system, we can execute that process quite successfully. But suppose friend, if we do not get required resources from the OS, then I have to put that running process into the build state here and he is not able to get executed until I get required resources from the operating system. Friends, now we are going to use one different way of presenting the states of process here. In fact, we I use the graphical presentation to define the different states of process. The state of process is or we are having the process can be in either running state or waiting state there. So, it can show that process state here with the help of some sort of symbols there in the graphical notations there. So, friend I have introduced here one new concept called as a resource allocation graph. It is simply called as RAG that is resource allocation graph. Now, this RAG is a pictorial presentation of all the process states in the given system there. Just see which are the components here. So, friend I am showing I am going to show the process P1 by a circle and in that circle I am putting that P1 as a process name that is nothing but a process symbol there. Then I use a rectangle and I just use one dot here that is showing me the instances available in the resource here. So, currently I want to show here it is a R1 resource and it has got only one instance which is available to you. Now, also possible that friend here I can also got I can also can have a resource which is having two instances are possible. So, it is just like we got two resources means you got two printers or two scanners like this here. So, dot shows that number of that resource is available there. Now, I want to show one more symbol here that is the P1 is having a arrow which is ending towards R1 there. So, friend this is meaning that the P1 requires a resource R1 for its execution there. Now, in the counterpart this R1 is having arrow is going towards P1 there. It means that the resource R1 is allocated to process P1 there. So, friend I am going to use all these symbols to draw a resource allocation graph that decides a stage or the steps of the process execution there. And from this we get some get some knowledge there and from that knowledge we can talk about the system conditions there. Friend this is the symbol symbol RIG here that shows you so I got process P1, P2, P3 they are sharing some resources. So, in this diagram here this R1 has got one instance here R2 got one instance R3 got again two instances here. Now, the R3 instance is now given to the process P1 there. So, I call this as this Rth is allocated to process P1. Similarly, P1 require R1's help to execute himself here. So, the arrow is now coming from P1 and that goes to R1. So, P1 requires the resource R1 there to get executed. So, friend in this way we are going to read this graph here. Suppose if I say a case of the process P3, process P3 is allocated with resource R2 there and you do not require any additional resource here for execution. Now friend I can now discuss with the application of this RIG for finding the process condition there. So, I will say here resource allocation graph is used to predict whether system experiences deadlock or not. Friend deadlock is only available when you don't get required resource from the operating system and that resource is held by some other process here at that time and that is not ready to leave that resource there. So, this is a condition called as a deadlock condition there. So, this RIG is able to help me to find out that deadlock condition. Now we have applied some rules there. The rule one says that if there exists a closed loop in resource allocation graph there may be or may not be deadlock condition. So, first we have to find out whether loop is available or not there. Second if there is no loop in the given RIG we can confirm that in the given system deadlock will not be occurring there that is a good solution there. Now friend this is one of the example I took here. So, I can say that currently P1 is requiring R1, P1 is allocated with this R2 there and so on. Now whether we get any loop or not here. So, friend I can say here this arrow will start from this R2 here that goes to P1 goes to R1 goes to P3 again back to R2 here. So, this is this closed loop here. So, there may be a case of deadlock here, but we have to analyze that condition from the given graph here because loop does not mean that there is always a case of deadlock here just see what we can do. So, friend if you see close with this graph here this P4 and P2 will not require any resources to get executed here because what they require is already allocated by the operating system there. So, they can get executed directly. So, P1 P2 will get executed first here. Now after that they will release the resources R1 and R2. So, that R1 R2 can be given to some other process here. So, that the P3 can get executed then after this P3 execution here he will return all engaged resources back to this operating system here. And after that we are going to execute the P1. So, friend I can say that in all this example here we see that even we get some feedback loop here that does not mean that we get deadlock there. So, I can say that the loop indicates that deadlock may be there or deadlock may not be there. This is example in which I do not get any kind of deadlock here. Now I will take one more example friend here. Let us see what we changed here that is one more diagram here which is called as resource allocation graph and again if you see that again I got the same loop is available. So, if I start from this P1 goes to R1 goes to P2 then it goes to R2 then to P3 and back to R3 and back to P1. So, this is a loop case I can say. So, again rule says that deadlock may be there or deadlock may not be there. So, what we can do? So, friend I can say that in this RHE there may be deadlock or there may not be deadlock is available here. Just in this case you see that the process P1 needs R1 which is held by P2. Then process P2 needs R2 which is held by P3 and process P3 requires R3 and which is held by P1. So, friend these processes will not return resources until they get executed. You see that in this example all P1, P2, P3 are holding other resources and they are not ready to leave their resources to the operating system. So, friend in this case deadlock is bound to come. So, friend this is the example that shows that there is a presence of closed loop and here we are not able to execute any process right now so that the deadlock is available. So, friend I can say that from this given RHE we can say that deadlock is either available or not available. So, this RHE is quite useful to me to find without executing that system here regarding deadlock occurrence there. Friend this is my references for this video. I hope that this video is useful to you. You understand the concept of this RHE. So, thank you for listening my video. Thanks very much.