From 02e92b18a51389e5fc18764a603a49e32b552e7d Mon Sep 17 00:00:00 2001 From: halw Date: Fri, 8 Apr 2011 18:59:47 +0000 Subject: [PATCH] Author:halw Date:2011-04-04T23:12:30.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@868 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../scoop-examples/dining-philosophers.wiki | 8 ++++---- .../scoop-examples/faneuil-hall.wiki | 13 +++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/dining-philosophers.wiki b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/dining-philosophers.wiki index 1cdf1d2e..318125de 100644 --- a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/dining-philosophers.wiki +++ b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/dining-philosophers.wiki @@ -11,18 +11,18 @@ In the [http://en.wikipedia.org/wiki/Dining_philosophers_problem dining philosop The philosophers spend all their time in either of only two states: they are thinking or they are eating. The philosophers may be brilliant thinkers, but apparently manual dexterity is not their strong suit. This is evidenced by the fact that in order to eat, any philosopher must be able to pick up both of the forks positioned next to his plate (which he can do, so long as the philosopher next to him is not currently eating). So, while eating he must have possession of both forks, and while thinking, he has put down any forks that he had previously used. Therefore, any particular philosopher has the opportunity to eat only when the two philosophers on either side of him are thinking and have made their forks available. -Apart from any negative consequences from these questionable sanitary practices, the dining philosophers can, in improperly designed solutions, encounter problems related to concurrency. For example, if all philosophers were to pick up the fork to their right and then wait for the fork to their left to become available (or vice versa), the philosophers would be caught in a [http://en.wikipedia.org/wiki/Deadlock deadlock]. If, because of a lack of fairness in the solution, some of the philosophers get stuck in thinking mode because they can never secure the two forks necessary to eat, then those philosophers so affected would suffer a condition known as [http://en.wikipedia.org/wiki/Resource_starvation resource starvation]. +Apart from any negative consequences from the questionable sanitary practices described above, the dining philosophers can, in improperly designed solutions, encounter problems related to concurrency. For example, if all philosophers were to pick up the fork to their right and then wait for the fork to their left to become available (or vice versa), the philosophers would be caught in a [http://en.wikipedia.org/wiki/Deadlock deadlock]. If, because of a lack of fairness in the solution, some of the philosophers get stuck in thinking mode because they can never secure the two forks necessary to eat, then those philosophers so affected would suffer a condition known as [http://en.wikipedia.org/wiki/Resource_starvation resource starvation]. =Highlights= -This example includes three classes relevant to the problem: APPLICATION, PHILOSOPHER, and FORK. Class APPLICATION sets the problem in motion by creating the forks and philosophers all typed as separate, and then applying the feature live to each philosopher after creation. +This example includes three classes relevant to the problem: DINING_PHILOSOPHERS, PHILOSOPHER, and FORK. Class DINING_PHILOSOPHERS sets the problem in motion by creating the forks and philosophers all typed as separate, and then applying the feature live to each philosopher after creation. Class PHILOSOPHER models the philosophers. The totality of a philosopher's exciting activities is modeled by the feature step: step - -- Perform a philosopher'’s tasks. + -- Perform tasks. do think eat (left_fork, right_fork) @@ -48,7 +48,7 @@ Another interesting feature of this example is the feature {PHILOSOPHER}.e and you're not wearing your SCOOP glasses, this could look a little odd to you. Here is a routine that takes two arguments l and r representing the left and right forks. But then, l and r are never used in body of the routine! -However, with SCOOP in mind, we realize that the fork objects are shared resources to which exclusive access must be secured before a philosopher can eat. In this example, the fork object themselves don't really do anything except serve that purpose. (Take a look at the FORK class, and you'll see that it has no features.) +However, with SCOOP in mind, we realize that the fork objects are shared resources to which exclusive access must be secured before a philosopher can eat. In this example, the fork object themselves don't really do anything except serve that purpose. (Take a look at the FORK class, and you'll see that it has no features.) In real world concurrency problems, it is likely that shared resources would play a more active role than the forks of the dining philosophers, but here it's just not necessary. diff --git a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/faneuil-hall.wiki b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/faneuil-hall.wiki index afd9b16a..e518a2e4 100644 --- a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/faneuil-hall.wiki +++ b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/faneuil-hall.wiki @@ -1,9 +1,18 @@ [[Property:title|Faneuil Hall]] [[Property:weight|-5]] -[[Property:uuid|32052706-cde9-f0a6-f140-697d47823f53]] - +[[Property:uuid|93132084-5eb9-c7d9-d58c-7b5c3f7508f8]] {{UnderConstruction}} +=Description= + +The Faneuil Hall example is one of several examples that comes to us from Allen Downey's book ''[http://greenteapress.com/semaphores/ The Little Book of Semaphores]''. Downey credits Grant Hutchins as the originator of the example. [http://en.wikipedia.org/wiki/Faneuil_Hall Faneuil Hall] itself is an historic building in Boston which dates from 1742 an has served as a public meeting and market place. + +The scenario in the Faneuil Hall example involves a number of immigrants waiting to have their naturalizations confirmed by a judge and receive their certificates of citizenship. Immigrants enter the building wait in line to check in, then they wait. Meanwhile, a number of spectators can also enter the building. Once the judge enters the Hall, no one else may enter the hall. Spectators may leave, but immigrants may not. Once all the immigrants have checked in, their naturalization can be confirmed by the judge. Once confirmed, the immigrants can pick up their certificates. At some point after the confirmation, the judge leaves the Hall. At that point, spectators can enter again, and immigrants can leave as soon as they have picked up their certificates. + + +=Highlights= + +