When running more that one SICStus runtime in the same process it is often necessary to protect data with mutual exclusion locks. The following functions implement recursive mutual exclusion locks, which only need static initialization.
Locks the mutex.
Unlocks the mutex.
A (recursive) mutual exclusion lock is declared as type
SP_mutex. It should be initialized to (the static initializer)
SP_MUTEX_INITIALIZER before use.
Note that the SICStus runtime is not thread safe in general.
A dynamic foreign resource that is used by multiple SICStus
runtimes in the same process may need to maintain a global state that
is kept separate for each SICStus runtime. Each SICStus runtime
maintains a location (containing a
void*) for each foreign
resource. By calling
a foreign resource can then access this location to
store any data that is specific to the calling SICStus runtime.