Chymyst / chymyst-core

Declarative concurrency in Scala - The implementation of the chemical machine
Apache License 2.0
155 stars 11 forks source link

Replace Philosophers, Spaghetti, and Forks with Readers, Books, and Candles #154

Open naturallymitchell opened 6 years ago

naturallymitchell commented 6 years ago

There seems like no way to mentally picture any of this without tripping over a fallen Ugly Tree branch.

I'd take this issue upstream, but this project seems like the best ongoing work in the field. So I propose to this project's community here:

To bolster this terminology, the latest solution fits N "readers", not 5 named participants, and makes a good bit of sense while using some messaging. So, this could easily be visualized as an After Dark Reading Circle. This way, thinking goes hand-in-hand with putting down reading material, which frees a light source, and reading can take place continuously for those who want it and while their neighbors keep thinking (or sleeping), as long as that works well for them. No one has to starve.

naturallymitchell commented 6 years ago

Also, "both sides of the book" gives an interesting twist. Perhaps a reader could read only an odd page with an available light on the left hand side and an even page with an available light on the right hand side. And they can only read "page after page" (continuously) while both light sources are available, or the next page once that light is available. So then, if it takes one reader 1 min to read each page, and his neighbors take 2 min to read each page, then that leaves interesting opportunities to optimize and alternate resource usage.

So variable factors:

winitzki commented 6 years ago

Would you like to implement this example in Chymyst? Let me know if something is unclear in the documentation, by the way. Always looking to improve things.

naturallymitchell commented 6 years ago

you have 5 people sitting at a table who have candles between each them, 5 total. to read their books, they need to pull the candle closer, but this this takes it away from the person next to them. since they need both sides of their book lit, how can they efficiently take the candles and put them back for optimal reading by the group?

/note to self and other diners