Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Commit the autogenerated files
[simgrid.git] / src / simix / private.h
1 /*      $Id$     */
2
3 /* Copyright (c) 2007 Arnaud Legrand, Bruno Donnassolo.
4    All rights reserved.                                          */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #ifndef SIMIX_PRIVATE_H
10 #define SIMIX_PRIVATE_H
11
12 #include "simix/simix.h"
13 #include "surf/surf.h"
14 #include "xbt/fifo.h"
15 #include "xbt/swag.h"
16 #include "xbt/dict.h"
17 #include "xbt/context.h"
18 #include "xbt/config.h"
19
20 /******************************* Datatypes **********************************/
21
22
23 /********************************** Host ************************************/
24
25 typedef struct s_simdata_host {
26   void *host;                   /* SURF modeling */
27   xbt_swag_t process_list;
28 } s_simdata_host_t;
29
30 /********************************* Simix Global ******************************/
31
32 typedef struct SIMIX_Global {
33   xbt_fifo_t host;
34   xbt_swag_t process_to_run;
35   xbt_swag_t process_list;
36  /* xbt_swag_t process_sleeping; */
37
38   smx_process_t current_process;
39   xbt_dict_t registered_functions;
40 /*  FILE *paje_output;
41   int session; */
42 } s_SIMIX_Global_t, *SIMIX_Global_t;
43
44 extern SIMIX_Global_t simix_global;
45
46 /******************************* Process *************************************/
47
48 typedef struct s_simdata_process {
49   smx_host_t host;                /* the host on which the process is running */
50   xbt_context_t context;                /* the context that executes the scheduler fonction */
51   int blocked;
52   int suspended;
53   smx_mutex_t mutex;            /* mutex on which the process is blocked  */
54   smx_cond_t cond;              /* cond on which the process is blocked  */
55   smx_host_t put_host;          /* used for debugging purposes */
56   smx_action_t block_action;    /* action that block the process when it does a mutex_lock or cond_wait */
57   int argc;                     /* arguments number if any */
58   char **argv;                  /* arguments table if any */
59 //  SIMIX_error_t last_errno;       /* the last value returned by a MSG_function */
60 // int paje_state;               /* the number of states stacked with Paje */
61 } s_simdata_process_t;
62
63 typedef struct process_arg {
64   const char *name;
65   smx_process_code_t code;
66   void *data;
67   smx_host_t host;
68   int argc;
69   char **argv;
70   double kill_time;
71 } s_process_arg_t, *process_arg_t;
72
73 /********************************* Mutex and Conditional ****************************/
74
75 typedef struct s_smx_mutex {
76         xbt_swag_t sleeping;                    /* list of sleeping process */
77         int using;
78
79 } s_smx_mutex_t;
80
81 typedef struct s_smx_cond {
82         xbt_swag_t sleeping;                    /* list of sleeping process */
83         smx_mutex_t  mutex;
84         xbt_fifo_t actions;                     /* list of actions */
85
86 } s_smx_cond_t;
87
88 /********************************* Action **************************************/
89
90 typedef struct s_simdata_action {
91   surf_action_t surf_action;    /* SURF modeling of computation  */
92   
93   xbt_fifo_t cond_list;         /* conditional variables that must be signaled when the action finish. */
94   smx_host_t source; 
95
96 /* control needed when the action blocks a process(__SIMIX_process_block). For each process that is blocked a new action is created, the process is stocked in cond_process variable and the "boolean" action_block is marked to 1 */
97   int action_block;             /* simix control variable, system action or not */
98   smx_process_t cond_process;   /* system process will wake up */               
99   smx_cond_t timeout_cond;      /* useful to remove the process from the sleeping list when a timeout occurs */
100
101 } s_simdata_action_t;
102
103
104
105 /******************************* Configuration support **********************************/
106
107 void simix_config_init(void); /* create the config set, call this before use! */
108 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
109 extern int _simix_init_status; /* 0: beginning of time; 
110                                 1: pre-inited (cfg_set created); 
111                                 2: inited (running) */
112 extern xbt_cfg_t _simix_cfg_set;
113
114
115
116
117
118
119 //#define PROCESS_SET_ERRNO(val) (SIMIX_process_self()->simdata->last_errno=val)
120 //#define PROCESS_GET_ERRNO() (SIMIX_process_self()->simdata->last_errno)
121 //#define SIMIX_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
122 /* #define CHECK_ERRNO()  ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
123
124 #define CHECK_HOST()  xbt_assert0(surf_workstation_resource->extension_public-> \
125                                   get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
126                                   "Host failed, you cannot call this function.")
127
128 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
129 void __SIMIX_host_destroy(smx_host_t host);
130
131 int __SIMIX_process_block(double max_duration);
132 void __SIMIX_process_unblock(smx_process_t process);
133 int __SIMIX_process_isBlocked(smx_process_t process);
134
135 void __SIMIX_display_process_status(void);
136
137 void __SIMIX_wait_for_action(smx_process_t process, smx_action_t action);
138
139
140 /*
141 void __MSG_task_execute(smx_process_t process, m_task_t task);
142 MSG_error_t __MSG_task_wait_event(smx_process_t process, m_task_t task);
143 */
144
145
146 #endif