Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove the 'TUTORIAL: New API' chunks
[simgrid.git] / include / simgrid / simix.h
1 /* Copyright (c) 2007-2010, 2012-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _SIMIX_SIMIX_H
8 #define _SIMIX_SIMIX_H
9
10 #include "xbt/misc.h"
11 #include "xbt/fifo.h"
12 #include "xbt/dict.h"
13 #include "xbt/function_types.h"
14 #include "xbt/parmap.h"
15 #include "xbt/swag.h"
16 #include "simgrid/platf.h"
17 #include "simgrid/datatypes.h"
18
19 SG_BEGIN_DECL()
20
21 /**************************** Scalar Values **********************************/
22
23 typedef union u_smx_scalar u_smx_scalar_t;
24
25 /* ******************************** Host ************************************ */
26 /** @brief Host datatype
27     @ingroup simix_host_management
28
29     A <em>location</em> (or <em>host</em>) is any possible place where
30     a process may run. Thus it is represented as a <em>physical
31     resource with computing capabilities</em>, some <em>mailboxes</em>
32     to enable running process to communicate with remote ones, and
33     some <em>private data</em> that can be only accessed by local
34     process.
35
36     \see m_host_management
37   @{ */
38 typedef xbt_dictelm_t smx_host_t;
39 typedef struct s_smx_host_priv *smx_host_priv_t;
40 typedef enum {
41   SIMIX_WAITING,
42   SIMIX_READY,
43   SIMIX_RUNNING,
44   SIMIX_DONE,
45   SIMIX_CANCELED,
46   SIMIX_FAILED,
47   SIMIX_SRC_HOST_FAILURE,
48   SIMIX_DST_HOST_FAILURE,
49   SIMIX_SRC_TIMEOUT,
50   SIMIX_DST_TIMEOUT,
51   SIMIX_LINK_FAILURE
52 } e_smx_state_t;
53 /** @} */
54
55 typedef struct s_smx_timer* smx_timer_t;
56
57 /* ******************************** Synchro ************************************ */
58 /**
59  * \ingroup simix_synchro_management
60  */
61 typedef struct s_smx_mutex *smx_mutex_t;
62 /**
63  * \ingroup simix_synchro_management
64  */
65 typedef struct s_smx_cond *smx_cond_t;
66 /**
67  * \ingroup simix_synchro_management
68  */
69 typedef struct s_smx_sem *smx_sem_t;
70
71 /********************************** File *************************************/
72 typedef struct s_smx_file *smx_file_t;
73
74 /********************************** Storage *************************************/
75 typedef xbt_dictelm_t smx_storage_t;
76 typedef struct s_smx_storage_priv *smx_storage_priv_t;
77
78 /********************************** Action *************************************/
79 typedef struct s_smx_action *smx_action_t; /* FIXME: replace by specialized action handlers */
80
81 /* ****************************** Process *********************************** */
82 /** @brief Process datatype
83     @ingroup simix_process_management
84
85     A processt may be defined as a <em>code</em>, with some <em>private
86     data</em>, executing in a <em>location</em>.
87     \see m_process_management
88   @{ */
89 typedef struct s_smx_process *smx_process_t;
90 typedef enum {
91   SMX_EXIT_SUCCESS = 0,
92   SMX_EXIT_FAILURE = 1
93 } smx_process_exit_status_t;
94 /** @} */
95
96
97 /*
98  * Type of function that creates a process.
99  * The function must accept the following parameters:
100  * void* process: the process created will be stored there
101  * const char *name: a name for the object. It is for user-level information and can be NULL
102  * xbt_main_func_t code: is a function describing the behavior of the process
103  * void *data: data a pointer to any data one may want to attach to the new object.
104  * smx_host_t host: the location where the new process is executed
105  * int argc, char **argv: parameters passed to code
106  * xbt_dict_t pros: properties
107  */
108 typedef void (*smx_creation_func_t) ( /* process */ smx_process_t*,
109                                       /* name */ const char*,
110                                       /* code */ xbt_main_func_t,
111                                       /* userdata */ void*,
112                                       /* hostname */ const char*,
113                                       /* kill_time */ double,
114                                       /* argc */ int,
115                                       /* argv */ char**,
116                                       /* props */ xbt_dict_t,
117                                       /* auto_restart */ int,
118                                       /* parent_process */ smx_process_t);
119
120
121 /******************************* Networking ***********************************/
122 /**
123  * \ingroup simix_rdv_management
124  */
125 typedef struct s_smx_rvpoint *smx_rdv_t;
126
127 XBT_PUBLIC(void*) SIMIX_comm_get_src_data(smx_action_t action);
128 XBT_PUBLIC(void*) SIMIX_comm_get_dst_data(smx_action_t action);
129
130 /******************************** Context *************************************/
131 typedef struct s_smx_context *smx_context_t;
132 typedef struct s_smx_context_factory *smx_context_factory_t;
133
134 /* Process creation/destruction callbacks */
135 typedef void (*void_pfn_smxprocess_t) (smx_process_t);
136 /* Process kill */
137 typedef void (*void_pfn_smxprocess_t_smxprocess_t) (smx_process_t, smx_process_t);
138 /* for auto-restart function */
139 typedef void (*void_pfn_smxhost_t) (smx_host_t);
140
141 /* The following function pointer types describe the interface that any context
142    factory should implement */
143
144
145 typedef smx_context_t (*smx_pfn_context_factory_create_context_t)(
146   xbt_main_func_t, int, char **, void_pfn_smxprocess_t, smx_process_t process);
147 typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*);
148 typedef void (*smx_pfn_context_free_t) (smx_context_t);
149 typedef void (*smx_pfn_context_start_t) (smx_context_t);
150 typedef void (*smx_pfn_context_stop_t) (smx_context_t);
151 typedef void (*smx_pfn_context_suspend_t) (smx_context_t context);
152 typedef void (*smx_pfn_context_runall_t) (void);
153 typedef smx_context_t (*smx_pfn_context_self_t) (void);
154 typedef smx_process_t (*smx_pfn_context_get_process_t) (smx_context_t context);
155
156 /* interface of the context factories */
157 typedef struct s_smx_context_factory {
158   const char *name;
159   smx_pfn_context_factory_create_context_t create_context;
160   smx_pfn_context_factory_finalize_t finalize;
161   smx_pfn_context_free_t free;
162   smx_pfn_context_stop_t stop;
163   smx_pfn_context_suspend_t suspend;
164   smx_pfn_context_runall_t runall;
165   smx_pfn_context_self_t self;
166   smx_pfn_context_get_process_t get_process;
167 } s_smx_context_factory_t;
168
169 /* Hack: let msg load directly the right factory */
170 typedef void (*smx_ctx_factory_initializer_t)(smx_context_factory_t*);
171 XBT_PUBLIC(smx_ctx_factory_initializer_t) smx_factory_initializer_to_use;
172 extern char* smx_context_factory_name;
173 extern int smx_context_stack_size;
174 extern int smx_context_stack_size_was_set;
175 extern int smx_context_guard_size;
176 extern int smx_context_guard_size_was_set;
177
178 /* *********************** */
179 /* Context type definition */
180 /* *********************** */
181 /* the following function pointers types describe the interface that all context
182    concepts must implement */
183 /* each context type derive from this structure, so they must contain this structure
184  * at their beginning -- OOP in C :/ */
185 typedef struct s_smx_context {
186   s_xbt_swag_hookup_t hookup;
187   xbt_main_func_t code;
188   void_pfn_smxprocess_t cleanup_func;
189   smx_process_t process;
190   char **argv;
191   int argc;
192   unsigned iwannadie:1;
193 } s_smx_ctx_base_t;
194
195 /* methods of this class */
196 XBT_PUBLIC(void) smx_ctx_base_factory_init(smx_context_factory_t *factory);
197 XBT_PUBLIC(int) smx_ctx_base_factory_finalize(smx_context_factory_t *factory);
198
199 XBT_PUBLIC(smx_context_t)
200 smx_ctx_base_factory_create_context_sized(size_t size, xbt_main_func_t code,
201                                           int argc, char **argv,
202                                           void_pfn_smxprocess_t cleanup,
203                                           smx_process_t process);
204 XBT_PUBLIC(void) smx_ctx_base_free(smx_context_t context);
205 XBT_PUBLIC(void) smx_ctx_base_stop(smx_context_t context);
206 XBT_PUBLIC(smx_context_t) smx_ctx_base_self(void);
207 XBT_PUBLIC(smx_process_t) smx_ctx_base_get_process(smx_context_t context);
208
209 XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable(void);
210 XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID);
211 XBT_PUBLIC(xbt_dynar_t) SIMIX_processes_as_dynar(void);
212
213 /* parallelism */
214 XBT_PUBLIC(int) SIMIX_context_is_parallel(void);
215 XBT_PUBLIC(int) SIMIX_context_get_nthreads(void);
216 XBT_PUBLIC(void) SIMIX_context_set_nthreads(int nb_threads);
217 XBT_PUBLIC(int) SIMIX_context_get_parallel_threshold(void);
218 XBT_PUBLIC(void) SIMIX_context_set_parallel_threshold(int threshold);
219 XBT_PUBLIC(e_xbt_parmap_mode_t) SIMIX_context_get_parallel_mode(void);
220 XBT_PUBLIC(void) SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode);
221
222
223
224 /********************************** Global ************************************/
225 /* Initialization and exit */
226 XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
227
228
229 XBT_PUBLIC(void) SIMIX_function_register_process_cleanup(void_pfn_smxprocess_t function);
230 XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t function);
231 XBT_PUBLIC(void) SIMIX_function_register_process_kill(void_pfn_smxprocess_t_smxprocess_t function);
232
233 /* Simulation execution */
234 XBT_PUBLIC(void) SIMIX_run(void);
235 XBT_PUBLIC(double) SIMIX_get_clock(void);
236
237 /* Timer functions FIXME: should these be public? */
238 XBT_PUBLIC(void) SIMIX_timer_set(double date, void *function, void *arg);
239 XBT_PUBLIC(double) SIMIX_timer_next(void);
240
241 XBT_PUBLIC(void) SIMIX_display_process_status(void);
242
243 /******************************* Environment **********************************/
244 XBT_PUBLIC(void) SIMIX_create_environment(const char *file);
245
246 /******************************** Deployment **********************************/
247
248 XBT_PUBLIC(void) SIMIX_function_register(const char *name, xbt_main_func_t code);
249 XBT_PUBLIC(void) SIMIX_function_register_default(xbt_main_func_t code);
250 XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name);
251 XBT_PUBLIC(void) SIMIX_init_application(void);
252 XBT_PUBLIC(void) SIMIX_launch_application(const char *file);
253
254 XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
255                                             const char *process_function,
256                                             xbt_dynar_t arguments,
257                                             double process_start_time,
258                                             double process_kill_time);
259
260 /*********************************** Host *************************************/
261 //XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(u_smx_scalar_t *args);
262 XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
263 XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
264 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
265 XBT_PUBLIC(const char*) SIMIX_host_get_name(smx_host_t host); /* FIXME: make private: only the name of SIMIX_host_self() should be public without request */
266 XBT_PUBLIC(void) SIMIX_host_on(smx_host_t host);
267 XBT_PUBLIC(void) SIMIX_host_off(smx_host_t host, smx_process_t issuer);
268 XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
269 XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
270 XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_mounted_storage_list(smx_host_t host);
271 /********************************* Process ************************************/
272 XBT_PUBLIC(int) SIMIX_process_count(void);
273 XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
274 XBT_PUBLIC(const char*) SIMIX_process_self_get_name(void);
275 XBT_PUBLIC(void) SIMIX_process_self_set_data(smx_process_t self, void *data);
276 XBT_PUBLIC(void*) SIMIX_process_self_get_data(smx_process_t self);
277 XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_process_t);
278 XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c);
279 XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
280 XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_process_t process);
281 XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_pvoid_t fun, void *data);
282
283 /****************************** Communication *********************************/
284 XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, void*, size_t));
285 XBT_PUBLIC(void) SIMIX_comm_copy_pointer_callback(smx_action_t comm, void* buff, size_t buff_size);
286 XBT_PUBLIC(void) SIMIX_comm_copy_buffer_callback(smx_action_t comm, void* buff, size_t buff_size);
287
288 XBT_PUBLIC(smx_action_t) SIMIX_comm_get_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
289 XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
290 XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
291 XBT_PUBLIC(void) SIMIX_comm_finish(smx_action_t action);
292
293 /******************************************************************************/
294 /*                            SIMIX simcalls                                  */
295 /******************************************************************************/
296 /* These functions are a system call-like interface to the simulation kernel. */
297 /* They can also be called from maestro's context, and they are thread safe.  */
298 /******************************************************************************/
299
300 /******************************* Host simcalls ********************************/
301 /* TODO use handlers and keep smx_host_t hidden from higher levels */
302 XBT_PUBLIC(smx_host_t) simcall_host_get_by_name(const char *name);
303 XBT_PUBLIC(const char *) simcall_host_get_name(smx_host_t host);
304 XBT_PUBLIC(xbt_dict_t) simcall_host_get_properties(smx_host_t host);
305 XBT_PUBLIC(void) simcall_host_on(smx_host_t host);
306 XBT_PUBLIC(void) simcall_host_off(smx_host_t host);
307 XBT_PUBLIC(int) simcall_host_get_core(smx_host_t host);
308 XBT_PUBLIC(xbt_swag_t) simcall_host_get_process_list(smx_host_t host);
309 XBT_PUBLIC(double) simcall_host_get_speed(smx_host_t host);
310 XBT_PUBLIC(double) simcall_host_get_available_speed(smx_host_t host);
311 /* Two possible states, 1 - CPU ON and 0 CPU OFF */
312 XBT_PUBLIC(int) simcall_host_get_state(smx_host_t host);
313 XBT_PUBLIC(void *) simcall_host_get_data(smx_host_t host);
314
315 XBT_PUBLIC(void) simcall_host_set_data(smx_host_t host, void *data);
316
317 XBT_PUBLIC(double) simcall_host_get_current_power_peak(smx_host_t host);
318 XBT_PUBLIC(double) simcall_host_get_power_peak_at(smx_host_t host, int pstate_index);
319 XBT_PUBLIC(int) simcall_host_get_nb_pstates(smx_host_t host);
320 XBT_PUBLIC(void) simcall_host_set_power_peak_at(smx_host_t host, int pstate_index);
321 XBT_PUBLIC(double) simcall_host_get_consumed_energy(smx_host_t host);
322
323 XBT_PUBLIC(smx_action_t) simcall_host_execute(const char *name, smx_host_t host,
324                                                 double computation_amount,
325                                                 double priority, double bound, unsigned long affinity_mask);
326 XBT_PUBLIC(smx_action_t) simcall_host_parallel_execute(const char *name,
327                                                      int host_nb,
328                                                      smx_host_t *host_list,
329                                                      double *computation_amount,
330                                                      double *communication_amount,
331                                                      double amount,
332                                                      double rate);
333 XBT_PUBLIC(void) simcall_host_execution_destroy(smx_action_t execution);
334 XBT_PUBLIC(void) simcall_host_execution_cancel(smx_action_t execution);
335 XBT_PUBLIC(double) simcall_host_execution_get_remains(smx_action_t execution);
336 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_get_state(smx_action_t execution);
337 XBT_PUBLIC(void) simcall_host_execution_set_priority(smx_action_t execution, double priority);
338 XBT_PUBLIC(void) simcall_host_execution_set_bound(smx_action_t execution, double bound);
339 XBT_PUBLIC(void) simcall_host_execution_set_affinity(smx_action_t execution, smx_host_t host, unsigned long mask);
340 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
341 XBT_PUBLIC(xbt_dict_t) simcall_host_get_mounted_storage_list(smx_host_t host);
342 XBT_PUBLIC(xbt_dynar_t) simcall_host_get_attached_storage_list(smx_host_t host);
343 XBT_PUBLIC(void) simcall_host_get_params(smx_host_t vm, ws_params_t param);
344 XBT_PUBLIC(void) simcall_host_set_params(smx_host_t vm, ws_params_t param);
345
346 /******************************* VM simcalls ********************************/
347 // Create the vm_workstation at the SURF level
348 XBT_PUBLIC(void*) simcall_vm_create(const char *name, smx_host_t host);
349 XBT_PUBLIC(int) simcall_vm_get_state(smx_host_t vm);
350 XBT_PUBLIC(void) simcall_vm_start(smx_host_t vm);
351 XBT_PUBLIC(void) simcall_vm_migrate(smx_host_t vm, smx_host_t dst_pm);
352 XBT_PUBLIC(void *) simcall_vm_get_pm(smx_host_t vm);
353 XBT_PUBLIC(void) simcall_vm_set_bound(smx_host_t vm, double bound);
354 XBT_PUBLIC(void) simcall_vm_set_affinity(smx_host_t vm, smx_host_t pm, unsigned long mask);
355 XBT_PUBLIC(void) simcall_vm_resume(smx_host_t vm);
356 XBT_PUBLIC(void) simcall_vm_save(smx_host_t vm);
357 XBT_PUBLIC(void) simcall_vm_restore(smx_host_t vm);
358 XBT_PUBLIC(void) simcall_vm_suspend(smx_host_t vm);
359 XBT_PUBLIC(void) simcall_vm_destroy(smx_host_t vm);
360 XBT_PUBLIC(void) simcall_vm_shutdown(smx_host_t vm);
361
362 /**************************** Process simcalls ********************************/
363 /* Constructor and Destructor */
364 XBT_PUBLIC(void) simcall_process_create(smx_process_t *process,
365                                           const char *name,
366                                           xbt_main_func_t code,
367                                           void *data,
368                                           const char *hostname,
369                                           double kill_time,
370                                           int argc, char **argv,
371                                           xbt_dict_t properties,
372                                           int auto_restart);
373
374 XBT_PUBLIC(void) simcall_process_kill(smx_process_t process);
375 XBT_PUBLIC(void) simcall_process_killall(int reset_pid);
376 XBT_PUBLIC(void) SIMIX_process_throw(smx_process_t process, xbt_errcat_t cat, int value, const char *msg);
377
378
379 /* Process handling */
380 XBT_PUBLIC(void) simcall_process_cleanup(smx_process_t process);
381 XBT_PUBLIC(void) simcall_process_change_host(smx_process_t process,
382                  smx_host_t dest);
383 XBT_PUBLIC(void) simcall_process_suspend(smx_process_t process);
384 XBT_PUBLIC(void) simcall_process_resume(smx_process_t process);
385
386 /* Getters and Setters */
387 XBT_PUBLIC(int) simcall_process_count(void);
388 XBT_PUBLIC(void *) simcall_process_get_data(smx_process_t process);
389 XBT_PUBLIC(void) simcall_process_set_data(smx_process_t process, void *data);
390 XBT_PUBLIC(smx_host_t) simcall_process_get_host(smx_process_t process);
391 XBT_PUBLIC(const char *) simcall_process_get_name(smx_process_t process);
392 XBT_PUBLIC(int) simcall_process_get_PID(smx_process_t process);
393 XBT_PUBLIC(int) simcall_process_get_PPID(smx_process_t process);
394 XBT_PUBLIC(int) simcall_process_is_suspended(smx_process_t process);
395 XBT_PUBLIC(xbt_dict_t) simcall_process_get_properties(smx_process_t host);
396 XBT_PUBLIC(void) simcall_process_set_kill_time(smx_process_t process, double kill_time);
397 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_pvoid_t fun, void *data);
398 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart);
399 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process);
400 XBT_PUBLIC(void) simcall_process_join(smx_process_t process, double timeout);
401 /* Sleep control */
402 XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration);
403
404 /************************** Comunication simcalls *****************************/
405 /***** Rendez-vous points *****/
406
407 XBT_PUBLIC(smx_rdv_t) simcall_rdv_create(const char *name);
408 XBT_PUBLIC(void) simcall_rdv_destroy(smx_rdv_t rvp);
409 XBT_PUBLIC(smx_rdv_t) simcall_rdv_get_by_name(const char *name);
410 XBT_PUBLIC(int) simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host);
411 XBT_PUBLIC(smx_action_t) simcall_rdv_get_head(smx_rdv_t rdv);
412 XBT_PUBLIC(smx_process_t) simcall_rdv_get_receiver(smx_rdv_t rdv);
413 XBT_PUBLIC(void) simcall_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process);
414
415 XBT_PUBLIC(xbt_dict_t) SIMIX_get_rdv_points(void);
416
417 /***** Communication simcalls *****/
418
419 XBT_PUBLIC(void) simcall_comm_send(smx_process_t src, smx_rdv_t rdv, double task_size,
420                                      double rate, void *src_buff,
421                                      size_t src_buff_size,
422                                      int (*match_fun)(void *, void *, smx_action_t),
423                                      void (*copy_data_fun)(smx_action_t, void*, size_t),
424                                      void *data, double timeout);
425
426 XBT_PUBLIC(smx_action_t) simcall_comm_isend(smx_process_t src, smx_rdv_t rdv, 
427                                               double task_size,
428                                               double rate, void *src_buff,
429                                               size_t src_buff_size,
430                                               int (*match_fun)(void *, void *, smx_action_t),
431                                               void (*clean_fun)(void *),
432                                               void (*copy_data_fun)(smx_action_t, void*, size_t),
433                                               void *data, int detached);
434
435 XBT_PUBLIC(void) simcall_comm_recv(smx_rdv_t rdv, void *dst_buff,
436                                    size_t * dst_buff_size,
437                                    int (*match_fun)(void *, void *, smx_action_t),
438                                    void (*copy_data_fun)(smx_action_t, void*, size_t),
439                                    void *data, double timeout, double rate);
440
441 XBT_PUBLIC(smx_action_t) simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff,
442                                             size_t * dst_buff_size,
443                                             int (*match_fun)(void *, void *, smx_action_t),
444                                             void (*copy_data_fun)(smx_action_t, void*, size_t),
445                                             void *data, double rate);
446
447 XBT_PUBLIC(smx_action_t) simcall_comm_iprobe(smx_rdv_t rdv, int type, int src, int tag,
448                                 int (*match_fun)(void *, void *, smx_action_t), void *data);
449 XBT_PUBLIC(void) simcall_comm_cancel(smx_action_t comm);
450
451 /* FIXME: waitany is going to be a vararg function, and should take a timeout */
452 XBT_PUBLIC(unsigned int) simcall_comm_waitany(xbt_dynar_t comms);
453 XBT_PUBLIC(void) simcall_comm_wait(smx_action_t comm, double timeout);
454 XBT_PUBLIC(int) simcall_comm_test(smx_action_t comm);
455 XBT_PUBLIC(int) simcall_comm_testany(xbt_dynar_t comms);
456
457 /* Getters and setters */
458 XBT_PUBLIC(double) simcall_comm_get_remains(smx_action_t comm);
459 XBT_PUBLIC(e_smx_state_t) simcall_comm_get_state(smx_action_t comm);
460 XBT_PUBLIC(void *) simcall_comm_get_src_data(smx_action_t comm);
461 XBT_PUBLIC(void *) simcall_comm_get_dst_data(smx_action_t comm);
462 XBT_PUBLIC(smx_process_t) simcall_comm_get_src_proc(smx_action_t comm);
463 XBT_PUBLIC(smx_process_t) simcall_comm_get_dst_proc(smx_action_t comm);
464
465 #ifdef HAVE_LATENCY_BOUND_TRACKING
466 XBT_PUBLIC(int) simcall_comm_is_latency_bounded(smx_action_t comm);
467 #endif
468
469 #ifdef HAVE_TRACING
470 /************************** Tracing handling **********************************/
471 XBT_PUBLIC(void) simcall_set_category(smx_action_t action, const char *category);
472 #endif
473
474 /************************** Synchro simcalls **********************************/
475
476 XBT_PUBLIC(smx_mutex_t) simcall_mutex_init(void);
477 XBT_PUBLIC(void) simcall_mutex_destroy(smx_mutex_t mutex);
478 XBT_PUBLIC(void) simcall_mutex_lock(smx_mutex_t mutex);
479 XBT_PUBLIC(int) simcall_mutex_trylock(smx_mutex_t mutex);
480 XBT_PUBLIC(void) simcall_mutex_unlock(smx_mutex_t mutex);
481
482 XBT_PUBLIC(smx_cond_t) simcall_cond_init(void);
483 XBT_PUBLIC(void) simcall_cond_destroy(smx_cond_t cond);
484 XBT_PUBLIC(void) simcall_cond_signal(smx_cond_t cond);
485 XBT_PUBLIC(void) simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex);
486 XBT_PUBLIC(void) simcall_cond_wait_timeout(smx_cond_t cond,
487                                          smx_mutex_t mutex,
488                                          double max_duration);
489 XBT_PUBLIC(void) simcall_cond_broadcast(smx_cond_t cond);
490
491 XBT_PUBLIC(smx_sem_t) simcall_sem_init(int capacity);
492 XBT_PUBLIC(void) simcall_sem_destroy(smx_sem_t sem);
493 XBT_PUBLIC(void) simcall_sem_release(smx_sem_t sem);
494 XBT_PUBLIC(int) simcall_sem_would_block(smx_sem_t sem);
495 XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem);
496 XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem,
497                                              double max_duration);
498 XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
499
500 /*****************************   File   **********************************/
501 XBT_PUBLIC(void *) simcall_file_get_data(smx_file_t fd);
502 XBT_PUBLIC(void) simcall_file_set_data(smx_file_t fd, void *data);
503 XBT_PUBLIC(sg_size_t) simcall_file_read(smx_file_t fd, sg_size_t size, smx_host_t host);
504 XBT_PUBLIC(sg_size_t) simcall_file_write(smx_file_t fd, sg_size_t size, smx_host_t host);
505 XBT_PUBLIC(smx_file_t) simcall_file_open(const char* fullpath, smx_host_t host);
506 XBT_PUBLIC(int) simcall_file_close(smx_file_t fd, smx_host_t host);
507 XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd, smx_host_t host);
508 XBT_PUBLIC(sg_size_t) simcall_file_get_size(smx_file_t fd);
509 XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd);
510 XBT_PUBLIC(sg_size_t) simcall_file_tell(smx_file_t fd);
511 XBT_PUBLIC(int) simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin);
512 XBT_PUBLIC(int) simcall_file_move(smx_file_t fd, const char* fullpath);
513 /*****************************   Storage   **********************************/
514 XBT_PUBLIC(sg_size_t) simcall_storage_get_free_size (smx_storage_t storage);
515 XBT_PUBLIC(sg_size_t) simcall_storage_get_used_size (smx_storage_t storage);
516 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
517 XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage);
518 XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data);
519 XBT_PUBLIC(xbt_dict_t) SIMIX_storage_get_content(smx_storage_t storage);
520 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_content(smx_storage_t storage);
521 XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_storage_t storage);
522 XBT_PUBLIC(sg_size_t) SIMIX_storage_get_size(smx_storage_t storage);
523 XBT_PUBLIC(const char*) SIMIX_storage_get_host(smx_storage_t storage);
524 /************************** AS router   **********************************/
525 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
526 /************************** AS router simcalls ***************************/
527 XBT_PUBLIC(xbt_dict_t) simcall_asr_get_properties(const char *name);
528
529 /************************** MC simcalls   **********************************/
530 XBT_PUBLIC(void *) simcall_mc_snapshot(void);
531 XBT_PUBLIC(int) simcall_mc_compare_snapshots(void *s1, void *s2);
532 XBT_PUBLIC(int) simcall_mc_random(int min, int max);
533
534 SG_END_DECL()
535 #endif                          /* _SIMIX_SIMIX_H */