From 7c46c477d1ae41b1343cd318249b9f947f2cfd9d Mon Sep 17 00:00:00 2001 From: halw Date: Mon, 28 Feb 2011 18:26:55 +0000 Subject: [PATCH] Author:halw Date:2011-02-25T02:40:18.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@792 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../concurrent-eiffel-scoop/scoop-examples/barbershop.wiki | 4 +++- .../scoop-examples/dining-savages.wiki | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/barbershop.wiki b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/barbershop.wiki index 8ee35846..93c4e215 100644 --- a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/barbershop.wiki +++ b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/barbershop.wiki @@ -11,7 +11,9 @@ The [http://en.wikipedia.org/wiki/Sleeping_barber_problem barbershop], sometimes called ''the sleeping barber'', models a barbershop with one barber, one barber's chair, and a waiting room with several chairs. The alternative name of the problem comes from the fact that if there is no one waiting for a haircut, the barber flops in his chair and falls asleep. -Also involved are a number of shaggy-haired customers. A customer entering the barbershop looks around and assesses the situation. If all the waiting room chairs are occupied, the customer leaves the shop to return again at a time when hopefully the queue will be shorter. +Also involved are a number of shaggy-haired customers. A customer entering the barbershop looks around and assesses the situation. If all the waiting room chairs are occupied, the customer leaves the shop to return again at a time when hopefully the queue will be shorter. If there is an open chair the customer sits down and waits for the barber. + +Once the barber has finished cutting a customer's hair, the customer leaves the shop which allows another customer to enter the shop and the the next customer in the queue to get a haircut. =Highlights= diff --git a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/dining-savages.wiki b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/dining-savages.wiki index 194a1a6f..6b807034 100644 --- a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/dining-savages.wiki +++ b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/dining-savages.wiki @@ -15,7 +15,9 @@ The problem of the dining savages (an allusion to the classic dining philosopher =Highlights= -The primary shared resource here is the pot, represented by class POT, which is accessed by the savages and by the cook. POT has queries is_empty and is_full that can be used by savages (modeled by class SAVAGE) and the cook (class COOK). POT also has a feature to allow refilling of the pot. This feature is exported only to COOK. Another feature, this one exported only to SAVAGE allows the removal of a serving from the pot. +The primary shared resource here is the pot, represented by class POT, which is accessed for different purposes by both the savages and by the cook. POT has queries is_empty and is_full that can be used by savages (modeled by class SAVAGE) and the cook (class COOK). POT also has a feature to allow refilling of the pot. This feature is exported only to COOK. Another feature, this one exported only to SAVAGE allows the removal of a serving from the pot. + +The cook can also be viewed as a resource shared among all the savages. Whenever a savage executes the feature that checks the pot, he must have exclusive access to both the pot and the cook. If the pot is empty then the savage uses his access to the cook to request a refill. If the pot is not empty, then the savage exits the routine, and goes on to execute the routine that removes 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 becoming 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.