mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2026-02-07 11:04:06 +01:00
Date:2011-02-13T15:00:41.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@762 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
24 lines
2.2 KiB
Plaintext
24 lines
2.2 KiB
Plaintext
[[Property:title|Dining savages]]
|
|
[[Property:weight|-6]]
|
|
[[Property:uuid|ecd618f3-14f4-1a06-7f9c-be57623a9889]]
|
|
{{UnderConstruction}}
|
|
|
|
|
|
{{Beta}}
|
|
|
|
|
|
|
|
=Description=
|
|
|
|
The problem of the dining savages (an obvious allusion to the classic dining philosophers) is based on the arguably tasteless analogy of a number of members of a primitive culture, hereinafter called the "savages", are sharing a meal from a single pot. The players are the savages themselves, a cook, and the pot. The pot contains a certain number of servings of savage sustenance (the nature of which will be left to your imagination). Each of the savages can freely remove a serving from the pot so long as the pot is not empty. So before taking a serving, a savage must check to make sure the pot is not empty. In the case in which the pot is empty, the savage must wake up the cook to refill the pot, after which the feast continue. The savages, then, can eat only when the pot is not empty, and the cook can fill the pot only when the pot is empty.
|
|
|
|
|
|
=Highlights=
|
|
|
|
The primary shared resource here is the pot, represented by class <code>POT</code>. <code>POT</code> has queries <code>is_empty</code> and <code>is_full</code> that can be used by savages (modeled by class <code>SAVAGE</code>) and the cook (class <code>COOK</code>). <code>POT</code> also has a feature to allow refilling of the pot. This feature is exported only to <code>COOK</code>. Another feature, this one exported only to <code>SAVAGE</code> allows the removal of a serving from the pot.
|
|
|
|
In the root class, you can adjust the number of savages, the size (in servings) of the pot, and how hungry the savages are. The hunger index indicates how many times a savage will take a serving from the pot and eat it before being sated. So if the pot holds 20 servings and there are 5 savages with hunger index of 4, then the pot will become empty just as the last savage takes his last serving, meaning that the pot will not require refilling. In the same scenario, if the hunger index were 10, then 50 servings total would be required, resulting in the need for the cook to be notified to refill the pot 2 times ... and 10 servings leftover ... presumably for tomorrow's breakfast.
|
|
|
|
|
|
|