Dining Philosopher problem (semaphore )

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video we are going to discuss about the 19 philosopher problem initially we have a table and a set of five plates and a fork lying next to each plate on the table next we have five philosophers whose only work is to keep thinking or feel hungry and eat there are a few problems associated with the situation they are starvation and the deadlock so what is the starvation and deadlock starvation is a situation where one philosopher never gets the chance to eat thus he eventually stops and dies deadlock is a state where one philosopher is waiting for the other philosophers to complete eating and the other philosophers in turn are waiting for the first one to complete eating thus forming an unending cycle one of the solutions for this problem is called the conductor's solution this solution introduces a waiter or a conductor to arbitrate philosophers must ask his permission before taking up any Forks because the waiter is aware of how many folks are in use he is able to intervene and prevent the deadlock we implement the conductor as a semaphore to further simplify the logic we implement a rule to request folks say write folk before left for or vice versa consider that the philosophers are labeled clockwise from A to E if a and C are reading for folks are news B sits between a and C so has made a folk available whereas D and E have one unuseful between them suppose D wants to e when he wants to take up v for deadlock becomes likely if instead he asked the waiter and he's told a way we can be sure that the next time two folks are released they will certainly be at least one philosopher who could successfully request a pair of folks therefore deadlock cannot happen I know you guys must have found the previous lecture learning philosophers quite morning and I wouldn't leave you these things are quite hard to understand but I have a solution who better Kristen any philosopher problem and the knighting philosophers themselves let's go meet them these are regular surfers as you can see there are five of them and I have five plates with exactly two fours around each player now the dining philosophers have only two cares in the world they think as i doing now and they get hungry they eat the philosophers don't care about the other philosophers the hungry they pick up that fork and they eat there is just one room they need both faults at any point of time if they're supposed to eat with 1/4 they cannot eat now this could lead to a variety of problems as we shall soon see one of these problems is the case of deadlock suppose also if I could also first were to get hungry at exactly the same time and pick up the right foot this seems to be a problem is it there none of them have their left folks none of them can eat and you see a solution to this problem no there isn't none of them are going to drop the right force tension of them I'm going to pick up the left hook eventually the philosophers are going to start now getting hungry getting tired eventually all right we have 5 10 tiny philosophers because all of them figure the right book at the same time they lock has scales not philosophers one more problem we could face with London scenario is that of starvation let's see what's going on philosophers 1 & 3 find themselves hungry these are eating and when they drop their phones the remaining philosophers 3 & 5 start eating we also / 2 is still thinking at this point you'll also verse 3 and 5 are now satisfied they rocked efforts look what was getting hungry but it's right for him to being taken back to 0 1 1 & 4 are now some it is have to get back to thinking but also for to seems to be getting a little worried now he's getting hungry whenever a an opportunity to eat with both folks riveting philosophers 1 3 4 & 5 seem to be quite satisfied or if it also were to have to wait a bit of trouble now as we can see philosopher 2 is no snarling because the remains of us are giving him an opportunity to eat it all suffered two eventually dies this is the problem of salvation another situation in which we could have starvation of tiny plus a purse this is one or two us first get Philly PD he decides that he's hungry and he started objection for a while you think you got enough people austere sports but he doesn't want to think you want to get back to leaving as you can see philosopher five-year never learn operative access is left for and philosopher who the the mother nice opportunity to access his right foot the Lebanese philosophers three and four or five plus for one order of chess book but is greedy seconds hungry again you want a scuffle philosophers two and five seem to be starving let's see what the end result of this could be I can see lots of good one the other one really really healthy operating from one philosophers two and five are dead since you have disgusted any philosopher problem but lower detail let's look at a solution this solution was proposed a long time ago known as a conductor solution if it was our first on exactly the same they make the request as before the only difference is that I a partner is present at oak oversee this any philosopher if he wants the right book it is his right hand I then have to grant him permission to pick up that for it is his left hand is requesting the left book and I have to grant him permission to pick up that for no philosopher can pick up our for without my permission let's see how this works out you'll also for one request arrives for I got into it another one request of left for I grant that to him as well and he sat ceilings meanwhile plus over three equals his life for granted it was stressful give it plus or five at this point is a question aside for I choose to be polled wait until one of them is done eating and then granted philosopher one seems to be done so I grant five his left foot as we can see things are proceeding quite peacefully and all are fine cross the first are still alive we notice that all of my possible was still alive when we left them but doesn't really solve the problem of deadlock as we remember the five learner first four into a state but neither of them could eat when all of the requested the rightful does this solve this problem let's see what another person appreciated - I got it - one egg Monday - five I got it is food and I've also collected three for every forward to pull on the fourth one as you can see this is tomato deadlock and now it was abruptly can begin eating when he is done eating - 10 G's + / - is done proper Pankaj multiple one answer five ensure visibility and the floor four five is done I got both sports Plaza for believe all the dining philosophers well aligned and benefit you now philosophers are done eating and thinking they seem to relax and the mood to party Percival - hey whooping come star you system
Info
Channel: aynesh
Views: 62,813
Rating: 4.8436017 out of 5
Keywords: Operating System (Algorithm Family), Deadlock, semaphore
Id: M3CNoX8wetM
Channel Id: undefined
Length: 10min 44sec (644 seconds)
Published: Sun Nov 10 2013
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.