Dining Philosophers Solution using Monitors
Вставка
- Опубліковано 9 вер 2024
- Operating System: Monitors
Topics discussed:
1. A Solution to the Dining Philosophers Problem using Monitors.
Follow Neso Academy on Instagram: @nesoacademy (bit.ly/2XP63OE)
Follow me on Instagram: @jaiz_itech (bit.ly/2M3xyOa)
Contribute: www.nesoacadem...
Memberships: bit.ly/2U7YSPI
Books: www.nesoacadem...
Website ► www.nesoacadem...
Forum ► forum.nesoacad...
Facebook ► goo.gl/Nt0PmB
Twitter ► / nesoacademy
Music:
Axol x Alex Skrindo - You [NCS Release]
#OperatingSystemByNeso #OperatingSystem #ProcessSynchronization #Monitors
Thank you very much, you guys have been our constant support to pass my exams every semester!! Love you Neso Academy
you are a lifesaver...in the world of operating system
You are superb teacher 👍👍👍
You make me motivated to complete that very big book like galvin 😁😁 ty so much
Thank you so much for the step by step explanation
Thank you. Well explained
Thx for a video. One question: will that solution let us make all of philosophers eat in the correct time? I mean if simultaneously odd and even ones can eat not to die?
Watching one day before exam
Very clear explanation
great explaination
Shouldn't putdown(i); come after test(i); in pickup function? Cus in this logic nothing is calling the putdown function
you will use those functions in your main code then you can call each functions however u need
Bro this is pseudo code those are just functions
well done
thnk u
plz complete data structure playlist
agree
Nice Explanation Great Work
you're awesome
awesomme
Pls someone explain (i+1%5)
How does the putdown function work when testing the next left and right philosophers? The test function requires that the current philosopher is hungry but we never got to change the state of that current philosopher to hungry?
We only got to change the current philosopher's state to hungry in the pickup function, so how can the current philosopher be hungry in the putdown function?
@@bronwyndrummer8326 Let's say we are calling putdown function for philosopher 1; we are setting its state back to thinking. Fine so far?
Now since it is putting its chopsticks his left and right philosopher can eat now, we are calling test function on them. For ex, when we call test ((i+4)%5), the parameter of the test function is index of right philosopher, not the current one. Is your confusion because we are checking the state of i as hungry in the test function? if yes, please check the basic function concepts. When executing the test function, i is actually the right philosopher's index, not the current one.
@@SajidAli-ub6th
Yes I am a tiny bit confused because let's say Philosopher 1 initially wanted to eat. So his state is set to hungry when he picks up the chopsticks.
When he is done he will put them down and the putdown function will test the philosopher to the right of him. The test function requires him (the philosopher that was on the right) to be hungry. But in the putdown function did not allow him to change his state to hungry as of yet. That only happens in the pickup function? So to my understanding that test function would evaluate to false for this philosopher because he never got to change his state to hungry yet?
@@bronwyndrummer8326 I have the same question. Also, I remember philosopher dinner only allows one philosopher to eat at a time, so if we test the left and the right both, will it result both of them can eat together?
When will be putdown function called?
After eating
I have main function
The code makes sense, but I don't understand how and where initialization-code is run or the monitor is accessed?
Whenever a process (philosopher) wants to eat they would call the two functions (pickup and put down).
Initially assume all are hungry then it start clearly what code will do
6.33
test function{
if( i==1 )
state[(i+4)]!=eating) and state[(i+1)%5]!=eating
else if(i==4)
state[(i+4)%5]!=eating) and state[(i+1)]!=eating
else
state[(i+4)%5]!=eating) and state[(i+1)%5]!=eating
}
you have to remember that in an array, the first variable in the array is considered item 0 rather than item 1. meaning the array would have [0, 1, 2, 3, 4] therefor, the original solution is actually correct.
This code is actually saying that only philosopher with i=1 can eat except other philosopher 0,2,3,4😂😂😂
First!