3 /* gras/process.h - Manipulating data related to an host. */
5 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #ifndef GRAS_PROCESS_H
11 #define GRAS_PROCESS_H
13 #include "xbt/misc.h" /* SG_BEGIN_DECL */
18 void gras_agent_spawn(const char *name, void *data, xbt_main_func_t code, int argc, char *argv[], xbt_dict_t properties);
21 /****************************************************************************/
22 /* Manipulating User Data */
23 /****************************************************************************/
25 /** \addtogroup GRAS_globals
26 * \brief Handling global variables so that it works on simulator.
28 * In GRAS, using globals is forbidden since the "processes" will
29 * sometimes run as a thread inside the same process (namely, in
30 * simulation mode). So, you have to put all globals in a structure, and
33 * Use the \ref gras_userdata_new macro to create a new user data (or malloc it
34 * and use \ref gras_userdata_set yourself), and \ref gras_userdata_get to
35 * retrieve a reference to it.
40 * \brief Get the data associated with the current process.
41 * \ingroup GRAS_globals
43 XBT_PUBLIC(void*) gras_userdata_get(void);
46 * \brief Set the data associated with the current process.
47 * \ingroup GRAS_globals
49 XBT_PUBLIC(void) gras_userdata_set(void *ud);
51 /** \brief Malloc and set the data associated with the current process. */
52 #define gras_userdata_new(type) (gras_userdata_set(xbt_new0(type,1)),gras_userdata_get())
57 #endif /* GRAS_PROCESS_H */