From b8f6a9180bea43cff4df24688d6662dff3943950 Mon Sep 17 00:00:00 2001 From: halw Date: Wed, 9 Feb 2011 15:00:56 +0000 Subject: [PATCH] Author:halw Date:2011-02-09T15:00:56.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@756 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../scoop-examples/dining-philosophers.wiki | 6 +++--- 1 file changed, 3 insertions(+), 3 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 f8e5fa48..1cdf1d2e 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 @@ -9,9 +9,9 @@ In the [http://en.wikipedia.org/wiki/Dining_philosophers_problem dining philosopers] a number of philosophers (five, in our example) are seated at a round table. On the table are five plates of food, one in front of each philosopher, and five forks, one between each adjacent pair of plates. So each philosopher has a plate in front of him and a fork to his left and a fork to his right. -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 has not already done so). 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. +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), they would achieve a ''deadlock''. A ''starvation'' situation might occur if, because of unfairness in the solution algorithm, one or more philosophers get stuck in thinking mode because they can never secure the two forks necessary to eat. +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]. =Highlights= @@ -31,7 +31,7 @@ Class PHILOSOPHER models the philosophers. The totality of a philos This feature is called by {PHILOSOPHER}.live repeatedly until the philosopher has eaten a prescribed number of times. -The feature think requires no access to shared objects, but the feature eat depends upon the philosopher's ability to secure access to both of the forks adjacent to his plate. Because all forks are separate objects, each call to eat waits until the processors for both the left and right forks are available (in accordance with the Wait rule). +The feature think requires no access to shared objects, but the feature eat depends upon the philosopher's ability to secure access to both of the forks adjacent to his plate. Because all forks are separate objects, each call to eat waits until the processors for both the left and right forks are available (in accordance with the [[Concurrent Eiffel with SCOOP#Access to shared resources|Wait rule]]). Another interesting feature of this example is the feature {PHILOSOPHER}.eat. If you look at the text of this feature