Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
bw_request now works
[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"  /* BEGIN_DECL */
14 #include "xbt/error.h" /* xbt_error_t */
15
16 BEGIN_DECL()
17
18 /* **************************************************************************
19  * Initializing the processes
20  * **************************************************************************/
21 /**
22  * gras_process_init:
23  * 
24  * Perform the various intialisations needed by gras. Each process must run it
25  */
26 xbt_error_t gras_process_init(void);
27
28 /**
29  * gras_process_exit:
30  * 
31  * Frees the memory allocated by gras. Processes should run it
32  */
33 xbt_error_t gras_process_exit(void);
34
35 /****************************************************************************/
36 /* Manipulating User Data                                                   */
37 /****************************************************************************/
38
39 /** \addtogroup GRAS_globals
40  *  \brief Handling global variables so that it works on simulator (Virtualization).
41  * 
42  * In GRAS, using globals is forbidden since the "processes" will
43  * sometimes run as a thread inside the same process (namely, in
44  * simulation mode). So, you have to put all globals in a structure, and
45  * let GRAS handle it.
46  * 
47  * Use the \ref gras_userdata_new macro to create a new user data (or malloc it
48  * and use \ref gras_userdata_set yourself), and \ref gras_userdata_get to
49  * retrive a reference to it. 
50  */
51 /* @{ */
52
53 /**
54  * \brief Get the data associated with the current process.
55  * \ingroup GRAS_globals
56  */
57 void *gras_userdata_get(void);
58
59 /**
60  * \brief Set the data associated with the current process.
61  * \ingroup GRAS_globals
62  */
63 void gras_userdata_set(void *ud);
64
65 /** \brief Malloc and set the data associated with the current process. */
66 #define gras_userdata_new(type) (gras_userdata_set(xbt_new0(type,1)),gras_userdata_get())
67 /* @} */
68
69 END_DECL()
70
71 #endif /* GRAS_PROCESS_H */
72