In: Computer Science
Operating Systems:
We have learned two methods for the Dining Philosophers Problem. Can you come up with other solutions? Make sure your solution works. Wrong solution does not count. (20 points)
plz check the below content.
page 2
page 3
No need to remember the just check the wait and signal logics once .
simplified answer plz check the below.
plz assume a table , it contains five philosopher.
every one is having two states 1.Think, 2.eat
void philosopher (void)
{
while (trw)
{
thinking ();
take_fork(i); // left fork
take_ fork(i+1)%N); // right fork , N is no.of forks
EAT();
put_fork(i);
put_fork(i+1)%N);
}
}
here we are using semaphores S0, S1 ,S2, S3, S4
for this we need to used wait and signal for the code process
wait(take_fork(Si));
wait(take_fork(S(i+1)modN));
signal(put_fork(i);)
signal(put_fork((i+1)%N));
plz use dead locks to understand.