Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Java binding (on going) - Adrien
[simgrid.git] / include / simgrid / simix.h
1 /* Copyright (c) 2007, 2008, 2009, 2010. 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/file_stat.h"
14 #include "xbt/function_types.h"
15 #include "xbt/parmap.h"
16 #include "xbt/swag.h"
17
18 #include "simgrid/platf.h" // ws_params_t
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 xbt_dictelm_t smx_host_t;
40 typedef struct s_smx_host_priv *smx_host_priv_t;
41 typedef enum {
42   SIMIX_WAITING,
43   SIMIX_READY,
44   SIMIX_RUNNING,
45   SIMIX_DONE,
46   SIMIX_CANCELED,
47   SIMIX_FAILED,
48   SIMIX_SRC_HOST_FAILURE,
49   SIMIX_DST_HOST_FAILURE,
50   SIMIX_SRC_TIMEOUT,
51   SIMIX_DST_TIMEOUT,
52   SIMIX_LINK_FAILURE
53 } e_smx_state_t;
54 /** @} */
55
56
57 typedef struct s_smx_timer* smx_timer_t;
58
59 /* ******************************** Synchro ************************************ */
60 /**
61  * \ingroup simix_synchro_management
62  */
63 typedef struct s_smx_mutex *smx_mutex_t;
64 /**
65  * \ingroup simix_synchro_management
66  */
67 typedef struct s_smx_cond *smx_cond_t;
68 /**
69  * \ingroup simix_synchro_management
70  */
71 typedef struct s_smx_sem *smx_sem_t;
72
73 /********************************** File *************************************/
74 typedef struct s_smx_file *smx_file_t;
75 typedef struct s_smx_stat *smx_stat_t;
76
77 /********************************** Action *************************************/
78 typedef struct s_smx_action *smx_action_t; /* FIXME: replace by specialized action handlers */
79
80
81
82 /* ****************************** Process *********************************** */
83 /** @brief Process datatype
84     @ingroup simix_process_management
85
86     A processt may be defined as a <em>code</em>, with some <em>private
87     data</em>, executing in a <em>location</em>.
88     \see m_process_management
89   @{ */
90 typedef struct s_smx_process *smx_process_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  * smx_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 void (*smx_creation_func_t) ( /* process */ smx_process_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
116
117 /******************************* Networking ***********************************/
118 /**
119  * \ingroup simix_rdv_management
120  */
121 typedef struct s_smx_rvpoint *smx_rdv_t;
122
123 XBT_PUBLIC(void*) SIMIX_comm_get_src_data(smx_action_t action);
124 XBT_PUBLIC(void*) SIMIX_comm_get_dst_data(smx_action_t action);
125
126 /******************************** Context *************************************/
127 typedef struct s_smx_context *smx_context_t;
128 typedef struct s_smx_context_factory *smx_context_factory_t;
129
130 /* Process creation/destruction callbacks */
131 typedef void (*void_pfn_smxprocess_t) (smx_process_t);
132 /* Process kill */
133 typedef void (*void_pfn_smxprocess_t_smxprocess_t) (smx_process_t, smx_process_t);
134 /* for auto-restart function */
135 typedef void (*void_pfn_smxhost_t) (smx_host_t);
136
137 /* The following function pointer types describe the interface that any context
138    factory should implement */
139
140
141 typedef smx_context_t(*smx_pfn_context_factory_create_context_t)
142   (xbt_main_func_t, int, char **, void_pfn_smxprocess_t, void* data);
143 typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*);
144 typedef void (*smx_pfn_context_free_t) (smx_context_t);
145 typedef void (*smx_pfn_context_start_t) (smx_context_t);
146 typedef void (*smx_pfn_context_stop_t) (smx_context_t);
147 typedef void (*smx_pfn_context_suspend_t) (smx_context_t context);
148 typedef void (*smx_pfn_context_runall_t) (void);
149 typedef smx_context_t (*smx_pfn_context_self_t) (void);
150 typedef void* (*smx_pfn_context_get_data_t) (smx_context_t context);
151
152 /* interface of the context factories */
153 typedef struct s_smx_context_factory {
154   const char *name;
155   smx_pfn_context_factory_create_context_t create_context;
156   smx_pfn_context_factory_finalize_t finalize;
157   smx_pfn_context_free_t free;
158   smx_pfn_context_stop_t stop;
159   smx_pfn_context_suspend_t suspend;
160   smx_pfn_context_runall_t runall;
161   smx_pfn_context_self_t self;
162   smx_pfn_context_get_data_t get_data;
163 } s_smx_context_factory_t;
164
165 /* Hack: let msg load directly the right factory */
166 typedef void (*smx_ctx_factory_initializer_t)(smx_context_factory_t*);
167 XBT_PUBLIC(smx_ctx_factory_initializer_t) smx_factory_initializer_to_use;
168 extern char* smx_context_factory_name;
169 extern int smx_context_stack_size;
170 extern int smx_context_stack_size_was_set;
171
172 /* *********************** */
173 /* Context type definition */
174 /* *********************** */
175 /* the following function pointers types describe the interface that all context
176    concepts must implement */
177 /* each context type derive from this structure, so they must contain this structure
178  * at their beginning -- OOP in C :/ */
179 typedef struct s_smx_context {
180   s_xbt_swag_hookup_t hookup;
181   xbt_main_func_t code;
182   void_pfn_smxprocess_t cleanup_func;
183   void *data;   /* Here SIMIX stores the smx_process_t containing the context */
184   char **argv;
185   int argc;
186   unsigned iwannadie:1;
187 } s_smx_ctx_base_t;
188
189 /* methods of this class */
190 XBT_PUBLIC(void) smx_ctx_base_factory_init(smx_context_factory_t *factory);
191 XBT_PUBLIC(int) smx_ctx_base_factory_finalize(smx_context_factory_t *factory);
192
193 XBT_PUBLIC(smx_context_t)
194 smx_ctx_base_factory_create_context_sized(size_t size,
195                                           xbt_main_func_t code, int argc,
196                                           char **argv,
197                                           void_pfn_smxprocess_t cleanup,
198                                           void* data);
199 XBT_PUBLIC(void) smx_ctx_base_free(smx_context_t context);
200 XBT_PUBLIC(void) smx_ctx_base_stop(smx_context_t context);
201 XBT_PUBLIC(smx_context_t) smx_ctx_base_self(void);
202 XBT_PUBLIC(void) *smx_ctx_base_get_data(smx_context_t context);
203
204 XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable(void);
205 XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID);
206 XBT_PUBLIC(xbt_dynar_t) SIMIX_processes_as_dynar(void);
207
208 /* parallelism */
209 XBT_PUBLIC(int) SIMIX_context_is_parallel(void);
210 XBT_PUBLIC(int) SIMIX_context_get_nthreads(void);
211 XBT_PUBLIC(void) SIMIX_context_set_nthreads(int nb_threads);
212 XBT_PUBLIC(int) SIMIX_context_get_parallel_threshold(void);
213 XBT_PUBLIC(void) SIMIX_context_set_parallel_threshold(int threshold);
214 XBT_PUBLIC(e_xbt_parmap_mode_t) SIMIX_context_get_parallel_mode(void);
215 XBT_PUBLIC(void) SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode);
216
217
218
219 /********************************** Global ************************************/
220 /* Initialization and exit */
221 XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
222
223
224 XBT_PUBLIC(void) SIMIX_function_register_process_cleanup(void_pfn_smxprocess_t function);
225 XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t function);
226 XBT_PUBLIC(void) SIMIX_function_register_process_kill(void_pfn_smxprocess_t_smxprocess_t function);
227
228 /* Simulation execution */
229 XBT_PUBLIC(void) SIMIX_run(void);    
230 XBT_PUBLIC(double) SIMIX_get_clock(void);
231
232 /* Timer functions FIXME: should these be public? */
233 XBT_PUBLIC(void) SIMIX_timer_set(double date, void *function, void *arg);
234 XBT_PUBLIC(double) SIMIX_timer_next(void);
235
236 XBT_PUBLIC(void) SIMIX_display_process_status(void);
237
238 /******************************* Environment **********************************/
239 XBT_PUBLIC(void) SIMIX_create_environment(const char *file);
240
241 /******************************** Deployment **********************************/
242
243 XBT_PUBLIC(void) SIMIX_function_register(const char *name, xbt_main_func_t code);
244 XBT_PUBLIC(void) SIMIX_function_register_default(xbt_main_func_t code);
245 XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name);
246 XBT_PUBLIC(void) SIMIX_init_application(void);
247 XBT_PUBLIC(void) SIMIX_launch_application(const char *file);
248
249 XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
250                                             const char *process_function,
251                                             xbt_dynar_t arguments,
252                                             double process_start_time,
253                                             double process_kill_time);
254
255 /*********************************** Host *************************************/
256 //XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(u_smx_scalar_t *args);
257 XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
258 XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
259 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
260 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 */
261 XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
262 XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
263 XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
264 XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
265
266 /********************************* Process ************************************/
267 XBT_PUBLIC(int) SIMIX_process_count(void);
268 XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
269 XBT_PUBLIC(const char*) SIMIX_process_self_get_name(void);
270 XBT_PUBLIC(void) SIMIX_process_self_set_data(smx_process_t self, void *data);
271 XBT_PUBLIC(void*) SIMIX_process_self_get_data(smx_process_t self);
272 XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_process_t);
273 XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c);
274 XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
275 XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_process_t process);
276 XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data);
277
278 /****************************** Communication *********************************/
279 XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, void*, size_t));
280 XBT_PUBLIC(void) SIMIX_comm_copy_pointer_callback(smx_action_t comm, void* buff, size_t buff_size);
281 XBT_PUBLIC(void) SIMIX_comm_copy_buffer_callback(smx_action_t comm, void* buff, size_t buff_size);
282
283 XBT_PUBLIC(smx_action_t) SIMIX_comm_get_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
284 XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
285 XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
286 XBT_PUBLIC(void) SIMIX_comm_finish(smx_action_t action);
287
288 /******************************************************************************/
289 /*                            SIMIX simcalls                                  */
290 /******************************************************************************/
291 /* These functions are a system call-like interface to the simulation kernel. */
292 /* They can also be called from maestro's context, and they are thread safe.  */
293 /******************************************************************************/
294
295 /******************************* Host simcalls ********************************/
296 /* TODO use handlers and keep smx_host_t hidden from higher levels */
297 XBT_PUBLIC(smx_host_t) simcall_host_get_by_name(const char *name);
298 XBT_PUBLIC(const char *) simcall_host_get_name(smx_host_t host);
299 XBT_PUBLIC(xbt_dict_t) simcall_host_get_properties(smx_host_t host);
300 XBT_PUBLIC(double) simcall_host_get_speed(smx_host_t host);
301 XBT_PUBLIC(double) simcall_host_get_available_speed(smx_host_t host);
302 /* Two possible states, 1 - CPU ON and 0 CPU OFF */
303 XBT_PUBLIC(int) simcall_host_get_state(smx_host_t host);
304 XBT_PUBLIC(void *) simcall_host_get_data(smx_host_t host);
305
306 XBT_PUBLIC(void) simcall_host_set_data(smx_host_t host, void *data);
307
308 XBT_PUBLIC(smx_action_t) simcall_host_execute(const char *name, smx_host_t host,
309                                                 double computation_amount,
310                                                 double priority);
311 XBT_PUBLIC(smx_action_t) simcall_host_parallel_execute(const char *name,
312                                                      int host_nb,
313                                                      smx_host_t *host_list,
314                                                      double *computation_amount,
315                                                      double *communication_amount,
316                                                      double amount,
317                                                      double rate);
318 XBT_PUBLIC(void) simcall_host_execution_destroy(smx_action_t execution);
319 XBT_PUBLIC(void) simcall_host_execution_cancel(smx_action_t execution);
320 XBT_PUBLIC(double) simcall_host_execution_get_remains(smx_action_t execution);
321 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_get_state(smx_action_t execution);
322 XBT_PUBLIC(void) simcall_host_execution_set_priority(smx_action_t execution, double priority);
323 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
324 XBT_PUBLIC(void) simcall_host_get_params(smx_host_t vm, ws_params_t param);
325 XBT_PUBLIC(void) simcall_host_set_params(smx_host_t vm, ws_params_t param);
326
327 /******************************* VM simcalls ********************************/
328 // Create the vm_workstation at the SURF level
329 XBT_PUBLIC(void*) simcall_vm_create(const char *name, smx_host_t host);
330 XBT_PUBLIC(int) simcall_vm_get_state(smx_host_t vm);
331 XBT_PUBLIC(void) simcall_vm_start(smx_host_t vm);
332 XBT_PUBLIC(void) simcall_vm_migrate(smx_host_t vm, smx_host_t dst_pm);
333 XBT_PUBLIC(void *) simcall_vm_get_pm(smx_host_t vm);
334 XBT_PUBLIC(void) simcall_vm_resume(smx_host_t vm);
335 XBT_PUBLIC(void) simcall_vm_save(smx_host_t vm);
336 XBT_PUBLIC(void) simcall_vm_restore(smx_host_t vm);
337 XBT_PUBLIC(void) simcall_vm_suspend(smx_host_t vm);
338 XBT_PUBLIC(void) simcall_vm_destroy(smx_host_t vm);
339 XBT_PUBLIC(void) simcall_vm_shutdown(smx_host_t vm);
340
341 /**************************** Process simcalls ********************************/
342 /* Constructor and Destructor */
343 XBT_PUBLIC(void) simcall_process_create(smx_process_t *process,
344                                           const char *name,
345                                           xbt_main_func_t code,
346                                           void *data,
347                                           const char *hostname,
348                                           double kill_time,
349                                           int argc, char **argv,
350                                           xbt_dict_t properties,
351                                           int auto_restart);
352
353 XBT_PUBLIC(void) simcall_process_kill(smx_process_t process);
354 XBT_PUBLIC(void) simcall_process_killall(int reset_pid);
355
356 /* Process handling */
357 XBT_PUBLIC(void) simcall_process_cleanup(smx_process_t process);
358 XBT_PUBLIC(void) simcall_process_change_host(smx_process_t process,
359                  smx_host_t dest);
360 XBT_PUBLIC(void) simcall_process_suspend(smx_process_t process);
361 XBT_PUBLIC(void) simcall_process_resume(smx_process_t process);
362
363 /* Getters and Setters */
364 XBT_PUBLIC(int) simcall_process_count(void);
365 XBT_PUBLIC(void *) simcall_process_get_data(smx_process_t process);
366 XBT_PUBLIC(void) simcall_process_set_data(smx_process_t process, void *data);
367 XBT_PUBLIC(smx_host_t) simcall_process_get_host(smx_process_t process);
368 XBT_PUBLIC(const char *) simcall_process_get_name(smx_process_t process);
369 XBT_PUBLIC(int) simcall_process_get_PID(smx_process_t process);
370 XBT_PUBLIC(int) simcall_process_get_PPID(smx_process_t process);
371 XBT_PUBLIC(int) simcall_process_is_suspended(smx_process_t process);
372 XBT_PUBLIC(xbt_dict_t) simcall_process_get_properties(smx_process_t host);
373 XBT_PUBLIC(void) simcall_process_set_kill_time(smx_process_t process, double kill_time);
374 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data);
375 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart);
376 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process);
377 /* Sleep control */
378 XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration);
379
380 /************************** Comunication simcalls *****************************/
381 /***** Rendez-vous points *****/
382
383 XBT_PUBLIC(smx_rdv_t) simcall_rdv_create(const char *name);
384 XBT_PUBLIC(void) simcall_rdv_destroy(smx_rdv_t rvp);
385 XBT_PUBLIC(smx_rdv_t) simcall_rdv_get_by_name(const char *name);
386 XBT_PUBLIC(int) simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host);
387 XBT_PUBLIC(smx_action_t) simcall_rdv_get_head(smx_rdv_t rdv);
388 XBT_PUBLIC(smx_process_t) simcall_rdv_get_receiver(smx_rdv_t rdv);
389 XBT_PUBLIC(void) simcall_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process);
390
391 XBT_PUBLIC(xbt_dict_t) SIMIX_get_rdv_points(void);
392
393 /***** Communication simcalls *****/
394
395 XBT_PUBLIC(void) simcall_comm_send(smx_rdv_t rdv, double task_size,
396                                      double rate, void *src_buff,
397                                      size_t src_buff_size,
398                                      int (*match_fun)(void *, void *, smx_action_t),
399                                      void *data, double timeout);
400
401 XBT_PUBLIC(smx_action_t) simcall_comm_isend(smx_rdv_t rdv, double task_size,
402                                               double rate, void *src_buff,
403                                               size_t src_buff_size,
404                                               int (*match_fun)(void *, void *, smx_action_t),
405                                               void (*clean_fun)(void *),
406                                               void *data, int detached);
407
408 XBT_PUBLIC(void) simcall_comm_recv(smx_rdv_t rdv, void *dst_buff,
409                                      size_t * dst_buff_size,
410                                      int (*match_fun)(void *, void *, smx_action_t),
411                                      void *data, double timeout);
412
413 XBT_PUBLIC(smx_action_t) simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff,
414                                               size_t * dst_buff_size,
415                                               int (*match_fun)(void *, void *, smx_action_t),
416                                               void *data);
417
418 XBT_PUBLIC(void) simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff,
419                                      size_t * dst_buff_size,
420                                      int (*match_fun)(void *, void *, smx_action_t),
421                                      void *data, double timeout, double rate);
422
423 XBT_PUBLIC(smx_action_t) simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff,
424                                               size_t * dst_buff_size,
425                                               int (*match_fun)(void *, void *, smx_action_t),
426                                               void *data, double rate);
427
428 XBT_PUBLIC(void) simcall_comm_destroy(smx_action_t comm);
429 XBT_PUBLIC(smx_action_t) simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
430                                 int (*match_fun)(void *, void *, smx_action_t), void *data);
431 XBT_PUBLIC(void) simcall_comm_cancel(smx_action_t comm);
432
433 /* FIXME: waitany is going to be a vararg function, and should take a timeout */
434 XBT_PUBLIC(unsigned int) simcall_comm_waitany(xbt_dynar_t comms);
435 XBT_PUBLIC(void) simcall_comm_wait(smx_action_t comm, double timeout);
436 XBT_PUBLIC(int) simcall_comm_test(smx_action_t comm);
437 XBT_PUBLIC(int) simcall_comm_testany(xbt_dynar_t comms);
438
439 /* Getters and setters */
440 XBT_PUBLIC(double) simcall_comm_get_remains(smx_action_t comm);
441 XBT_PUBLIC(e_smx_state_t) simcall_comm_get_state(smx_action_t comm);
442 XBT_PUBLIC(void *) simcall_comm_get_src_data(smx_action_t comm);
443 XBT_PUBLIC(void *) simcall_comm_get_dst_data(smx_action_t comm);
444 XBT_PUBLIC(smx_process_t) simcall_comm_get_src_proc(smx_action_t comm);
445 XBT_PUBLIC(smx_process_t) simcall_comm_get_dst_proc(smx_action_t comm);
446
447 #ifdef HAVE_LATENCY_BOUND_TRACKING
448 XBT_PUBLIC(int) simcall_comm_is_latency_bounded(smx_action_t comm);
449 #endif
450
451 #ifdef HAVE_TRACING
452 /************************** Tracing handling **********************************/
453 XBT_PUBLIC(void) simcall_set_category(smx_action_t action, const char *category);
454 #endif
455
456 /************************** Synchro simcalls **********************************/
457
458 XBT_PUBLIC(smx_mutex_t) simcall_mutex_init(void);
459 XBT_PUBLIC(void) simcall_mutex_destroy(smx_mutex_t mutex);
460 XBT_PUBLIC(void) simcall_mutex_lock(smx_mutex_t mutex);
461 XBT_PUBLIC(int) simcall_mutex_trylock(smx_mutex_t mutex);
462 XBT_PUBLIC(void) simcall_mutex_unlock(smx_mutex_t mutex);
463
464 XBT_PUBLIC(smx_cond_t) simcall_cond_init(void);
465 XBT_PUBLIC(void) simcall_cond_destroy(smx_cond_t cond);
466 XBT_PUBLIC(void) simcall_cond_signal(smx_cond_t cond);
467 XBT_PUBLIC(void) simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex);
468 XBT_PUBLIC(void) simcall_cond_wait_timeout(smx_cond_t cond,
469                                          smx_mutex_t mutex,
470                                          double max_duration);
471 XBT_PUBLIC(void) simcall_cond_broadcast(smx_cond_t cond);
472
473 XBT_PUBLIC(smx_sem_t) simcall_sem_init(int capacity);
474 XBT_PUBLIC(void) simcall_sem_destroy(smx_sem_t sem);
475 XBT_PUBLIC(void) simcall_sem_release(smx_sem_t sem);
476 XBT_PUBLIC(int) simcall_sem_would_block(smx_sem_t sem);
477 XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem);
478 XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem,
479                                            double max_duration);
480 XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
481
482 XBT_PUBLIC(double) simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream);
483 XBT_PUBLIC(size_t) simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream);
484 XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path, const char* mode);
485 XBT_PUBLIC(int) simcall_file_close(smx_file_t fp);
486 XBT_PUBLIC(int) simcall_file_stat(smx_file_t fd, s_file_stat_t *buf);
487 XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd);
488 XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path);
489
490 /************************** AS router   **********************************/
491 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
492 /************************** AS router simcalls ***************************/
493 XBT_PUBLIC(xbt_dict_t) simcall_asr_get_properties(const char *name);
494
495 /************************** MC simcalls   **********************************/
496 XBT_PUBLIC(void *) simcall_mc_snapshot(void);
497 XBT_PUBLIC(int) simcall_mc_compare_snapshots(void *s1, void *s2);
498 XBT_PUBLIC(int) simcall_mc_random(void);
499
500 /************************** New API simcalls **********************************/
501 /* TUTORIAL: New API                                                          */
502 /******************************************************************************/
503 XBT_PUBLIC(int) simcall_new_api_fct(const char* param1, double param2);
504
505 SG_END_DECL()
506 #endif                          /* _SIMIX_SIMIX_H */