Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Unique key for shared memory at start of simulation

Unique key for shared memory at start of simulation

Hello
I am trying to call an external C function which will generate unique key (for shared memory) at the start of simulation and then save it into a variable which will be accesible from submodels in my scheme. But I cant to find a way to call the function only one time at the start of simulation(when {time== 0 didnt work}) and then how to set it as global variable so other submodels can acces it. Thanks for reply:)

Re: Unique key for shared memory at start of simulation

pthread_once_t my_once = PTHREAD_ONCE_INIT;

Or possibly simpler would be to create an inner/outer external object since external objects are created only once. The external object itself could be the shared memory; no keys needed since you just pass around the same pointer to all functions.

There are 0 guests and 0 other users also viewing this topic
You are here: