open-simulation-platform / libcosim

OSP C++ co-simulation library
https://open-simulation-platform.github.io/libcosim
Mozilla Public License 2.0
61 stars 10 forks source link

Cache access synchronisation does not work across processes #620

Open kyllingstad opened 4 years ago

kyllingstad commented 4 years ago

When running two or more cosim instances in parallel, some of them will exit with the following error message:

error: Resource deadlock avoided

Some googling reveals that this error message comes from the deadlock avoidance mechanism in Linux's threading system, which means that libcosim is probably using some synchronisation primitives in the wrong way.

To reproduce this, try the following command line:

cosim run path/to/system_structure --output-dir=out1 &; cosim run path/to/system_structure --output-dir=out2

This will spawn the first command as a background job and immediately continue with the second command, resulting in two parallel instances of cosim that try to access the same cache at the same time.