When running more that one SICStus run-time 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.
SP_mutex_lock()
SP_mutex_unlock()
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 run-time is not thread safe in general.
A dynamic foreign resource that is used by multiple SICStus
run-times in the same process may need to maintain a global state that
is kept separate for each SICStus run-time. Each SICStus run-time
maintains a location (containing a void*
) for each foreign
resource. By calling SP_foreign_stash()
,
a foreign resource can then access this location to
store any data that is specific to the calling SICStus run-time.