SimGrid 3.6.2
Scalable simulation of distributed systems
|
Handling global variables so that it works on simulator. More...
Defines | |
#define | gras_userdata_new(type) ((type*)gras_userdata_set(xbt_new0(type,1))) |
Malloc and set the data associated with the current process. | |
Functions | |
void | gras_agent_spawn (const char *name, xbt_main_func_t code, int argc, char *argv[], xbt_dict_t properties) |
Create a new thread. | |
void * | gras_userdata_get (void) |
Get the data associated with the current process. | |
void * | gras_userdata_set (void *ud) |
Set the data associated with the current process. |
Handling global variables so that it works on simulator.
In GRAS, using globals is forbidden since the "processes" will sometimes run as a thread inside the same process (namely, in simulation mode). So, you have to put all globals in a structure, and let GRAS handle it.
Use the gras_userdata_new macro to create a new user data (or malloc it and use gras_userdata_set yourself), and gras_userdata_get to retrieve a reference to it.
For more info on this, you may want to check the relevant lesson of the GRAS tutorial: Lesson 5: Using globals in processes
#define gras_userdata_new | ( | type | ) | ((type*)gras_userdata_set(xbt_new0(type,1))) |
Malloc and set the data associated with the current process.
You'll find an example in the tutorial: Lesson 5: Using globals in processes
Back to the main Simgrid Documentation page |
The version of Simgrid documented here is v3.6.2. Documentation of other versions can be found in their respective archive files (directory doc/html). |
Generated for SimGridAPI by
![]() |