Logo AND Algorithmique Numérique Distribuée

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