Page 1 of 1
Dining Philosopher Problem
Posted: Mon Sep 26, 2005 11:00 pm
by Velan
In Dining Philosopher problem, I have doubts in Semaphore. Which one of the following is better and suited for what?
1) Applying Semaphores for Other processes (i.e for Philosophers)
2) Applying Semaphore for Other Resources (i.e for Forks).
Re: Dining Philosopher Problem
Posted: Sat Oct 01, 2005 11:00 pm
by Legend
Well, do you want to use a semaphore that a philosopher has first to get before he can pick up a fork?
Or a semaphore per philosopher?
Re: Dining Philosopher Problem
Posted: Sun Oct 02, 2005 11:00 pm
by Velan
I have implemented both the methods.
1) Putting semaphore for all the forks.
2) Putting semaphore for every philosophers.
But only one mothod is possible at a time. I would like to which method to choose for efficiency and differentiate.
Re: Dining Philosopher Problem
Posted: Mon Oct 03, 2005 11:00 pm
by Legend
One semaphore for all forks ... as a result only one philosopher can eat at a time?
Re: Dining Philosopher Problem
Posted: Tue Oct 04, 2005 11:00 pm
by Velan
It's not like that. If a philosopher wants to eat, he will put a semphore for LEFT and RIGHT forks. This is one way.
If a philospher wants to eat, he will put a semaphore for LEFT and RIGHT philosophers, provided both of them are not eating.
For the above two, I want to know which one will be efficient and better.
Re: Dining Philosopher Problem
Posted: Tue Oct 04, 2005 11:00 pm
by Legend
The first one sounds like the classical case that has a dead lock problem, doesn't it?
Re: Dining Philosopher Problem
Posted: Mon Oct 10, 2005 11:00 pm
by Da_Maestro
Either way is just as efficient.
Though with the semaphores per philosopher implementation you might get syncronisation problems...
Adam