Deadlock | Necessary conditions for Deadlock | Operating Systems

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
suppose very narrow street is there like this only one person can pass this street at one time okay now see suppose one person is coming from this side person p1 and second person is suppose at the same time coming from this side person p2 now the street is so narrow that only one person can pass the street condition is only one person can pass this trace can pass this street so here is p1 haze person p2 now the both the person got blocked neither p1 can go or neither p2 can go this side why so because they cannot share the street this street is non shareable only one person can use this this path this street at a time fine so here you can take P 1 and P 2 are that processes 2 processes and this street is what resource ok now P 1 is waiting P 1 is also waiting for this resource to be free and P 2 is also waiting for this tree to be free so both the processes are waiting and both the processes are waiting for which resource which is held by another waiting process so in this case there is no progress we cannot say for how much amount of time they will wait because the way they will wait for in finite amount of time because there is no progress for thus 9 neither 4 percent P 1 neither 4 person P 2 because they are just waiting there is no progress so in deadlock also this kind of situation is there you can say waiting for something for in finite time in which there is no progress for waiting processes in starvation also also we have discussed that waiting for in finite amount of time or you can say in definite blocking but deadlock is different from starvation in starvation we cannot say that there is no progress but in deadlock we say that there is no progress if this what is there no progress is there then this definitely there would be deadlock this condition is must means no progress must in starvation see because of higher priority processes are coming coming and coming low priority processes will you know wait wait for the CPU it's not getting the CPU but here progress is there means CPU is running some processes processes are coming and they're executing and they are going to terminate state progress is there but because of that priority case low priority processes are not getting the CPU fine CP R is not blocked but here here no progress would be there then there would be dead look if CPU got blocked see if you will not run any process then we can say that the low priority process will never get the CPU but here in this case in case of starvation maybe after 15 minutes after 1 hour after 2 RR or after 3 hour that higher priority processes will not come and ultimately that low priority process will get the CPU because of the progress only but if no progress case is there then definitely there would be deadlock so this this word is very important in deadlock no progress no progress means deadlock but you can say processes wait for one another section indefinitely here also you can say person P 1 is waiting for this P 2 is action and P 2 is waiting for P 1 section but these action can not occur that is why they have to wait the processors will have to wait indefinitely and that is the condition of deadlock let us take one more example suppose 2 children are there and they want to draw something and on one table one drawing book is there and 1 you can say a sketch pen or you can say pencil is there fine now they they both the children run to get the trying book and pencil now one child got this drawing book and one another child got the pencil fine one child suppose see one and here we have pens and see to what pencil now neither see one can draw something nor see two can draw something why so because see two only has pencil and see - is waiting for this drawing book and see one is waiting for this pencil and see one has only drawing book so both are waiting for resources which are held by some other waiting process we cannot say by some other process which are waiting for some which are waiting for resources which are held by some and other waiting processes see this one is also waiting this one is also waiting by and here no progress case is also there you can easily analyze that here also no progress cases there so if no progress is there in any situation then you can say ultimately there will be dead no so this no progress funda is very important now come to the point of operating system see basically deadlock comes in the operating system which are image multiple processes are running multiple processes are competing for some resources and multi plus multiple processes will be running maybe you know in multi programming operating system see we have discussed many types of operating system in that we do we have discussed what is multi programming operating system so we can say multi programming operating system many processes are there many processes are running and many resources are also there but resources are finite number of resources we cannot say if resources are in finite then obviously there would not be dead low and we don't have in finite number of resources we have some limited number of resources resources means your CPU memory i/o devices and all these are resources fine and these these processes are computing obviously these processes multiple processes are running then these processes will be competing for these number of resources fine now it's some time maybe one process p1 requester is any process p1 requestor the source if this resource is available then ultimately this resource will be allocated to this process but suppose this price this resource is not available it may be some other processes holding this resource or using this resource right now at this point of time this resource cannot be allocated to this process then this process will go into waiting state and this will be waiting for this resource fine maybe some other processes are also waiting for this resource and sometimes this process this process which is in waiting State or in waiting State there may be set of processes more than one process so sometimes these processes or you can say this process never again change its state it will always remain in waiting state and why so because this process is waiting for a resource which is already held by another waiting process another waiting process is there which is holding this resource and that process suppose p2 is also in waiting state which is holding this resource waiting means obviously this would be waiting some another resource something like this now this p2 is waiting for a resource again maybe this resource is again held by waiting process so if this kind of scenario is there then you can see this is deadlock now you can say when a waiting process never again have able to change its state because it is waiting for the resources which are held by some other waiting processes then this situation is known as deadlock one more point also you can it and you can this definition and there is no progress then ultimately there would be deadlock now I will discuss what are the four necessary conditions see I am saying only necessary conditions I'm not saying that necessary and sufficient condition condition you cannot say necessary and sufficient condition only these are necessary conditions or you can say for many conditions now four conditions are there we'll discuss those conditions also now these are the four necessary conditions for deadlock you can say Coffman conditions for deadlock one is mutual exclusion second one is Holden weight makes is no preemption and next one is circular weight so a deadlock situation will arise if all the four conditions held in the system simultaneously at the same time all the force conditions not only one only two are only three no one though all the four conditions are there then deadlock would be there in the system now what is this mutual exclusion in this case we can say at least one resource must be must be held in a non shareable mode means we cannot only only one process known share pure mode means only one process can use a resource at one time no two process can share the resource any other process wants that resource then that second process has to wait until the completion of the first process this is first condition mutual exclusion see we have taken the example of this that street narrow street so that is known shareable why you can say non shareable because only one person can pass through that street and what at one amount of a particular amount of time if both the person if two person can pass then that is you can say shareable and at that time there would not be deadlock so that is why this condition should must be hold in the system at least one resource would be there must be held in non shareable more now next next one is holding weight it means processes must be holding some resource and waiting to acquire some other resources that are currently held by some other processes it should not be a case that if you are holding some resource you cannot wait for or you cannot request for and the resources no they're holding maybe resources r1 r2 and you are waiting for the source r3 and r4 that should be a case hold plus wait you can hold some resources also process can hold some resource also and can wait or or request for another resources also third is no preemption I have discussed this preemption many times means forcefully you can remove something so no preemption means the resources cannot be preempted if one process is holding some resource we cannot forcefully take that resource from that process no preemption would be there see in case of that drawing book in pen may be forcefully from one child we we took the drawing book and give it to the second children then obviously there would not be deadlock but that should not be a case you cannot forcefully take any resource from a process no preemption case would be there and last one is circular wait circular way it means they are waiting in circuit only like suppose we have processes from five processes are there P 1 P 2 P 3 P 4 P 5 and P 1 is waiting P 1 is waiting for a resource and that resource is held by process P 2 P 2 is waiting for a resource that processes held by resource P 3 by process P 3 P 3 is waiting for a resource that is held by process P 4 and P 4 is waiting for a resource that is held by P 5 and finally P 5 is waiting for a resource and that resource is held by process P 1 so this is a circular wait condition so this would also be there otherwise deadlock would not be there fine so all these four conditions must be held simultaneously in a system then a deadlock situation arise fine so next video will discuss how to prove to handle the deadlock how to prevent how to avoid how to detect the deadlock how to recover the deadlock bankers algorithm and all fine so till then bye bye take
Info
Channel: Jenny's lectures CS/IT NET&JRF
Views: 78,391
Rating: 4.9318337 out of 5
Keywords: deadlock, dead lock, jennys lectures, jenny's lectures, jenny lamba, jayanti khatri lamba, jayanti khatri, operating systems, OS Computer Science, what is deadlock, what is dead lock, CS/IT, information technology, classes, technology, technical, engineering, engineering colleges, computer science classes, computer science youtube channel, computer science channel, necessary conditions for deadlock, OS, Data, Data Structure, Operating System Notes, OS Notes, UGC NET Computer Science
Id: x9FF723STvo
Channel Id: undefined
Length: 13min 14sec (794 seconds)
Published: Sat May 04 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.