DLR-SR / Noise

Modelica library for generating stochastic signals to be included in the Modelica Standard Library
9 stars 11 forks source link

Mutex for thread-safe access to static variables #46

Closed akloeckner closed 9 years ago

akloeckner commented 9 years ago

This adresses the issue #45.

tbeu commented 9 years ago

Looks good to me.

tbeu commented 9 years ago

Sorry, missed one. In ModelicaRandom_impureRandom_xorshift1024star MUTEX_LOCK must be called before ModelicaRandom_id is accessed.

MUTEX_LOCK();
/* Check that ModelicaRandom_initializeImpureRandome_xorshift1024star was called before */
if ( id != ModelicaRandom_id ) {
ModelicaError("Function impureRandom not initialized with function initializeImpureRandom");
}
/* Compute random number */
ModelicaRandom_xorshift1024star_internal(ModelicaRandom_s, &ModelicaRandom_p, &y);
MUTEX_UNLOCK();
return y;