Talk:Dining philosophers: Difference between revisions

Content added Content deleted
No edit summary
(→‎Contradictory: new section)
Line 63: Line 63:


:It works because each philosopher picks up a lower numbered fork before picking up a higher numbered fork. (When each thread starts, the forks are placed in order according to their number) The thing about this solution is that some philosophers have a slight advantage of acquiring both forks over other philosophers. It can't deadlock because in order for deadlock to occur, one of the philosophers would have to pick up a higher numbered fork before attempting to pick up a lower numbered fork. You can't have the situation where all the philosophers have each picked up one fork. At least one of them will not be able to acquire any forks (most likely the one who uses forks 4 and 0)- rldrenth
:It works because each philosopher picks up a lower numbered fork before picking up a higher numbered fork. (When each thread starts, the forks are placed in order according to their number) The thing about this solution is that some philosophers have a slight advantage of acquiring both forks over other philosophers. It can't deadlock because in order for deadlock to occur, one of the philosophers would have to pick up a higher numbered fork before attempting to pick up a lower numbered fork. You can't have the situation where all the philosophers have each picked up one fork. At least one of them will not be able to acquire any forks (most likely the one who uses forks 4 and 0)- rldrenth

== Contradictory ==

The question is contradictory.
"When a philosopher cannot grab both forks it sits and waits."
Since he puts the forks down at the same time,
he will never be holding only one fork.