Typo in Dining Philosophers example?


#1

This line:
Philosopher::new(“Michel Foucault”, 0, 4),

looks wrong to me. I think it should be
Philosopher::new(“Michel Foucault”, 4,0),

As it is, it has Foucault sharing the left fork with Butler.


#2

This is on purpose, as described in the paragraph of the book immediately following the quoted code:

We need to pass in our left and right values to the constructors for our Philosophers. But there’s one more detail here, and it’s very important. If you look at the pattern, it’s all consistent until the very end. Monsieur Foucault should have 4, 0 as arguments, but instead, has 0, 4. This is what prevents deadlock, actually: one of our philosophers is left handed! This is one way to solve the problem, and in my opinion, it’s the simplest. If you change the order of the parameters, you will be able to observe the deadlock taking place.


#3

Oh, I didn’t read that far. Obviously someone wanted all the philosophers to eat, but it seems that deadlocks are important. Left handed, right.