Logo AND Algorithmique Numérique Distribuée

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