Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
57f8b4c728017e8c2ac7fa18ce9d4c04d0f86e18
[simgrid.git] / include / gras / process.h
1 /* $Id$ */
2
3 /* gras/process.h - Manipulating data related to an host.                   */
4
5 /* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved.            */
6
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. */
9
10 #ifndef GRAS_PROCESS_H
11 #define GRAS_PROCESS_H
12
13 #include "xbt/misc.h"  /* SG_BEGIN_DECL */
14
15 SG_BEGIN_DECL()
16
17 /* **************************************************************************
18  * Initializing the processes
19  * **************************************************************************/
20 /**
21  * gras_process_init:
22  * 
23  * Perform the various intialisations needed by gras. Each process must run it
24  */
25 void gras_process_init(void);
26
27 /**
28  * gras_process_exit:
29  * 
30  * Frees the memory allocated by gras. Processes should run it
31  */
32 void gras_process_exit(void);
33
34 /****************************************************************************/
35 /* Manipulating User Data                                                   */
36 /****************************************************************************/
37
38 /** \addtogroup GRAS_globals
39  *  \brief Handling global variables so that it works on simulator (Virtualization).
40  * 
41  * <center><table><tr><td><b>Top</b>    <td> [\ref index]::[\ref GRAS_API]
42  *                <tr><td><b>Prev</b>   <td> [\ref GRAS_virtu]
43  *                <tr><td><b>Next</b>   <td> [\ref GRAS_emul]            </table></center>
44  *
45  * In GRAS, using globals is forbidden since the "processes" will
46  * sometimes run as a thread inside the same process (namely, in
47  * simulation mode). So, you have to put all globals in a structure, and
48  * let GRAS handle it.
49  * 
50  * Use the \ref gras_userdata_new macro to create a new user data (or malloc it
51  * and use \ref gras_userdata_set yourself), and \ref gras_userdata_get to
52  * retrive a reference to it. 
53  */
54 /* @{ */
55
56 /**
57  * \brief Get the data associated with the current process.
58  * \ingroup GRAS_globals
59  */
60 void *gras_userdata_get(void);
61
62 /**
63  * \brief Set the data associated with the current process.
64  * \ingroup GRAS_globals
65  */
66 void gras_userdata_set(void *ud);
67
68 /** \brief Malloc and set the data associated with the current process. */
69 #define gras_userdata_new(type) (gras_userdata_set(xbt_new0(type,1)),gras_userdata_get())
70 /* @} */
71
72 SG_END_DECL()
73
74 #endif /* GRAS_PROCESS_H */
75