SMAS 2.0bA Primer |
4. The Factorial Example (SC-1)
Running the simulator with the .i.graphics interface; is the normal way to proceed, since grpaphics will show the exchange of messages, and trace will print the corresponding content of each message. This is done as follows:
The resulting SMAS control pannel should appear as follows:
Note that it was not necessary to click the "UNLOCK" button. The resulting Message Diagram window and Listener window are shown in next page. Their contents is intuitive and messages are color coded both in their graphics and their printed version to allow easy matching.
At time t=1 the user requests MUL-2 (blue arrow) to do some task (SC-1.2). Agent MUL-2 becomes busy (red).
At time t=4 while MUL-2 is busy, the user requests the FACTORIAL agent to compute 4! To do so the FACTORIAL agent subcontracts a multiplication to agent MUL-1. FACTORIAL then change state and becomes waiting-for-answer (yellow), while MUL-1 becomes busy.
At time t=9, MUL-2 completes its job and returns the answer 625 to the user (green arrow leading to the left edge of the screen).
At time t=11 MUL-1 completes its job, returns an answer to FACTORIAL (12). FACTORIAL needs to subcantract a MULTIPLY of 12 by 2, to complete the computation of 4!, which it does at time t=12 (blue arrow).
At time t=18, MUL-1 completes it subtask, returns 24 to FACTORIAL which returns the final result to the user. Note that FACTORIAL becomes busy (red color) when preparing to return the answer.
Copyrignt Jean-Paul Barthès@UTC, 1998 Last update, Jan 99