mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2026-02-28 11:50:57 +01:00
updated to 22.12
git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@2364 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
[[Property:title|CECIL - Threads]]
|
||||
[[Property:weight|3]]
|
||||
[[Property:uuid|44f2ee31-8634-6e54-f45a-8b36f780f888]]
|
||||
==bank_account==
|
||||
|
||||
After you have done the appropriate steps to compile the example, you will get a `bank_account.exe` on windows, or `bank_account` on Unix.
|
||||
|
||||
This program launches two types of threads:
|
||||
* the spenders withdraw some money from a shared bank account
|
||||
* the savers make some deposits on it.
|
||||
|
||||
The Eiffel Threads are launched from C. The synchronization is done from Eiffel. The shared bank account is a C structure, and is updated by the Eiffel Threads using some C externals.
|
||||
|
||||
<br/>
|
||||
In main. c: <br/>
|
||||
LISTSZ size of bank account history. <br/>
|
||||
DEPOSITORS numbers of savers. <br/>
|
||||
WITHDRAWERS numbers of spenders.
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
A typical output will be:
|
||||
<code>
|
||||
$ bank_account
|
||||
**** Bank account report:
|
||||
Thread 0x30036350 DEPOSIT 161
|
||||
Thread 0x30036350 DEPOSIT 614
|
||||
Thread 0x30036350 DEPOSIT 626
|
||||
Thread 0x30036350 DEPOSIT 880
|
||||
Thread 0x30036350 DEPOSIT 601
|
||||
Thread 0x30036350 DEPOSIT 480
|
||||
Thread 0x30036350 DEPOSIT 177
|
||||
Thread 0x30036350 DEPOSIT 451
|
||||
Thread 0x30036350 DEPOSIT 96
|
||||
Thread 0x30036350 DEPOSIT 219
|
||||
*** BALANCE: 5305
|
||||
Do you want to continue? (y/n)
|
||||
y
|
||||
**** Bank account report:
|
||||
Thread 0x3003fcf0 DEPOSIT 161
|
||||
Thread 0x3004f088 DEPOSIT 161
|
||||
Thread 0x300567a0 WITHDRAWAL 161
|
||||
Thread 0x3005e1f0 WITHDRAWAL 161
|
||||
Thread 0x30036350 DEPOSIT 531
|
||||
Thread 0x3003fcf0 DEPOSIT 614
|
||||
Thread 0x3004f088 DEPOSIT 614
|
||||
Thread 0x300567a0 WITHDRAWAL 614
|
||||
Thread 0x30036350 DEPOSIT 409
|
||||
Thread 0x3003fcf0 DEPOSIT 626
|
||||
*** BALANCE: 7485
|
||||
Do you want to continue? (y/n)
|
||||
y
|
||||
**** Bank account report:
|
||||
Thread 0x3004f088 DEPOSIT 626
|
||||
Thread 0x30036350 DEPOSIT 799
|
||||
Thread 0x300567a0 WITHDRAWAL 626
|
||||
Thread 0x3005e1f0 WITHDRAWAL 614
|
||||
Thread 0x3003fcf0 DEPOSIT 880
|
||||
Thread 0x30036350 DEPOSIT 860
|
||||
Thread 0x3004f088 DEPOSIT 880
|
||||
Thread 0x300567a0 WITHDRAWAL 880
|
||||
Thread 0x30036350 DEPOSIT 307
|
||||
Thread 0x3004f088 DEPOSIT 601
|
||||
*** BALANCE: 10318
|
||||
</code>
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user