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).
Dining Philosopher Problem
Re: Dining Philosopher Problem
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?
Or a semaphore per philosopher?
*post*
Re: Dining Philosopher Problem
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.
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
One semaphore for all forks ... as a result only one philosopher can eat at a time?
*post*
Re: Dining Philosopher Problem
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.
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
The first one sounds like the classical case that has a dead lock problem, doesn't it?
*post*
-
- Member
- Posts: 144
- Joined: Tue Oct 26, 2004 11:00 pm
- Location: Australia
Re: Dining Philosopher Problem
Either way is just as efficient.
Though with the semaphores per philosopher implementation you might get syncronisation problems...
Adam
Though with the semaphores per philosopher implementation you might get syncronisation problems...
Adam
Two things are infinite: The universe and human stupidity. But I'm not quite sure about the universe.
--- Albert Einstein
--- Albert Einstein