-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
book: Fix final dining philosophers program output #30569
Conversation
danmactough
commented
Dec 26, 2015
- Fix final dining philosophers program output to match what the program actually outputs
- Clarify that only one philosopher can eat at a time (as currently implemented, at least)
Also clarifies that only one philosopher may eat at a time, not two.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Hey @danmactough ! I'm still not sure why this is different for you, as I copied it directly from running. Hm. They should be able to eat at the same time, though the timing may not always work out that way. |
Hey @steveklabnik ! I don't know either! :) My code is here but the only diff from the docs (I I was wondering if the implementation changed since you copied that output. Just thinking about it logically the way it's being implemented, I can't see how anything other than what I observed could happen.
|
@danmactough why do you believe that philosopher 0 will always run first? Threads do not necessarily execute in exactly the order they're spawned. |
…tput." This reverts commit 70013e1.
Also add brief explanation about why program output may differ.
It never occurred to me that ...
In part, because I ran the code probably a hundred times and got the same output (which doesn't match the current docs). Thanks for the tip, @sfackler! I added a little more output to my code and can see what you're saying now: thread::spawn(move || {
+ println!("{} starting", p.name);
p.eat(&table);
}) Still... I have never seen two philosophers eating together (not since college, at least). I think the docs for this exercise -- which is about learning Rust -- shouldn't present an edge case (if that's accurate) as the norm and assume that a beginner (me) would connect the dots -- i.e., that since spawned thread execution order is arbitrary, it's remotely possible that two philosophers could eat at the same time if the order of execution is just so. It sure confused the heck out of me. I was certain that I had missed something in my code. I've reverted my initial change and instead suggest a clarification just to the wording: 7dc7531. |
closed by #30595 |