Author Topic: Simulation multithreading issues  (Read 215 times)


  • EA User
  • **
  • Posts: 151
  • Karma: +2/-1
    • View Profile
Simulation multithreading issues
« on: May 06, 2020, 01:09:45 am »
I have been experimenting and running into propblems with simulations in SysML and UML State and Activity models with the goal of using such simulation for strengthening the faith in dynamic models.

The models I want to use are semi-complex. They consist of subsystems such as signaling lights, movable bridges, sensors, etc. And there is a central system that must control the actuators and receive data from the sensors. This is clearly a multithreaded environment.

I have tried to model this with State Diagrams using the existing Petrinet-like semantics where a Join will only "fire" when all its input states are active. In this way you can create a model where each action consists of entering a "command" state by the central control parallel with entering a "wait" state. The appropriate subsystem waits until the "command" state (that for this purpose is repeated (linked) on the subsystem diagram) enables one of its Joins (Transitions in Petrinet language) and consumes the Command state. After finishing its work in its own thread, it enters a "Confirmation" state that is consumed by the Control thread so that it leaves the Wait state..... Etcetera. The different state machines are started each in their own thread from a Startup state machine in whose diagram I have linked the various Entry elements.
The whole model is not extremely simple but no rocket science either.

This works a bit but not well enough to be useful. I run into all sorts of strange problems. Inexplainable repetitions in the simulation log, inexplainable paths taken, halting of the simulation for no apparent reasons, etc. This also seems to depend on the way in which you organise the model with packages, nested elements, state machines etc. But I have not found a good way to make this work.

I have tried the same idea using Activity Charts but that gives different but similar problems that are also difficult to reproduce exactly.... I have the impression that the semantics of the Fork/Join element is not completely clear (at least to me...).

Of course, I have also tried to use Javascript to set global variables instead of communicating through shared States or Actions. However this leads to models that are very difficult to debug and maintain. And also to multithreading problems similar to those mentioned above.

So, my question is, are there other EA users who have tried similar simulations with multithreaded models and what is their experience and advice?

Regards, Michiel