To use multi-threading in Simics, all modules used in the simulation must be thread safe. This section describes what it means for a module to be thread safe, and what conditions must be fulfilled.
yes
when compiling the module.
Below is an example makefile for a module marked as thread safe.
It can be found in the
[project]
/modules/sample-user-decoder
directory
if the sample-user-decoder has been copied to the
project.
MODULE_CLASSES = sample-user-decoder SRC_FILES = sample-user-decoder.c SIMICS_API := 6 THREAD_SAFE = yes include $(MODULE_MAKEFILE)
To make a module thread safe, global state should be avoided, both in the form of global variables and in the form of local static variables in C. Having constant global variables are fine. Modules written in pure DML do not have this problem since the DML compiler does not emit any non-constant global state.
Simics checks for some execution context violations during run-time and emits warnings if they occur. When running with multi-threading disabled, violations result in warnings that can optionally be turned off. With multi-threading enabled, violations cause hard errors.
If a module that is not marked with THREAD_SAFE=yes
is
loaded, multi-threading will be turned off automatically and a warning
will be shown. The list-modules command will show whether a
module is marked thread safe or not.