mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2025-12-08 15:52:26 +01:00
Author:halw
Date:2011-02-13T15:00:41.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@762 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -15,9 +15,9 @@ The problem of the dining savages (an obvious allusion to the classic dining phi
|
||||
|
||||
=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 SAVAGE) and the cook (class COOK).
|
||||
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, one 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 or her last serving. 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.
|
||||
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.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
[[Property:weight|3]]
|
||||
[[Property:uuid|24e474b5-3cb7-16ff-365f-73be8e73bd56]]
|
||||
==Settings==
|
||||
* Set the option multithreaded in the project settings under Advanced.
|
||||
* Set the Concurrency option to EiffelThread in the project settings under Advanced.
|
||||
* Do not use a non-multi-threaded precompiled library. The corresponding multi-threaded libraries of base, WEL and Vision2 should be located in $ISE_EIFFEL/precomp/spec/$PLATFORM/ with the mt prefix.
|
||||
* You may want to include the thread library (located at "$ISE_EIFFEL/library/thread") to your project. This setting can be done in [[Group Options| the groups section of the project settings window]] .
|
||||
* When using external C libraries, be sure that they are MT-safe: on the platforms where the Eiffel Threads are available. For example [[WEL]] and [[EiffelNet]] multi-threaded libraries can be recognized by the `mt' prefix.
|
||||
* You may want to include the thread library (located at "$ISE_EIFFEL/library/thread") in your project. This setting can be done in [[Group Options| the groups section of the project settings window]] .
|
||||
* When using external C libraries, be sure that they are MT-safe on the platforms where the Eiffel Threads are available. For example [[WEL]] and [[EiffelNet]] multi-threaded libraries can be recognized by the `mt' prefix.
|
||||
|
||||
==Compilation==
|
||||
|
||||
@@ -14,7 +14,7 @@ Just launch the compilation: the Eiffel compiler will generate and link the mult
|
||||
==External C files==
|
||||
|
||||
The C files that you link with a multi-threaded Eiffel application must be compiled in multi-threaded mode. In addition, you should follow some basic guidelines, which you can find in any documentation on threads. Here are the main requirements:
|
||||
* Check what you are importing is safe: you cannot arbitrarily enter non-threaded code in a multi-threaded program. Check your include files and libraries you use for the linking to decide if they can be used in multi-threaded mode.
|
||||
* Check that what you are importing is safe: you cannot arbitrarily enter non-threaded code in a multi-threaded program. Check your include files and the libraries that you use for linking to decide if they can be used in multi-threaded mode.
|
||||
* If you are using CECIL in multi-threaded mode, you must compile your C files with the same defined symbols as those used to compile the generated C-code in multi-threaded mode.
|
||||
* Threaded code can safely refer to unsafe code ONLY from the initial thread.
|
||||
|
||||
@@ -24,13 +24,13 @@ The C files that you link with a multi-threaded Eiffel application must be compi
|
||||
|
||||
Most libraries are not thread safe. This means that even though you can use them in a multi-threaded environment, you will need to add the necessary protection to ensure that objects are accessed only by one thread at a time.
|
||||
|
||||
Most of the issues is related to the use of EiffelBase containers which have been designed at a time where threads where not present. In the future we will certainly provide a version of EiffelBase which will be designed to be thread safe, in the meantime, you have to use basic protection mechanism such a mutexes to guarantee a safe execution of your programs.
|
||||
Most of the issues are related to the use of EiffelBase containers which were designed at a time when threads were not present. In the future we will certainly provide a version of EiffelBase which will be designed to be thread safe, in the meantime, you have to use basic protection mechanisms such as mutexes to guarantee the safe execution of your programs.
|
||||
|
||||
Here is a summary of what you need to include in your project settings when using our libraries:
|
||||
|
||||
- EiffelBase: not thread safe, no externals required
|
||||
|
||||
- WEL: partly thread safe regarding creation of graphical objects that belongs to two different threads, but since it relies on EiffelBase, be aware of what has been said. Other libraries have the same dependency on EiffelBase and this warning will not be repeated.
|
||||
- WEL: partly thread safe regarding creation of graphical objects that belong to two different threads, but since it relies on EiffelBase, be aware of what has been said. Other libraries have the same dependency on EiffelBase and this warning will not be repeated.
|
||||
|
||||
- MEL: you have to be aware that Motif 1. 2 is not thread safe and that Motif 2.x is. Therefore you can use MEL in a multi-threaded program only if you have Motif 2.x. In this case, you need to include libmtmel.a instead of libmel.a
|
||||
|
||||
|
||||
Reference in New Issue
Block a user