Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b595bf6ee73d6742c43036d04e3af49d29cecc6f
[simgrid.git] / include / simgrid / simix.h
1 /* Copyright (c) 2007-2010, 2012-2013. 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
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
73 typedef struct s_smx_file *smx_file_t;
74
75 /********************************** Storage *************************************/
76 typedef xbt_dictelm_t smx_storage_t;
77 typedef struct s_smx_storage_priv *smx_storage_priv_t;
78
79 /********************************** Action *************************************/
80 typedef struct s_smx_action *smx_action_t; /* FIXME: replace by specialized action handlers */
81
82
83
84 /* ****************************** Process *********************************** */
85 /** @brief Process datatype
86     @ingroup simix_process_management
87
88     A processt may be defined as a <em>code</em>, with some <em>private
89     data</em>, executing in a <em>location</em>.
90     \see m_process_management
91   @{ */
92 typedef struct s_smx_process *smx_process_t;
93 /** @} */
94
95
96 /*
97  * Type of function that creates a process.
98  * The function must accept the following parameters:
99  * void* process: the process created will be stored there
100  * const char *name: a name for the object. It is for user-level information and can be NULL
101  * xbt_main_func_t code: is a function describing the behavior of the process
102  * void *data: data a pointer to any data one may want to attach to the new object.
103  * smx_host_t host: the location where the new process is executed
104  * int argc, char **argv: parameters passed to code
105  * xbt_dict_t pros: properties
106  */
107 typedef void (*smx_creation_func_t) ( /* process */ smx_process_t*,
108                                       /* name */ const char*,
109                                       /* code */ xbt_main_func_t,
110                                       /* userdata */ void*,
111                                       /* hostname */ const char*,
112                                       /* kill_time */ double,
113                                       /* argc */ int,
114                                       /* argv */ char**,
115                                       /* props */ xbt_dict_t,
116                                       /* auto_restart */ int);
117
118
119 /******************************* Networking ***********************************/
120 /**
121  * \ingroup simix_rdv_management
122  */
123 typedef struct s_smx_rvpoint *smx_rdv_t;
124
125 XBT_PUBLIC(void*) SIMIX_comm_get_src_data(smx_action_t action);
126 XBT_PUBLIC(void*) SIMIX_comm_get_dst_data(smx_action_t action);
127
128 /******************************** Context *************************************/
129 typedef struct s_smx_context *smx_context_t;
130 typedef struct s_smx_context_factory *smx_context_factory_t;
131
132 /* Process creation/destruction callbacks */
133 typedef void (*void_pfn_smxprocess_t) (smx_process_t);
134 /* Process kill */
135 typedef void (*void_pfn_smxprocess_t_smxprocess_t) (smx_process_t, smx_process_t);
136 /* for auto-restart function */
137 typedef void (*void_pfn_smxhost_t) (smx_host_t);
138
139 /* The following function pointer types describe the interface that any context
140    factory should implement */
141
142
143 typedef smx_context_t(*smx_pfn_context_factory_create_context_t)
144   (xbt_main_func_t, int, char **, void_pfn_smxprocess_t, void* data);
145 typedef int (*smx_pfn_context_factory_finalize_t) (smx_context_factory_t*);
146 typedef void (*smx_pfn_context_free_t) (smx_context_t);
147 typedef void (*smx_pfn_context_start_t) (smx_context_t);
148 typedef void (*smx_pfn_context_stop_t) (smx_context_t);
149 typedef void (*smx_pfn_context_suspend_t) (smx_context_t context);
150 typedef void (*smx_pfn_context_runall_t) (void);
151 typedef smx_context_t (*smx_pfn_context_self_t) (void);
152 typedef void* (*smx_pfn_context_get_data_t) (smx_context_t context);
153
154 /* interface of the context factories */
155 typedef struct s_smx_context_factory {
156   const char *name;
157   smx_pfn_context_factory_create_context_t create_context;
158   smx_pfn_context_factory_finalize_t finalize;
159   smx_pfn_context_free_t free;
160   smx_pfn_context_stop_t stop;
161   smx_pfn_context_suspend_t suspend;
162   smx_pfn_context_runall_t runall;
163   smx_pfn_context_self_t self;
164   smx_pfn_context_get_data_t get_data;
165 } s_smx_context_factory_t;
166
167 /* Hack: let msg load directly the right factory */
168 typedef void (*smx_ctx_factory_initializer_t)(smx_context_factory_t*);
169 XBT_PUBLIC(smx_ctx_factory_initializer_t) smx_factory_initializer_to_use;
170 extern char* smx_context_factory_name;
171 extern int smx_context_stack_size;
172 extern int smx_context_stack_size_was_set;
173
174 /* *********************** */
175 /* Context type definition */
176 /* *********************** */
177 /* the following function pointers types describe the interface that all context
178    concepts must implement */
179 /* each context type derive from this structure, so they must contain this structure
180  * at their beginning -- OOP in C :/ */
181 typedef struct s_smx_context {
182   s_xbt_swag_hookup_t hookup;
183   xbt_main_func_t code;
184   void_pfn_smxprocess_t cleanup_func;
185   void *data;   /* Here SIMIX stores the smx_process_t containing the context */
186   char **argv;
187   int argc;
188   unsigned iwannadie:1;
189 } s_smx_ctx_base_t;
190
191 /* methods of this class */
192 XBT_PUBLIC(void) smx_ctx_base_factory_init(smx_context_factory_t *factory);
193 XBT_PUBLIC(int) smx_ctx_base_factory_finalize(smx_context_factory_t *factory);
194
195 XBT_PUBLIC(smx_context_t)
196 smx_ctx_base_factory_create_context_sized(size_t size,
197                                           xbt_main_func_t code, int argc,
198                                           char **argv,
199                                           void_pfn_smxprocess_t cleanup,
200                                           void* data);
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(void) *smx_ctx_base_get_data(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 XBT_PUBLIC(void) SIMIX_timer_set(double date, void *function, void *arg);
236 XBT_PUBLIC(double) SIMIX_timer_next(void);
237
238 XBT_PUBLIC(void) SIMIX_display_process_status(void);
239
240 /******************************* Environment **********************************/
241 XBT_PUBLIC(void) SIMIX_create_environment(const char *file);
242
243 /******************************** Deployment **********************************/
244
245 XBT_PUBLIC(void) SIMIX_function_register(const char *name, xbt_main_func_t code);
246 XBT_PUBLIC(void) SIMIX_function_register_default(xbt_main_func_t code);
247 XBT_PUBLIC(xbt_main_func_t) SIMIX_get_registered_function(const char *name);
248 XBT_PUBLIC(void) SIMIX_init_application(void);
249 XBT_PUBLIC(void) SIMIX_launch_application(const char *file);
250
251 XBT_PUBLIC(void) SIMIX_process_set_function(const char* process_host,
252                                             const char *process_function,
253                                             xbt_dynar_t arguments,
254                                             double process_start_time,
255                                             double process_kill_time);
256
257 /*********************************** Host *************************************/
258 //XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_dict(u_smx_scalar_t *args);
259 XBT_PUBLIC(smx_host_t) SIMIX_host_get_by_name(const char *name);
260 XBT_PUBLIC(smx_host_t) SIMIX_host_self(void);
261 XBT_PUBLIC(const char*) SIMIX_host_self_get_name(void);
262 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 */
263 XBT_PUBLIC(void) SIMIX_host_self_set_data(void *data);
264 XBT_PUBLIC(void*) SIMIX_host_self_get_data(void);
265 XBT_PUBLIC(void*) SIMIX_host_get_data(smx_host_t host);
266 XBT_PUBLIC(void) SIMIX_host_set_data(smx_host_t host, void *data);
267 XBT_PUBLIC(xbt_dict_t) SIMIX_host_get_storage_list(smx_host_t host);
268 /********************************* Process ************************************/
269 XBT_PUBLIC(int) SIMIX_process_count(void);
270 XBT_PUBLIC(smx_process_t) SIMIX_process_self(void);
271 XBT_PUBLIC(const char*) SIMIX_process_self_get_name(void);
272 XBT_PUBLIC(void) SIMIX_process_self_set_data(smx_process_t self, void *data);
273 XBT_PUBLIC(void*) SIMIX_process_self_get_data(smx_process_t self);
274 XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_process_t);
275 XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c);
276 XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
277 XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_process_t process);
278 XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data);
279
280 /****************************** Communication *********************************/
281 XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, void*, size_t));
282 XBT_PUBLIC(void) SIMIX_comm_copy_pointer_callback(smx_action_t comm, void* buff, size_t buff_size);
283 XBT_PUBLIC(void) SIMIX_comm_copy_buffer_callback(smx_action_t comm, void* buff, size_t buff_size);
284
285 XBT_PUBLIC(smx_action_t) SIMIX_comm_get_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
286 XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
287 XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_rdv_t rdv, int (*match_fun)(void*, void*), void* data);
288 XBT_PUBLIC(void) SIMIX_comm_finish(smx_action_t action);
289
290 /*********************************** File *************************************/
291 XBT_PUBLIC(void*) SIMIX_file_get_data(smx_file_t fd);
292 XBT_PUBLIC(void) SIMIX_file_set_data(smx_file_t fd, void *data);
293
294 /******************************************************************************/
295 /*                            SIMIX simcalls                                  */
296 /******************************************************************************/
297 /* These functions are a system call-like interface to the simulation kernel. */
298 /* They can also be called from maestro's context, and they are thread safe.  */
299 /******************************************************************************/
300
301 /******************************* Host simcalls ********************************/
302 /* TODO use handlers and keep smx_host_t hidden from higher levels */
303 XBT_PUBLIC(smx_host_t) simcall_host_get_by_name(const char *name);
304 XBT_PUBLIC(const char *) simcall_host_get_name(smx_host_t host);
305 XBT_PUBLIC(xbt_dict_t) simcall_host_get_properties(smx_host_t host);
306 XBT_PUBLIC(int) simcall_host_get_core(smx_host_t host);
307 XBT_PUBLIC(xbt_swag_t) simcall_host_get_process_list(smx_host_t host);
308 XBT_PUBLIC(double) simcall_host_get_speed(smx_host_t host);
309 XBT_PUBLIC(double) simcall_host_get_available_speed(smx_host_t host);
310 /* Two possible states, 1 - CPU ON and 0 CPU OFF */
311 XBT_PUBLIC(int) simcall_host_get_state(smx_host_t host);
312 XBT_PUBLIC(void *) simcall_host_get_data(smx_host_t host);
313
314 XBT_PUBLIC(void) simcall_host_set_data(smx_host_t host, void *data);
315
316 XBT_PUBLIC(double) simcall_host_get_current_power_peak(smx_host_t host);
317 XBT_PUBLIC(double) simcall_host_get_power_peak_at(smx_host_t host, int pstate_index);
318 XBT_PUBLIC(int) simcall_host_get_nb_pstates(smx_host_t host);
319 XBT_PUBLIC(void) simcall_host_set_power_peak_at(smx_host_t host, int pstate_index);
320 XBT_PUBLIC(double) simcall_host_get_consumed_energy(smx_host_t host);
321
322 XBT_PUBLIC(smx_action_t) simcall_host_execute(const char *name, smx_host_t host,
323                                                 double computation_amount,
324                                                 double priority);
325 XBT_PUBLIC(smx_action_t) simcall_host_parallel_execute(const char *name,
326                                                      int host_nb,
327                                                      smx_host_t *host_list,
328                                                      double *computation_amount,
329                                                      double *communication_amount,
330                                                      double amount,
331                                                      double rate);
332 XBT_PUBLIC(void) simcall_host_execution_destroy(smx_action_t execution);
333 XBT_PUBLIC(void) simcall_host_execution_cancel(smx_action_t execution);
334 XBT_PUBLIC(double) simcall_host_execution_get_remains(smx_action_t execution);
335 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_get_state(smx_action_t execution);
336 XBT_PUBLIC(void) simcall_host_execution_set_priority(smx_action_t execution, double priority);
337 XBT_PUBLIC(e_smx_state_t) simcall_host_execution_wait(smx_action_t execution);
338 XBT_PUBLIC(xbt_dict_t) simcall_host_get_storage_list(smx_host_t host);
339
340 /**************************** Process simcalls ********************************/
341 /* Constructor and Destructor */
342 XBT_PUBLIC(void) simcall_process_create(smx_process_t *process,
343                                           const char *name,
344                                           xbt_main_func_t code,
345                                           void *data,
346                                           const char *hostname,
347                                           double kill_time,
348                                           int argc, char **argv,
349                                           xbt_dict_t properties,
350                                           int auto_restart);
351
352 XBT_PUBLIC(void) simcall_process_kill(smx_process_t process);
353 XBT_PUBLIC(void) simcall_process_killall(int reset_pid);
354
355 /* Process handling */
356 XBT_PUBLIC(void) simcall_process_cleanup(smx_process_t process);
357 XBT_PUBLIC(void) simcall_process_change_host(smx_process_t process,
358                  smx_host_t dest);
359 XBT_PUBLIC(void) simcall_process_suspend(smx_process_t process);
360 XBT_PUBLIC(void) simcall_process_resume(smx_process_t process);
361
362 /* Getters and Setters */
363 XBT_PUBLIC(int) simcall_process_count(void);
364 XBT_PUBLIC(void *) simcall_process_get_data(smx_process_t process);
365 XBT_PUBLIC(void) simcall_process_set_data(smx_process_t process, void *data);
366 XBT_PUBLIC(smx_host_t) simcall_process_get_host(smx_process_t process);
367 XBT_PUBLIC(const char *) simcall_process_get_name(smx_process_t process);
368 XBT_PUBLIC(int) simcall_process_get_PID(smx_process_t process);
369 XBT_PUBLIC(int) simcall_process_get_PPID(smx_process_t process);
370 XBT_PUBLIC(int) simcall_process_is_suspended(smx_process_t process);
371 XBT_PUBLIC(xbt_dict_t) simcall_process_get_properties(smx_process_t host);
372 XBT_PUBLIC(void) simcall_process_set_kill_time(smx_process_t process, double kill_time);
373 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data);
374 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart);
375 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process);
376 /* Sleep control */
377 XBT_PUBLIC(e_smx_state_t) simcall_process_sleep(double duration);
378
379 /************************** Comunication simcalls *****************************/
380 /***** Rendez-vous points *****/
381
382 XBT_PUBLIC(smx_rdv_t) simcall_rdv_create(const char *name);
383 XBT_PUBLIC(void) simcall_rdv_destroy(smx_rdv_t rvp);
384 XBT_PUBLIC(smx_rdv_t) simcall_rdv_get_by_name(const char *name);
385 XBT_PUBLIC(int) simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host);
386 XBT_PUBLIC(smx_action_t) simcall_rdv_get_head(smx_rdv_t rdv);
387 XBT_PUBLIC(smx_process_t) simcall_rdv_get_receiver(smx_rdv_t rdv);
388 XBT_PUBLIC(void) simcall_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process);
389
390 XBT_PUBLIC(xbt_dict_t) SIMIX_get_rdv_points(void);
391
392 /***** Communication simcalls *****/
393
394 XBT_PUBLIC(void) simcall_comm_send(smx_rdv_t rdv, double task_size,
395                                      double rate, void *src_buff,
396                                      size_t src_buff_size,
397                                      int (*match_fun)(void *, void *, smx_action_t),
398                                      void *data, double timeout);
399
400 XBT_PUBLIC(smx_action_t) simcall_comm_isend(smx_rdv_t rdv, double task_size,
401                                               double rate, void *src_buff,
402                                               size_t src_buff_size,
403                                               int (*match_fun)(void *, void *, smx_action_t),
404                                               void (*clean_fun)(void *),
405                                               void *data, int detached);
406
407 XBT_PUBLIC(void) simcall_comm_recv(smx_rdv_t rdv, void *dst_buff,
408                                      size_t * dst_buff_size,
409                                      int (*match_fun)(void *, void *, smx_action_t),
410                                      void *data, double timeout);
411
412 XBT_PUBLIC(smx_action_t) simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff,
413                                               size_t * dst_buff_size,
414                                               int (*match_fun)(void *, void *, smx_action_t),
415                                               void *data);
416
417 XBT_PUBLIC(void) simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff,
418                                      size_t * dst_buff_size,
419                                      int (*match_fun)(void *, void *, smx_action_t),
420                                      void *data, double timeout, double rate);
421
422 XBT_PUBLIC(smx_action_t) simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff,
423                                               size_t * dst_buff_size,
424                                               int (*match_fun)(void *, void *, smx_action_t),
425                                               void *data, double rate);
426
427 XBT_PUBLIC(void) simcall_comm_destroy(smx_action_t comm);
428 XBT_PUBLIC(smx_action_t) simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
429                                 int (*match_fun)(void *, void *, smx_action_t), void *data);
430 XBT_PUBLIC(void) simcall_comm_cancel(smx_action_t comm);
431
432 /* FIXME: waitany is going to be a vararg function, and should take a timeout */
433 XBT_PUBLIC(unsigned int) simcall_comm_waitany(xbt_dynar_t comms);
434 XBT_PUBLIC(void) simcall_comm_wait(smx_action_t comm, double timeout);
435 XBT_PUBLIC(int) simcall_comm_test(smx_action_t comm);
436 XBT_PUBLIC(int) simcall_comm_testany(xbt_dynar_t comms);
437
438 /* Getters and setters */
439 XBT_PUBLIC(double) simcall_comm_get_remains(smx_action_t comm);
440 XBT_PUBLIC(e_smx_state_t) simcall_comm_get_state(smx_action_t comm);
441 XBT_PUBLIC(void *) simcall_comm_get_src_data(smx_action_t comm);
442 XBT_PUBLIC(void *) simcall_comm_get_dst_data(smx_action_t comm);
443 XBT_PUBLIC(smx_process_t) simcall_comm_get_src_proc(smx_action_t comm);
444 XBT_PUBLIC(smx_process_t) simcall_comm_get_dst_proc(smx_action_t comm);
445
446 #ifdef HAVE_LATENCY_BOUND_TRACKING
447 XBT_PUBLIC(int) simcall_comm_is_latency_bounded(smx_action_t comm);
448 #endif
449
450 #ifdef HAVE_TRACING
451 /************************** Tracing handling **********************************/
452 XBT_PUBLIC(void) simcall_set_category(smx_action_t action, const char *category);
453 #endif
454
455 /************************** Synchro simcalls **********************************/
456
457 XBT_PUBLIC(smx_mutex_t) simcall_mutex_init(void);
458 XBT_PUBLIC(void) simcall_mutex_destroy(smx_mutex_t mutex);
459 XBT_PUBLIC(void) simcall_mutex_lock(smx_mutex_t mutex);
460 XBT_PUBLIC(int) simcall_mutex_trylock(smx_mutex_t mutex);
461 XBT_PUBLIC(void) simcall_mutex_unlock(smx_mutex_t mutex);
462
463 XBT_PUBLIC(smx_cond_t) simcall_cond_init(void);
464 XBT_PUBLIC(void) simcall_cond_destroy(smx_cond_t cond);
465 XBT_PUBLIC(void) simcall_cond_signal(smx_cond_t cond);
466 XBT_PUBLIC(void) simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex);
467 XBT_PUBLIC(void) simcall_cond_wait_timeout(smx_cond_t cond,
468                                          smx_mutex_t mutex,
469                                          double max_duration);
470 XBT_PUBLIC(void) simcall_cond_broadcast(smx_cond_t cond);
471
472 XBT_PUBLIC(smx_sem_t) simcall_sem_init(int capacity);
473 XBT_PUBLIC(void) simcall_sem_destroy(smx_sem_t sem);
474 XBT_PUBLIC(void) simcall_sem_release(smx_sem_t sem);
475 XBT_PUBLIC(int) simcall_sem_would_block(smx_sem_t sem);
476 XBT_PUBLIC(void) simcall_sem_acquire(smx_sem_t sem);
477 XBT_PUBLIC(void) simcall_sem_acquire_timeout(smx_sem_t sem,
478                                              double max_duration);
479 XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
480
481 /*****************************   File   **********************************/
482 XBT_PUBLIC(void *) simcall_file_get_data(smx_file_t fd);
483 XBT_PUBLIC(void) simcall_file_set_data(smx_file_t fd, void *data);
484 XBT_PUBLIC(sg_storage_size_t) simcall_file_read(smx_file_t fd, sg_storage_size_t size);
485 XBT_PUBLIC(sg_storage_size_t) simcall_file_write(smx_file_t fd, sg_storage_size_t size);
486 XBT_PUBLIC(smx_file_t) simcall_file_open(const char* storage, const char* path);
487 XBT_PUBLIC(int) simcall_file_close(smx_file_t fd);
488 XBT_PUBLIC(int) simcall_file_unlink(smx_file_t fd);
489 XBT_PUBLIC(xbt_dict_t) simcall_file_ls(const char* mount, const char* path);
490 XBT_PUBLIC(sg_storage_size_t) simcall_file_get_size(smx_file_t fd);
491 XBT_PUBLIC(xbt_dynar_t) simcall_file_get_info(smx_file_t fd);
492 XBT_PUBLIC(void) simcall_file_rename(smx_file_t fd, const char* new_name);
493 /*****************************   Storage   **********************************/
494 XBT_PUBLIC(sg_storage_size_t) simcall_storage_get_free_size (const char* name);
495 XBT_PUBLIC(sg_storage_size_t) simcall_storage_get_used_size (const char* name);
496 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
497 XBT_PUBLIC(void*) SIMIX_storage_get_data(smx_storage_t storage);
498 XBT_PUBLIC(void) SIMIX_storage_set_data(smx_storage_t storage, void *data);
499 XBT_PUBLIC(xbt_dict_t) SIMIX_storage_get_content(smx_storage_t storage);
500 XBT_PUBLIC(xbt_dict_t) simcall_storage_get_content(smx_storage_t storage);
501 XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_host_t host);
502 XBT_PUBLIC(sg_storage_size_t) SIMIX_storage_get_size(smx_storage_t storage);
503 /************************** AS router   **********************************/
504 XBT_PUBLIC(xbt_dict_t) SIMIX_asr_get_properties(const char *name);
505 /************************** AS router simcalls ***************************/
506 XBT_PUBLIC(xbt_dict_t) simcall_asr_get_properties(const char *name);
507
508 /************************** MC simcalls   **********************************/
509 XBT_PUBLIC(void *) simcall_mc_snapshot(void);
510 XBT_PUBLIC(int) simcall_mc_compare_snapshots(void *s1, void *s2);
511 XBT_PUBLIC(int) simcall_mc_random(int min, int max);
512
513 /************************** New API simcalls **********************************/
514 /* TUTORIAL: New API                                                          */
515 /******************************************************************************/
516 XBT_PUBLIC(int) simcall_new_api_fct(const char* param1, double param2);
517
518 SG_END_DECL()
519 #endif                          /* _SIMIX_SIMIX_H */