Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fdd78b74425fa54c336a51ee636a72fa767cb52d
[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/function_types.h"
14 #include "xbt/parmap.h"
15 #include "xbt/swag.h"
16
17 SG_BEGIN_DECL()
18
19 /**************************** Scalar Values **********************************/
20
21 typedef union u_smx_scalar u_smx_scalar_t;
22
23 /* ******************************** Host ************************************ */
24 /** @brief Host datatype
25     @ingroup simix_host_management
26
27     A <em>location</em> (or <em>host</em>) is any possible place where
28     a process may run. Thus it is represented as a <em>physical
29     resource with computing capabilities</em>, some <em>mailboxes</em>
30     to enable running process to communicate with remote ones, and
31     some <em>private data</em> that can be only accessed by local
32     process.
33
34     \see m_host_management
35   @{ */
36 typedef xbt_dictelm_t smx_host_t;
37 typedef struct s_smx_host_priv *smx_host_priv_t;
38 typedef enum {
39   SIMIX_WAITING,
40   SIMIX_READY,
41   SIMIX_RUNNING,
42   SIMIX_DONE,
43   SIMIX_CANCELED,
44   SIMIX_FAILED,
45   SIMIX_SRC_HOST_FAILURE,
46   SIMIX_DST_HOST_FAILURE,
47   SIMIX_SRC_TIMEOUT,
48   SIMIX_DST_TIMEOUT,
49   SIMIX_LINK_FAILURE
50 } e_smx_state_t;
51 /** @} */
52
53
54 typedef struct s_smx_timer* smx_timer_t;
55
56 /* ******************************** Synchro ************************************ */
57 /**
58  * \ingroup simix_synchro_management
59  */
60 typedef struct s_smx_mutex *smx_mutex_t;
61 /**
62  * \ingroup simix_synchro_management
63  */
64 typedef struct s_smx_cond *smx_cond_t;
65 /**
66  * \ingroup simix_synchro_management
67  */
68 typedef struct s_smx_sem *smx_sem_t;
69
70 /********************************** File *************************************/
71
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
82
83 /* ****************************** Process *********************************** */
84 /** @brief Process datatype
85     @ingroup simix_process_management
86
87     A processt may be defined as a <em>code</em>, with some <em>private
88     data</em>, executing in a <em>location</em>.
89     \see m_process_management
90   @{ */
91 typedef struct s_smx_process *smx_process_t;
92 /** @} */
93
94
95 /*
96  * Type of function that creates a process.
97  * The function must accept the following parameters:
98  * void* process: the process created will be stored there
99  * const char *name: a name for the object. It is for user-level information and can be NULL
100  * xbt_main_func_t code: is a function describing the behavior of the process
101  * void *data: data a pointer to any data one may want to attach to the new object.
102  * smx_host_t host: the location where the new process is executed
103  * int argc, char **argv: parameters passed to code
104  * xbt_dict_t pros: properties
105  */
106 typedef void (*smx_creation_func_t) ( /* process */ smx_process_t*,
107                                       /* name */ const char*,
108                                       /* code */ xbt_main_func_t,
109                                       /* userdata */ void*,
110                                       /* hostname */ const char*,
111                                       /* kill_time */ double,
112                                       /* argc */ int,
113                                       /* argv */ char**,
114                                       /* props */ xbt_dict_t,
115                                       /* auto_restart */ int);
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_action_t action);
125 XBT_PUBLIC(void*) SIMIX_comm_get_dst_data(smx_action_t action);
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_smxhost_t) (smx_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, void* data);
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 void* (*smx_pfn_context_get_data_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_data_t get_data;
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(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
173 /* *********************** */
174 /* Context type definition */
175 /* *********************** */
176 /* the following function pointers types describe the interface that all context
177    concepts must implement */
178 /* each context type derive from this structure, so they must contain this structure
179  * at their beginning -- OOP in C :/ */
180 typedef struct s_smx_context {
181   s_xbt_swag_hookup_t hookup;
182   xbt_main_func_t code;
183   void_pfn_smxprocess_t cleanup_func;
184   void *data;   /* Here SIMIX stores the smx_process_t containing the context */
185   char **argv;
186   int argc;
187   unsigned iwannadie:1;
188 } s_smx_ctx_base_t;
189
190 /* methods of this class */
191 XBT_PUBLIC(void) smx_ctx_base_factory_init(smx_context_factory_t *factory);
192 XBT_PUBLIC(int) smx_ctx_base_factory_finalize(smx_context_factory_t *factory);
193
194 XBT_PUBLIC(smx_context_t)
195 smx_ctx_base_factory_create_context_sized(size_t size,
196                                           xbt_main_func_t code, int argc,
197                                           char **argv,
198                                           void_pfn_smxprocess_t cleanup,
199                                           void* data);
200 XBT_PUBLIC(void) smx_ctx_base_free(smx_context_t context);
201 XBT_PUBLIC(void) smx_ctx_base_stop(smx_context_t context);
202 XBT_PUBLIC(smx_context_t) smx_ctx_base_self(void);
203 XBT_PUBLIC(void) *smx_ctx_base_get_data(smx_context_t context);
204
205 XBT_PUBLIC(xbt_dynar_t) SIMIX_process_get_runnable(void);
206 XBT_PUBLIC(smx_process_t) SIMIX_process_from_PID(int PID);
207 XBT_PUBLIC(xbt_dynar_t) SIMIX_processes_as_dynar(void);
208
209 /* parallelism */
210 XBT_PUBLIC(int) SIMIX_context_is_parallel(void);
211 XBT_PUBLIC(int) SIMIX_context_get_nthreads(void);
212 XBT_PUBLIC(void) SIMIX_context_set_nthreads(int nb_threads);
213 XBT_PUBLIC(int) SIMIX_context_get_parallel_threshold(void);
214 XBT_PUBLIC(void) SIMIX_context_set_parallel_threshold(int threshold);
215 XBT_PUBLIC(e_xbt_parmap_mode_t) SIMIX_context_get_parallel_mode(void);
216 XBT_PUBLIC(void) SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode);
217
218
219
220 /********************************** Global ************************************/
221 /* Initialization and exit */
222 XBT_PUBLIC(void) SIMIX_global_init(int *argc, char **argv);
223
224
225 XBT_PUBLIC(void) SIMIX_function_register_process_cleanup(void_pfn_smxprocess_t function);
226 XBT_PUBLIC(void) SIMIX_function_register_process_create(smx_creation_func_t function);
227 XBT_PUBLIC(void) SIMIX_function_register_process_kill(void_pfn_smxprocess_t_smxprocess_t function);
228
229 /* Simulation execution */
230 XBT_PUBLIC(void) SIMIX_run(void);    
231 XBT_PUBLIC(double) SIMIX_get_clock(void);
232
233 /* Timer functions FIXME: should these be public? */
234 XBT_PUBLIC(void) SIMIX_timer_set(double date, void *function, void *arg);
235 XBT_PUBLIC(double) SIMIX_timer_next(void);
236
237 XBT_PUBLIC(void) SIMIX_display_process_status(void);
238
239 /******************************* Environment **********************************/
240 XBT_PUBLIC(void) SIMIX_create_environment(const char *file);
241
242 /******************************** Deployment **********************************/
243
244 XBT_PUBLIC(void) SIMIX_function_register(const char *name, xbt_main_func_t code);
245 XBT_PUBLIC(void) SIMIX_function_register_default(xbt_main_func_t code);
246 XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name);
247 XBT_PUBLIC(void) SIMIX_init_application(void);
248 XBT_PUBLIC(void) SIMIX_launch_application(const char *file);
249
250 XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
251                                             const char *process_function,
252                                             xbt_dynar_t arguments,
253                                             double process_start_time,
254                                             double process_kill_time);
255
256 /*********************************** Host *************************************/
257 //XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(u_smx_scalar_t *args);
258 XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
259 XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
260 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
261 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 */
262 XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
263 XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
264 XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
265 XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
266 XBT_PUBLIC(xbt_dynar_t) SIMIX_host_get_storage_list(smx_host_t host);
267 XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_host_t host);
268
269 /********************************* Process ************************************/
270 XBT_PUBLIC(int) SIMIX_process_count(void);
271 XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
272 XBT_PUBLIC(const char*) SIMIX_process_self_get_name(void);
273 XBT_PUBLIC(void) SIMIX_process_self_set_data(smx_process_t self, void *data);
274 XBT_PUBLIC(void*) SIMIX_process_self_get_data(smx_process_t self);
275 XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_process_t);
276 XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c);
277 XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
278 XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_process_t process);
279 XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data);
280
281 /****************************** Communication *********************************/
282 XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, void*, size_t));
283 XBT_PUBLIC(void) SIMIX_comm_copy_pointer_callback(smx_action_t comm, void* buff, size_t buff_size);
284 XBT_PUBLIC(void) SIMIX_comm_copy_buffer_callback(smx_action_t comm, void* buff, size_t buff_size);
285
286 XBT_PUBLIC(smx_action_t) SIMIX_comm_get_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
287 XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
288 XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
289 XBT_PUBLIC(void) SIMIX_comm_finish(smx_action_t action);
290
291 /*********************************** File *************************************/
292 XBT_PUBLIC(void*) SIMIX_file_get_data(smx_file_t fd);
293 XBT_PUBLIC(void) SIMIX_file_set_data(smx_file_t fd, void *data);
294
295 /******************************************************************************/
296 /*                            SIMIX simcalls                                  */
297 /******************************************************************************/
298 /* These functions are a system call-like interface to the simulation kernel. */
299 /* They can also be called from maestro's context, and they are thread safe.  */
300 /******************************************************************************/
301
302 /******************************* Host simcalls ********************************/
303 /* TODO use handlers and keep smx_host_t hidden from higher levels */
304 XBT_PUBLIC(smx_host_t) simcall_host_get_by_name(const char *name);
305 XBT_PUBLIC(const char *) simcall_host_get_name(smx_host_t host);
306 XBT_PUBLIC(xbt_dict_t) simcall_host_get_properties(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);
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(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
339 XBT_PUBLIC(xbt_dynar_t) simcall_host_get_storage_list(smx_host_t host);
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 /*****************************   File   **********************************/
483 XBT_PUBLIC(void *) simcall_file_get_data(smx_file_t fd);
484 XBT_PUBLIC(void) simcall_file_set_data(smx_file_t fd, void *data);
485 XBT_PUBLIC(size_t) simcall_file_read(size_t size, smx_file_t fd);
486 XBT_PUBLIC(size_t) simcall_file_write(size_t size, smx_file_t fd);
487 XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path);
488 XBT_PUBLIC(int) simcall_file_close(smx_file_t fd);
489 XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd);
490 XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path);
491 XBT_PUBLIC(size_t) simcall_file_get_size(smx_file_t fd);
492 XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd);
493
494 /*****************************   Storage   **********************************/
495 XBT_PUBLIC(size_t) simcall_storage_get_free_size (const char* name);
496 XBT_PUBLIC(size_t) simcall_storage_get_used_size (const char* name);
497 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
498 XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage);
499 XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data);
500
501 /************************** AS router   **********************************/
502 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
503 /************************** AS router simcalls ***************************/
504 XBT_PUBLIC(xbt_dict_t) simcall_asr_get_properties(const char *name);
505
506 /************************** MC simcalls   **********************************/
507 XBT_PUBLIC(void *) simcall_mc_snapshot(void);
508 XBT_PUBLIC(int) simcall_mc_compare_snapshots(void *s1, void *s2);
509 XBT_PUBLIC(int) simcall_mc_random(int min, int max);
510
511 /************************** New API simcalls **********************************/
512 /* TUTORIAL: New API                                                          */
513 /******************************************************************************/
514 XBT_PUBLIC(int) simcall_new_api_fct(const char* param1, double param2);
515
516 SG_END_DECL()
517 #endif                          /* _SIMIX_SIMIX_H */