Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[smpi,simix-network] remove a useless function
[simgrid.git] / src / simix / smx_user.c
1 /* smx_user.c - public interface to simix                                   */
2
3 /* Copyright (c) 2010, 2011. Da SimGrid team. All rights reserved.          */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef _SVID_SOURCE
8 #  define _SVID_SOURCE    /* strdup() */
9 #endif
10 #ifndef _ISOC99_SOURCE
11 #  define _ISOC99_SOURCE  /* isfinite() */
12 #endif
13 #ifndef _ISO_C99_SOURCE
14 #  define _ISO_C99_SOURCE /* isfinite() */
15 #endif
16 #include <math.h>         /* isfinite() */
17
18 #include "smx_private.h"
19 #include "mc/mc.h"
20 #include "xbt/ex.h"
21
22 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
23
24 static const char* simcall_names[] = {
25 #undef SIMCALL_ENUM_ELEMENT
26 #define SIMCALL_ENUM_ELEMENT(x) #x /* generate strings from the enumeration values */
27 SIMCALL_LIST
28 #undef SIMCALL_ENUM_ELEMENT
29 };
30
31 /**
32  * \ingroup simix_host_management
33  * \brief Returns a host given its name.
34  *
35  * \param name The name of the host to get
36  * \return The corresponding host
37  */
38 smx_host_t simcall_host_get_by_name(const char *name)
39 {
40   smx_simcall_t simcall = SIMIX_simcall_mine();
41
42   simcall->call = SIMCALL_HOST_GET_BY_NAME;
43   simcall->host_get_by_name.name = name;
44   SIMIX_simcall_push(simcall->issuer);
45   return simcall->host_get_by_name.result;
46 }
47
48 /**
49  * \ingroup simix_host_management
50  * \brief Returns the name of a host.
51  *
52  * \param host A SIMIX host
53  * \return The name of this host
54  */
55 const char* simcall_host_get_name(smx_host_t host)
56 {
57   smx_simcall_t simcall = SIMIX_simcall_mine();
58
59   simcall->call = SIMCALL_HOST_GET_NAME;
60   simcall->host_get_name.host = host;
61   SIMIX_simcall_push(simcall->issuer);
62   return simcall->host_get_name.result;
63 }
64
65 /**
66  * \ingroup simix_host_management
67  * \brief Returns a dict of the properties assigned to a host.
68  *
69  * \param host A host
70  * \return The properties of this host
71  */
72 xbt_dict_t simcall_host_get_properties(smx_host_t host)
73 {
74   smx_simcall_t simcall = SIMIX_simcall_mine();
75
76   simcall->call = SIMCALL_HOST_GET_PROPERTIES;
77   simcall->host_get_properties.host = host;
78   SIMIX_simcall_push(simcall->issuer);
79   return simcall->host_get_properties.result;
80 }
81
82 /**
83  * \ingroup simix_host_management
84  * \brief Returns the speed of the processor.
85  *
86  * The speed returned does not take into account the current load on the machine.
87  * \param host A SIMIX host
88  * \return The speed of this host (in Mflop/s)
89  */
90 double simcall_host_get_speed(smx_host_t host)
91 {
92   smx_simcall_t simcall = SIMIX_simcall_mine();
93
94   simcall->call = SIMCALL_HOST_GET_SPEED;
95   simcall->host_get_speed.host = host;
96   SIMIX_simcall_push(simcall->issuer);
97   return simcall->host_get_speed.result;
98 }
99
100 /**
101  * \ingroup simix_host_management
102  * \brief Returns the available speed of the processor.
103  *
104  * \return Speed currently available (in Mflop/s)
105  */
106 double simcall_host_get_available_speed(smx_host_t host)
107 {
108   smx_simcall_t simcall = SIMIX_simcall_mine();
109
110   simcall->call = SIMCALL_HOST_GET_AVAILABLE_SPEED;
111   simcall->host_get_available_speed.host = host;
112   SIMIX_simcall_push(simcall->issuer);
113   return simcall->host_get_available_speed.result;
114 }
115
116 /**
117  * \ingroup simix_host_management
118  * \brief Returns the state of a host.
119  *
120  * Two states are possible: 1 if the host is active or 0 if it has crashed.
121  * \param host A SIMIX host
122  * \return 1 if the host is available, 0 otherwise
123  */
124 int simcall_host_get_state(smx_host_t host)
125 {
126   smx_simcall_t simcall = SIMIX_simcall_mine();
127
128   simcall->call = SIMCALL_HOST_GET_STATE;
129   simcall->host_get_state.host = host;
130   SIMIX_simcall_push(simcall->issuer);
131   return simcall->host_get_state.result;
132 }
133
134 /**
135  * \ingroup simix_host_management
136  * \brief Returns the user data associated to a host.
137  *
138  * \param host SIMIX host
139  * \return the user data of this host
140  */
141 void* simcall_host_get_data(smx_host_t host)
142 {
143   smx_simcall_t simcall = SIMIX_simcall_mine();
144
145   simcall->call = SIMCALL_HOST_GET_DATA;
146   simcall->host_get_data.host = host;
147   SIMIX_simcall_push(simcall->issuer);
148   return simcall->host_get_data.result;
149 }
150
151 /**
152  * \ingroup simix_host_management
153  * \brief Sets the user data associated to a host.
154  *
155  * The host must not have previous user data associated to it.
156  * \param host A SIMIX host
157  * \param data The user data to set
158  */
159 void simcall_host_set_data(smx_host_t host, void *data)
160 {
161   smx_simcall_t simcall = SIMIX_simcall_mine();
162
163   simcall->call = SIMCALL_HOST_SET_DATA;
164   simcall->host_set_data.host = host;
165   simcall->host_set_data.data = data;
166   SIMIX_simcall_push(simcall->issuer);
167 }
168
169 /**
170  * \ingroup simix_host_management
171  * \brief Creates an action that executes some computation of an host.
172  *
173  * This function creates a SURF action and allocates the data necessary
174  * to create the SIMIX action. It can raise a host_error exception if the host crashed.
175  *
176  * \param name Name of the execution action to create
177  * \param host SIMIX host where the action will be executed
178  * \param computation_amount amount Computation amount (in bytes)
179  * \param priority computation priority
180  * \return A new SIMIX execution action
181  */
182 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
183                                     double computation_amount,
184                                     double priority)
185 {
186   /* checking for infinite values */
187   xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
188   xbt_assert(isfinite(priority), "priority is not finite!");
189   
190   smx_simcall_t simcall = SIMIX_simcall_mine();
191
192   simcall->call = SIMCALL_HOST_EXECUTE;
193   simcall->host_execute.name = name;
194   simcall->host_execute.host = host;
195   simcall->host_execute.computation_amount = computation_amount;
196   simcall->host_execute.priority = priority;
197   SIMIX_simcall_push(simcall->issuer);
198   return simcall->host_execute.result;
199 }
200
201 /**
202  * \ingroup simix_host_management
203  * \brief Creates an action that may involve parallel computation on
204  * several hosts and communication between them.
205  *
206  * \param name Name of the execution action to create
207  * \param host_nb Number of hosts where the action will be executed
208  * \param host_list Array (of size host_nb) of hosts where the action will be executed
209  * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
210  * \param communication_amount Array (of size host_nb * host_nb) representing the communication
211  * amount between each pair of hosts
212  * \param amount the SURF action amount
213  * \param rate the SURF action rate
214  * \return A new SIMIX execution action
215  */
216 smx_action_t simcall_host_parallel_execute(const char *name,
217                                          int host_nb,
218                                          smx_host_t *host_list,
219                                          double *computation_amount,
220                                          double *communication_amount,
221                                          double amount,
222                                          double rate)
223 {
224   int i,j;
225   /* checking for infinite values */
226   for (i = 0 ; i < host_nb ; ++i) {
227      xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i);
228      for (j = 0 ; j < host_nb ; ++j) {
229         xbt_assert(isfinite(communication_amount[i + host_nb * j]), 
230              "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j);
231      }   
232   }   
233  
234   xbt_assert(isfinite(amount), "amount is not finite!");
235   xbt_assert(isfinite(rate), "rate is not finite!");
236   
237   smx_simcall_t simcall = SIMIX_simcall_mine();
238
239   simcall->call = SIMCALL_HOST_PARALLEL_EXECUTE;
240   simcall->host_parallel_execute.name = name;
241   simcall->host_parallel_execute.host_nb = host_nb;
242   simcall->host_parallel_execute.host_list = host_list;
243   simcall->host_parallel_execute.computation_amount = computation_amount;
244   simcall->host_parallel_execute.communication_amount = communication_amount;
245   simcall->host_parallel_execute.amount = amount;
246   simcall->host_parallel_execute.rate = rate;
247   SIMIX_simcall_push(simcall->issuer);
248   return simcall->host_parallel_execute.result;
249 }
250
251 /**
252  * \ingroup simix_host_management
253  * \brief Destroys an execution action.
254  *
255  * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
256  * \param execution The execution action to destroy
257  */
258 void simcall_host_execution_destroy(smx_action_t execution)
259 {
260   smx_simcall_t simcall = SIMIX_simcall_mine();
261
262   simcall->call = SIMCALL_HOST_EXECUTION_DESTROY;
263   simcall->host_execution_destroy.execution = execution;
264   SIMIX_simcall_push(simcall->issuer);
265 }
266
267 /**
268  * \ingroup simix_host_management
269  * \brief Cancels an execution action.
270  *
271  * This functions stops the execution. It calls a surf function.
272  * \param execution The execution action to cancel
273  */
274 void simcall_host_execution_cancel(smx_action_t execution)
275 {
276   smx_simcall_t simcall = SIMIX_simcall_mine();
277
278   simcall->call = SIMCALL_HOST_EXECUTION_CANCEL;
279   simcall->host_execution_cancel.execution = execution;
280   SIMIX_simcall_push(simcall->issuer);
281 }
282
283 /**
284  * \ingroup simix_host_management
285  * \brief Returns how much of an execution action remains to be done.
286  *
287  * \param execution The execution action
288  * \return The remaining amount
289  */
290 double simcall_host_execution_get_remains(smx_action_t execution)
291 {
292   smx_simcall_t simcall = SIMIX_simcall_mine();
293
294   simcall->call = SIMCALL_HOST_EXECUTION_GET_REMAINS;
295   simcall->host_execution_get_remains.execution = execution;
296   SIMIX_simcall_push(simcall->issuer);
297   return simcall->host_execution_get_remains.result;
298 }
299
300 /**
301  * \ingroup simix_host_management
302  * \brief Returns the state of an execution action.
303  *
304  * \param execution The execution action
305  * \return The state
306  */
307 e_smx_state_t simcall_host_execution_get_state(smx_action_t execution)
308 {
309   smx_simcall_t simcall = SIMIX_simcall_mine();
310
311   simcall->call = SIMCALL_HOST_EXECUTION_GET_STATE;
312   simcall->host_execution_get_state.execution = execution;
313   SIMIX_simcall_push(simcall->issuer);
314   return simcall->host_execution_get_state.result;
315 }
316
317 /**
318  * \ingroup simix_host_management
319  * \brief Changes the priority of an execution action.
320  *
321  * This functions changes the priority only. It calls a surf function.
322  * \param execution The execution action
323  * \param priority The new priority
324  */
325 void simcall_host_execution_set_priority(smx_action_t execution, double priority)
326 {
327   /* checking for infinite values */
328   xbt_assert(isfinite(priority), "priority is not finite!");
329   
330   smx_simcall_t simcall = SIMIX_simcall_mine();
331
332   simcall->call = SIMCALL_HOST_EXECUTION_SET_PRIORITY;
333   simcall->host_execution_set_priority.execution = execution;
334   simcall->host_execution_set_priority.priority = priority;
335   SIMIX_simcall_push(simcall->issuer);
336 }
337
338 /**
339  * \ingroup simix_host_management
340  * \brief Waits for the completion of an execution action and destroy it.
341  *
342  * \param execution The execution action
343  */
344 e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
345 {
346   smx_simcall_t simcall = SIMIX_simcall_mine();
347
348   simcall->call = SIMCALL_HOST_EXECUTION_WAIT;
349   simcall->host_execution_wait.execution = execution;
350   SIMIX_simcall_push(simcall->issuer);
351   return simcall->host_execution_wait.result;
352 }
353
354 /**
355  * \ingroup simix_process_management
356  * \brief Creates and runs a new SIMIX process.
357  *
358  * The structure and the corresponding thread are created and put in the list of ready processes.
359  *
360  * \param process the process created will be stored in this pointer
361  * \param name a name for the process. It is for user-level information and can be NULL.
362  * \param code the main function of the process
363  * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
364  * It can be retrieved with the function \ref simcall_process_get_data.
365  * \param hostname name of the host where the new agent is executed.
366  * \param kill_time time when the process is killed
367  * \param argc first argument passed to \a code
368  * \param argv second argument passed to \a code
369  * \param properties the properties of the process
370  * \param auto_restart either it is autorestarting or not.
371  */
372 void simcall_process_create(smx_process_t *process, const char *name,
373                               xbt_main_func_t code,
374                               void *data,
375                               const char *hostname,
376                               double kill_time,
377                               int argc, char **argv,
378                               xbt_dict_t properties,
379                               int auto_restart)
380 {
381   smx_simcall_t simcall = SIMIX_simcall_mine();
382
383   simcall->call = SIMCALL_PROCESS_CREATE;
384   simcall->process_create.process = process;
385   simcall->process_create.name = name;
386   simcall->process_create.code = code;
387   simcall->process_create.data = data;
388   simcall->process_create.hostname = hostname;
389   simcall->process_create.kill_time = kill_time;
390   simcall->process_create.argc = argc;
391   simcall->process_create.argv = argv;
392   simcall->process_create.properties = properties;
393   simcall->process_create.auto_restart = auto_restart;
394   SIMIX_simcall_push(simcall->issuer);
395 }
396
397 /**
398  * \ingroup simix_process_management
399  * \brief Kills a SIMIX process.
400  *
401  * This function simply kills a  process.
402  *
403  * \param process poor victim
404  */
405 void simcall_process_kill(smx_process_t process)
406 {
407   smx_simcall_t simcall = SIMIX_simcall_mine();
408
409   simcall->call = SIMCALL_PROCESS_KILL;
410   simcall->process_kill.process = process;
411   SIMIX_simcall_push(simcall->issuer);
412 }
413
414 /**
415  * \ingroup simix_process_management
416  * \brief Kills all SIMIX processes.
417  */
418 void simcall_process_killall(void)
419 {
420   smx_simcall_t simcall = SIMIX_simcall_mine();
421
422   simcall->call = SIMCALL_PROCESS_KILLALL;
423   SIMIX_simcall_push(simcall->issuer);
424 }
425
426 /**
427  * \ingroup simix_process_management
428  * \brief Cleans up a SIMIX process.
429  * \param process poor victim (must have already been killed)
430  */
431 void simcall_process_cleanup(smx_process_t process)
432 {
433   smx_simcall_t simcall = SIMIX_simcall_mine();
434
435   simcall->call = SIMCALL_PROCESS_CLEANUP;
436   simcall->process_cleanup.process = process;
437   SIMIX_simcall_push(simcall->issuer);
438 }
439
440 /**
441  * \ingroup simix_process_management
442  * \brief Migrates an agent to another location.
443  *
444  * This function changes the value of the host on which \a process is running.
445  *
446  * \param process the process to migrate
447  * \param dest name of the new host
448  */
449 void simcall_process_change_host(smx_process_t process, smx_host_t dest)
450 {
451   smx_simcall_t simcall = SIMIX_simcall_mine();
452
453   simcall->call = SIMCALL_PROCESS_CHANGE_HOST;
454   simcall->process_change_host.process = process;
455   simcall->process_change_host.dest = dest;
456   SIMIX_simcall_push(simcall->issuer);
457 }
458
459 /**
460  * \ingroup simix_process_management
461  * \brief Suspends a process.
462  *
463  * This function suspends the process by suspending the action
464  * it was waiting for completion.
465  *
466  * \param process a SIMIX process
467  */
468 void simcall_process_suspend(smx_process_t process)
469 {
470   xbt_assert(process, "Invalid parameters");
471
472   smx_simcall_t simcall = SIMIX_simcall_mine();
473
474   simcall->call = SIMCALL_PROCESS_SUSPEND;
475   simcall->process_suspend.process = process;
476   SIMIX_simcall_push(simcall->issuer);
477 }
478
479 /**
480  * \ingroup simix_process_management
481  * \brief Resumes a suspended process.
482  *
483  * This function resumes a suspended process by resuming the action
484  * it was waiting for completion.
485  *
486  * \param process a SIMIX process
487  */
488 void simcall_process_resume(smx_process_t process)
489 {
490   smx_simcall_t simcall = SIMIX_simcall_mine();
491
492   simcall->call = SIMCALL_PROCESS_RESUME;
493   simcall->process_resume.process = process;
494   SIMIX_simcall_push(simcall->issuer);
495 }
496
497 /**
498  * \ingroup simix_process_management
499  * \brief Returns the amount of SIMIX processes in the system
500  *
501  * Maestro internal process is not counted, only user code processes are
502  */
503 int simcall_process_count(void)
504 {
505   smx_simcall_t simcall = SIMIX_simcall_mine();
506
507   simcall->call = SIMCALL_PROCESS_COUNT;
508   SIMIX_simcall_push(simcall->issuer);
509   return simcall->process_count.result;
510 }
511
512 /**
513  * \ingroup simix_process_management
514  * \brief Return the user data of a #smx_process_t.
515  * \param process a SIMIX process
516  * \return the user data of this process
517  */
518 void* simcall_process_get_data(smx_process_t process)
519 {
520   if (process == SIMIX_process_self()) {
521     /* avoid a simcall if this function is called by the process itself */
522     return SIMIX_process_get_data(process);
523   }
524
525   smx_simcall_t simcall = SIMIX_simcall_mine();
526
527   simcall->call = SIMCALL_PROCESS_GET_DATA;
528   simcall->process_get_data.process = process;
529   SIMIX_simcall_push(simcall->issuer);
530   return simcall->process_get_data.result;
531 }
532
533 /**
534  * \ingroup simix_process_management
535  * \brief Set the user data of a #smx_process_t.
536  *
537  * This functions sets the user data associated to \a process.
538  * \param process SIMIX process
539  * \param data User data
540  */
541 void simcall_process_set_data(smx_process_t process, void *data)
542 {
543   if (process == SIMIX_process_self()) {
544     /* avoid a simcall if this function is called by the process itself */
545     SIMIX_process_self_set_data(process, data);
546   }
547   else {
548
549     smx_simcall_t simcall = SIMIX_simcall_mine();
550
551     simcall->call = SIMCALL_PROCESS_SET_DATA;
552     simcall->process_set_data.process = process;
553     simcall->process_set_data.data = data;
554     SIMIX_simcall_push(simcall->issuer);
555   }
556 }
557
558 /**
559  * \ingroup simix_process_management
560  * \brief Set the kill time of a process.
561  * \param process a process
562  * \param kill_time a double
563  */
564 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
565 {
566
567   if (kill_time > SIMIX_get_clock()) {
568     if (simix_global->kill_process_function) {
569       XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
570           process->smx_host->name);
571       SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
572     }
573   }
574 }
575
576 /**
577  * \ingroup simix_process_management
578  * \brief Return the location on which an agent is running.
579  *
580  * This functions returns the smx_host_t corresponding to the location on which
581  * \a process is running.
582  * \param process SIMIX process
583  * \return SIMIX host
584  */
585 smx_host_t simcall_process_get_host(smx_process_t process)
586 {
587   smx_simcall_t simcall = SIMIX_simcall_mine();
588
589   simcall->call = SIMCALL_PROCESS_GET_HOST;
590   simcall->process_get_host.process = process;
591   SIMIX_simcall_push(simcall->issuer);
592   return simcall->process_get_host.result;
593 }
594
595 /**
596  * \ingroup simix_process_management
597  * \brief Return the name of an agent.
598  *
599  * This functions checks whether \a process is a valid pointer or not and return its name.
600  * \param process SIMIX process
601  * \return The process name
602  */
603 const char* simcall_process_get_name(smx_process_t process)
604 {
605   if (process == SIMIX_process_self()) {
606     /* avoid a simcall if this function is called by the process itself */
607     return process->name;
608   }
609
610   smx_simcall_t simcall = SIMIX_simcall_mine();
611
612   simcall->call = SIMCALL_PROCESS_GET_NAME;
613   simcall->process_get_name.process = process;
614   SIMIX_simcall_push(simcall->issuer);
615   return simcall->process_get_name.result;
616 }
617
618 /**
619  * \ingroup simix_process_management
620  * \brief Returns true if the process is suspended .
621  *
622  * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
623  * \param process SIMIX process
624  * \return 1, if the process is suspended, else 0.
625  */
626 int simcall_process_is_suspended(smx_process_t process)
627 {
628   smx_simcall_t simcall = SIMIX_simcall_mine();
629
630   simcall->call = SIMCALL_PROCESS_IS_SUSPENDED;
631   simcall->process_is_suspended.process = process;
632   SIMIX_simcall_push(simcall->issuer);
633   return simcall->process_is_suspended.result;
634 }
635
636 /**
637  * \ingroup simix_process_management
638  * \brief Return the properties
639  *
640  * This functions returns the properties associated with this process
641  */
642 xbt_dict_t simcall_process_get_properties(smx_process_t process)
643 {
644   smx_simcall_t simcall = SIMIX_simcall_mine();
645
646   simcall->call = SIMCALL_PROCESS_GET_PROPERTIES;
647   simcall->process_get_properties.process = process;
648   SIMIX_simcall_push(simcall->issuer);
649   return simcall->process_get_properties.result;
650 }
651 /**
652  * \ingroup simix_process_management
653  * \brief Add an on_exit function
654  * Add an on_exit function which will be executed when the process exits/is killed.
655  */
656 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
657 {
658   smx_simcall_t simcall = SIMIX_simcall_mine();
659
660   simcall->call = SIMCALL_PROCESS_ON_EXIT;
661   simcall->process_on_exit.process = process;
662   simcall->process_on_exit.fun = fun;
663   simcall->process_on_exit.data = data;
664
665   SIMIX_simcall_push(simcall->issuer);
666 }
667 /**
668  * \ingroup simix_process_management
669  * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
670  * Will restart the process when the host comes back up if auto_restart is set to 1.
671  */
672
673 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
674 {
675   smx_simcall_t simcall = SIMIX_simcall_mine();
676
677   simcall->call = SIMCALL_PROCESS_AUTO_RESTART_SET;
678   simcall->process_auto_restart.process = process;
679   simcall->process_auto_restart.auto_restart = auto_restart;
680
681   SIMIX_simcall_push(simcall->issuer);
682 }
683 /**
684  * \ingroup simix_process_management
685  * \brief Restarts the process, killing it and starting it again from scratch.
686  */
687 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
688 {
689   smx_simcall_t simcall = SIMIX_simcall_mine();
690
691   simcall->call = SIMCALL_PROCESS_RESTART;
692   simcall->process_restart.process = process;
693
694   SIMIX_simcall_push(simcall->issuer);
695
696   return simcall->process_restart.result;
697 }
698 /**
699  * \ingroup simix_process_management
700  * \brief Creates a new sleep SIMIX action.
701  *
702  * This function creates a SURF action and allocates the data necessary
703  * to create the SIMIX action. It can raise a host_error exception if the
704  * host crashed. The default SIMIX name of the action is "sleep".
705  *
706  *   \param duration Time duration of the sleep.
707  *   \return A result telling whether the sleep was successful
708  */
709 e_smx_state_t simcall_process_sleep(double duration)
710 {
711   /* checking for infinite values */
712   xbt_assert(isfinite(duration), "duration is not finite!");
713   
714   smx_simcall_t simcall = SIMIX_simcall_mine();
715
716   simcall->call = SIMCALL_PROCESS_SLEEP;
717   simcall->process_sleep.duration = duration;
718   SIMIX_simcall_push(simcall->issuer);
719   return simcall->process_sleep.result;
720 }
721
722 /**
723  *  \ingroup simix_rdv_management
724  *  \brief Creates a new rendez-vous point
725  *  \param name The name of the rendez-vous point
726  *  \return The created rendez-vous point
727  */
728 smx_rdv_t simcall_rdv_create(const char *name)
729 {
730   smx_simcall_t simcall = SIMIX_simcall_mine();
731
732   simcall->call = SIMCALL_RDV_CREATE;
733   simcall->rdv_create.name = name;
734
735   SIMIX_simcall_push(simcall->issuer);
736   return simcall->rdv_create.result;
737 }
738
739
740 /**
741  *  \ingroup simix_rdv_management
742  *  \brief Destroy a rendez-vous point
743  *  \param rdv The rendez-vous point to destroy
744  */
745 void simcall_rdv_destroy(smx_rdv_t rdv)
746 {
747   smx_simcall_t simcall = SIMIX_simcall_mine();
748
749   simcall->call = SIMCALL_RDV_DESTROY;
750   simcall->rdv_destroy.rdv = rdv;
751
752   SIMIX_simcall_push(simcall->issuer);
753 }
754 /**
755  *  \ingroup simix_rdv_management
756  *  \brief Returns a rendez-vous point knowing its name
757  */
758 smx_rdv_t simcall_rdv_get_by_name(const char *name)
759 {
760   xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
761
762   /* FIXME: this is a horrible lost of performance, so we hack it out by
763    * skipping the simcall (for now). It works in parallel, it won't work on
764    * distributed but probably we will change MSG for that. */
765
766   /*
767   smx_simcall_t simcall = simcall_mine();
768   simcall->call = SIMCALL_RDV_GEY_BY_NAME;
769   simcall->rdv_get_by_name.name = name;
770   SIMIX_simcall_push(simcall->issuer);
771   return simcall->rdv_get_by_name.result;*/
772
773   return SIMIX_rdv_get_by_name(name);
774 }
775
776 /**
777  *  \ingroup simix_rdv_management
778  *  \brief Counts the number of communication actions of a given host pending
779  *         on a rendez-vous point.
780  *  \param rdv The rendez-vous point
781  *  \param host The host to be counted
782  *  \return The number of comm actions pending in the rdv
783  */
784 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
785 {
786   smx_simcall_t simcall = SIMIX_simcall_mine();
787
788   simcall->call = SIMCALL_RDV_COMM_COUNT_BY_HOST;
789   simcall->rdv_comm_count_by_host.rdv = rdv;
790   simcall->rdv_comm_count_by_host.host = host;
791
792   SIMIX_simcall_push(simcall->issuer);
793   return simcall->rdv_comm_count_by_host.result;
794 }
795
796 /**
797  *  \ingroup simix_rdv_management
798  *  \brief returns the communication at the head of the rendez-vous
799  *  \param rdv The rendez-vous point
800  *  \return The communication or NULL if empty
801  */
802 smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
803 {
804   smx_simcall_t simcall = SIMIX_simcall_mine();
805
806   simcall->call = SIMCALL_RDV_GET_HEAD;
807   simcall->rdv_get_head.rdv = rdv;
808
809   SIMIX_simcall_push(simcall->issuer);
810   return simcall->rdv_get_head.result;
811 }
812
813 void simcall_rdv_set_receiver(smx_rdv_t rdv , smx_process_t process)
814 {
815   smx_simcall_t simcall = SIMIX_simcall_mine();
816
817   simcall->call = SIMCALL_RDV_SET_RECV;
818   simcall->rdv_set_rcv_proc.rdv = rdv;
819   simcall->rdv_set_rcv_proc.receiver = process;
820
821   SIMIX_simcall_push(simcall->issuer);
822 }
823
824 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
825 {
826   smx_simcall_t simcall = SIMIX_simcall_mine();
827
828   simcall->call = SIMCALL_RDV_GET_RECV;
829   simcall->rdv_get_rcv_proc.rdv = rdv;
830
831   SIMIX_simcall_push(simcall->issuer);
832   return simcall->rdv_get_rcv_proc.result;
833 }
834
835 /**
836  * \ingroup simix_comm_management
837  */
838 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
839                          void *src_buff, size_t src_buff_size,
840                          int (*match_fun)(void *, void *, smx_action_t), void *data,
841                          double timeout)
842 {
843   /* checking for infinite values */
844   xbt_assert(isfinite(task_size), "task_size is not finite!");
845   xbt_assert(isfinite(rate), "rate is not finite!");
846   xbt_assert(isfinite(timeout), "timeout is not finite!");
847   
848   xbt_assert(rdv, "No rendez-vous point defined for send");
849
850   if (MC_IS_ENABLED) {
851     /* the model-checker wants two separate simcalls */
852     smx_action_t comm = simcall_comm_isend(rdv, task_size, rate,
853         src_buff, src_buff_size, match_fun, NULL, data, 0);
854     simcall_comm_wait(comm, timeout);
855   }
856   else {
857     smx_simcall_t simcall = SIMIX_simcall_mine();
858
859     simcall->call = SIMCALL_COMM_SEND;
860     simcall->comm_send.rdv = rdv;
861     simcall->comm_send.task_size = task_size;
862     simcall->comm_send.rate = rate;
863     simcall->comm_send.src_buff = src_buff;
864     simcall->comm_send.src_buff_size = src_buff_size;
865     simcall->comm_send.match_fun = match_fun;
866     simcall->comm_send.data = data;
867     simcall->comm_send.timeout = timeout;
868
869     SIMIX_simcall_push(simcall->issuer);
870   }
871 }
872 /**
873  * \ingroup simix_comm_management
874  */
875 smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
876                               void *src_buff, size_t src_buff_size,
877                               int (*match_fun)(void *, void *, smx_action_t),
878                               void (*clean_fun)(void *),
879                               void *data,
880                               int detached)
881 {
882   /* checking for infinite values */
883   xbt_assert(isfinite(task_size), "task_size is not finite!");
884   xbt_assert(isfinite(rate), "rate is not finite!");
885   
886   xbt_assert(rdv, "No rendez-vous point defined for isend");
887
888   smx_simcall_t simcall = SIMIX_simcall_mine();
889
890   simcall->call = SIMCALL_COMM_ISEND;
891   simcall->comm_isend.rdv = rdv;
892   simcall->comm_isend.task_size = task_size;
893   simcall->comm_isend.rate = rate;
894   simcall->comm_isend.src_buff = src_buff;
895   simcall->comm_isend.src_buff_size = src_buff_size;
896   simcall->comm_isend.match_fun = match_fun;
897   simcall->comm_isend.clean_fun = clean_fun;
898   simcall->comm_isend.data = data;
899   simcall->comm_isend.detached = detached;
900
901   SIMIX_simcall_push(simcall->issuer);
902   return simcall->comm_isend.result;
903 }
904 /**
905  * \ingroup simix_comm_management
906  */
907 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
908                          int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
909 {
910   xbt_assert(isfinite(timeout), "timeout is not finite!");
911   xbt_assert(rdv, "No rendez-vous point defined for recv");
912
913   if (MC_IS_ENABLED) {
914     /* the model-checker wants two separate simcalls */
915     smx_action_t comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
916         match_fun, data);
917     simcall_comm_wait(comm, timeout);
918   }
919   else {
920     smx_simcall_t simcall = SIMIX_simcall_mine();
921
922     simcall->call = SIMCALL_COMM_RECV;
923     simcall->comm_recv.rdv = rdv;
924     simcall->comm_recv.dst_buff = dst_buff;
925     simcall->comm_recv.dst_buff_size = dst_buff_size;
926     simcall->comm_recv.match_fun = match_fun;
927     simcall->comm_recv.data = data;
928     simcall->comm_recv.timeout = timeout;
929
930     SIMIX_simcall_push(simcall->issuer);
931   }
932 }
933 /**
934  * \ingroup simix_comm_management
935  */
936 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
937                                   int (*match_fun)(void *, void *, smx_action_t), void *data)
938 {
939   xbt_assert(rdv, "No rendez-vous point defined for irecv");
940
941   smx_simcall_t simcall = SIMIX_simcall_mine();
942
943   simcall->call = SIMCALL_COMM_IRECV;
944   simcall->comm_irecv.rdv = rdv;
945   simcall->comm_irecv.dst_buff = dst_buff;
946   simcall->comm_irecv.dst_buff_size = dst_buff_size;
947   simcall->comm_irecv.match_fun = match_fun;
948   simcall->comm_irecv.data = data;
949
950   SIMIX_simcall_push(simcall->issuer);
951   return simcall->comm_irecv.result;
952 }
953 void simcall_comm_destroy(smx_action_t comm)
954 {
955   xbt_assert(comm, "Invalid parameter");
956
957   /* FIXME remove this simcall type: comms are auto-destroyed now */
958
959   /*
960   smx_simcall_t simcall = simcall_mine();
961
962   simcall->call = SIMCALL_COMM_DESTROY;
963   simcall->comm_destroy.comm = comm;
964
965   SIMIX_simcall_push(simcall->issuer);
966   */
967 }
968 /**
969  * \ingroup simix_comm_management
970  */
971 void simcall_comm_cancel(smx_action_t comm)
972 {
973   smx_simcall_t simcall = SIMIX_simcall_mine();
974
975   simcall->call = SIMCALL_COMM_CANCEL;
976   simcall->comm_cancel.comm = comm;
977
978   SIMIX_simcall_push(simcall->issuer);
979 }
980 /**
981  * \ingroup simix_comm_management
982  */
983 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
984 {
985   smx_simcall_t simcall = SIMIX_simcall_mine();
986
987   simcall->call = SIMCALL_COMM_WAITANY;
988   simcall->comm_waitany.comms = comms;
989
990   SIMIX_simcall_push(simcall->issuer);
991   return simcall->comm_waitany.result;
992 }
993 /**
994  * \ingroup simix_comm_management
995  */
996 int simcall_comm_testany(xbt_dynar_t comms)
997 {
998   smx_simcall_t simcall = SIMIX_simcall_mine();
999   if (xbt_dynar_is_empty(comms))
1000     return -1;
1001
1002   simcall->call = SIMCALL_COMM_TESTANY;
1003   simcall->comm_testany.comms = comms;
1004
1005   SIMIX_simcall_push(simcall->issuer);
1006   return simcall->comm_testany.result;
1007 }
1008 /**
1009  * \ingroup simix_comm_management
1010  */
1011 void simcall_comm_wait(smx_action_t comm, double timeout)
1012 {
1013   xbt_assert(isfinite(timeout), "timeout is not finite!");
1014   
1015   smx_simcall_t simcall = SIMIX_simcall_mine();
1016
1017   simcall->call = SIMCALL_COMM_WAIT;
1018   simcall->comm_wait.comm = comm;
1019   simcall->comm_wait.timeout = timeout;
1020
1021   SIMIX_simcall_push(simcall->issuer);
1022 }
1023
1024 #ifdef HAVE_TRACING
1025 /**
1026  * \brief Set the category of an action.
1027  *
1028  * This functions changes the category only. It calls a surf function.
1029  * \param execution The execution action
1030  * \param category The tracing category
1031  */
1032 void simcall_set_category(smx_action_t action, const char *category)
1033 {
1034   if (category == NULL) {
1035     return;
1036   }
1037
1038   smx_simcall_t simcall = SIMIX_simcall_mine();
1039
1040   simcall->call = SIMCALL_SET_CATEGORY;
1041   simcall->set_category.action = action;
1042   simcall->set_category.category = category;
1043
1044   SIMIX_simcall_push(simcall->issuer);
1045 }
1046 #endif
1047 /**
1048  * \ingroup simix_comm_management
1049  *
1050  */
1051 int simcall_comm_test(smx_action_t comm)
1052 {
1053   smx_simcall_t simcall = SIMIX_simcall_mine();
1054
1055   simcall->call = SIMCALL_COMM_TEST;
1056   simcall->comm_test.comm = comm;
1057
1058   SIMIX_simcall_push(simcall->issuer);
1059   return simcall->comm_test.result;
1060 }
1061 /**
1062  * \ingroup simix_comm_management
1063  *
1064  */
1065 double simcall_comm_get_remains(smx_action_t comm)
1066 {
1067   smx_simcall_t simcall = SIMIX_simcall_mine();
1068
1069   simcall->call = SIMCALL_COMM_GET_REMAINS;
1070   simcall->comm_get_remains.comm = comm;
1071
1072   SIMIX_simcall_push(simcall->issuer);
1073   return simcall->comm_get_remains.result;
1074 }
1075 /**
1076  * \ingroup simix_comm_management
1077  *
1078  */
1079 e_smx_state_t simcall_comm_get_state(smx_action_t comm)
1080 {
1081   smx_simcall_t simcall = SIMIX_simcall_mine();
1082
1083   simcall->call = SIMCALL_COMM_GET_STATE;
1084   simcall->comm_get_state.comm = comm;
1085
1086   SIMIX_simcall_push(simcall->issuer);
1087   return simcall->comm_get_state.result;
1088 }
1089 /**
1090  * \ingroup simix_comm_management
1091  *
1092  */
1093 void *simcall_comm_get_src_data(smx_action_t comm)
1094 {
1095   smx_simcall_t simcall = SIMIX_simcall_mine();
1096
1097   simcall->call = SIMCALL_COMM_GET_SRC_DATA;
1098   simcall->comm_get_src_data.comm = comm;
1099
1100   SIMIX_simcall_push(simcall->issuer);
1101   return simcall->comm_get_src_data.result;
1102 }
1103 /**
1104  * \ingroup simix_comm_management
1105  *
1106  */
1107 void *simcall_comm_get_dst_data(smx_action_t comm)
1108 {
1109   smx_simcall_t simcall = SIMIX_simcall_mine();
1110
1111   simcall->call = SIMCALL_COMM_GET_DST_DATA;
1112   simcall->comm_get_dst_data.comm = comm;
1113
1114   SIMIX_simcall_push(simcall->issuer);
1115   return simcall->comm_get_dst_data.result;
1116 }
1117 /**
1118  * \ingroup simix_comm_management
1119  *
1120  */
1121 smx_process_t simcall_comm_get_src_proc(smx_action_t comm)
1122 {
1123   smx_simcall_t simcall = SIMIX_simcall_mine();
1124
1125   simcall->call = SIMCALL_COMM_GET_SRC_PROC;
1126   simcall->comm_get_src_proc.comm = comm;
1127
1128   SIMIX_simcall_push(simcall->issuer);
1129   return simcall->comm_get_src_proc.result;
1130 }
1131 /**
1132  * \ingroup simix_comm_management
1133  *
1134  */
1135 smx_process_t simcall_comm_get_dst_proc(smx_action_t comm)
1136 {
1137   smx_simcall_t simcall = SIMIX_simcall_mine();
1138
1139   simcall->call = SIMCALL_COMM_GET_DST_PROC;
1140   simcall->comm_get_dst_proc.comm = comm;
1141
1142   SIMIX_simcall_push(simcall->issuer);
1143   return simcall->comm_get_dst_proc.result;
1144 }
1145
1146 #ifdef HAVE_LATENCY_BOUND_TRACKING
1147 int simcall_comm_is_latency_bounded(smx_action_t comm)
1148 {
1149   smx_simcall_t simcall = SIMIX_simcall_mine();
1150
1151   simcall->call = SIMCALL_COMM_IS_LATENCY_BOUNDED;
1152   simcall->comm_is_latency_bounded.comm = comm;
1153
1154   SIMIX_simcall_push(simcall->issuer);
1155   return simcall->comm_is_latency_bounded.result;
1156 }
1157 #endif
1158 /**
1159  * \ingroup simix_synchro_management
1160  *
1161  */
1162 smx_mutex_t simcall_mutex_init(void)
1163 {
1164   if(!simix_global) {
1165     fprintf(stderr,"You must run MSG_init or gras_init before using MSG or GRAS\n"); // I would have loved using xbt_die but I can't since it is not initialized yet... :)
1166     abort();
1167   }
1168   smx_simcall_t simcall = SIMIX_simcall_mine();
1169
1170   simcall->call = SIMCALL_MUTEX_INIT;
1171
1172   SIMIX_simcall_push(simcall->issuer);
1173   return simcall->mutex_init.result;
1174 }
1175 /**
1176  * \ingroup simix_synchro_management
1177  *
1178  */
1179 void simcall_mutex_destroy(smx_mutex_t mutex)
1180 {
1181   smx_simcall_t simcall = SIMIX_simcall_mine();
1182
1183   simcall->call = SIMCALL_MUTEX_DESTROY;
1184   simcall->mutex_destroy.mutex = mutex;
1185
1186   SIMIX_simcall_push(simcall->issuer);
1187 }
1188 /**
1189  * \ingroup simix_synchro_management
1190  *
1191  */
1192 void simcall_mutex_lock(smx_mutex_t mutex)
1193 {
1194   smx_simcall_t simcall = SIMIX_simcall_mine();
1195
1196   simcall->call = SIMCALL_MUTEX_LOCK;
1197   simcall->mutex_lock.mutex = mutex;
1198
1199   SIMIX_simcall_push(simcall->issuer);
1200 }
1201 /**
1202  * \ingroup simix_synchro_management
1203  *
1204  */
1205 int simcall_mutex_trylock(smx_mutex_t mutex)
1206 {
1207   smx_simcall_t simcall = SIMIX_simcall_mine();
1208
1209   simcall->call = SIMCALL_MUTEX_TRYLOCK;
1210   simcall->mutex_trylock.mutex = mutex;
1211
1212   SIMIX_simcall_push(simcall->issuer);
1213   return simcall->mutex_trylock.result;
1214 }
1215 /**
1216  * \ingroup simix_synchro_management
1217  *
1218  */
1219 void simcall_mutex_unlock(smx_mutex_t mutex)
1220 {
1221   smx_simcall_t simcall = SIMIX_simcall_mine();
1222
1223   simcall->call = SIMCALL_MUTEX_UNLOCK;
1224   simcall->mutex_unlock.mutex = mutex;
1225
1226   SIMIX_simcall_push(simcall->issuer);
1227 }
1228 /**
1229  * \ingroup simix_synchro_management
1230  *
1231  */
1232 smx_cond_t simcall_cond_init(void)
1233 {
1234   smx_simcall_t simcall = SIMIX_simcall_mine();
1235
1236   simcall->call = SIMCALL_COND_INIT;
1237
1238   SIMIX_simcall_push(simcall->issuer);
1239   return simcall->cond_init.result;
1240 }
1241 /**
1242  * \ingroup simix_synchro_management
1243  *
1244  */
1245 void simcall_cond_destroy(smx_cond_t cond)
1246 {
1247   smx_simcall_t simcall = SIMIX_simcall_mine();
1248
1249   simcall->call = SIMCALL_COND_DESTROY;
1250   simcall->cond_destroy.cond = cond;
1251
1252   SIMIX_simcall_push(simcall->issuer);
1253 }
1254 /**
1255  * \ingroup simix_synchro_management
1256  *
1257  */
1258 void simcall_cond_signal(smx_cond_t cond)
1259 {
1260   smx_simcall_t simcall = SIMIX_simcall_mine();
1261
1262   simcall->call = SIMCALL_COND_SIGNAL;
1263   simcall->cond_signal.cond = cond;
1264
1265   SIMIX_simcall_push(simcall->issuer);
1266 }
1267 /**
1268  * \ingroup simix_synchro_management
1269  *
1270  */
1271 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1272 {
1273   smx_simcall_t simcall = SIMIX_simcall_mine();
1274
1275   simcall->call = SIMCALL_COND_WAIT;
1276   simcall->cond_wait.cond = cond;
1277   simcall->cond_wait.mutex = mutex;
1278
1279   SIMIX_simcall_push(simcall->issuer);
1280 }
1281 /**
1282  * \ingroup simix_synchro_management
1283  *
1284  */
1285 void simcall_cond_wait_timeout(smx_cond_t cond,
1286                                  smx_mutex_t mutex,
1287                                  double timeout)
1288 {
1289   xbt_assert(isfinite(timeout), "timeout is not finite!");
1290   
1291   smx_simcall_t simcall = SIMIX_simcall_mine();
1292
1293   simcall->call = SIMCALL_COND_WAIT_TIMEOUT;
1294   simcall->cond_wait_timeout.cond = cond;
1295   simcall->cond_wait_timeout.mutex = mutex;
1296   simcall->cond_wait_timeout.timeout = timeout;
1297
1298   SIMIX_simcall_push(simcall->issuer);
1299 }
1300 /**
1301  * \ingroup simix_synchro_management
1302  *
1303  */
1304 void simcall_cond_broadcast(smx_cond_t cond)
1305 {
1306   smx_simcall_t simcall = SIMIX_simcall_mine();
1307
1308   simcall->call = SIMCALL_COND_BROADCAST;
1309   simcall->cond_broadcast.cond = cond;
1310
1311   SIMIX_simcall_push(simcall->issuer);
1312 }
1313 /**
1314  * \ingroup simix_synchro_management
1315  *
1316  */
1317 smx_sem_t simcall_sem_init(int capacity)
1318 {
1319   smx_simcall_t simcall = SIMIX_simcall_mine();
1320
1321   simcall->call = SIMCALL_SEM_INIT;
1322   simcall->sem_init.capacity = capacity;
1323
1324   SIMIX_simcall_push(simcall->issuer);
1325   return simcall->sem_init.result;
1326 }
1327 /**
1328  * \ingroup simix_synchro_management
1329  *
1330  */
1331 void simcall_sem_destroy(smx_sem_t sem)
1332 {
1333   smx_simcall_t simcall = SIMIX_simcall_mine();
1334
1335   simcall->call = SIMCALL_SEM_DESTROY;
1336   simcall->sem_destroy.sem = sem;
1337
1338   SIMIX_simcall_push(simcall->issuer);
1339 }
1340 /**
1341  * \ingroup simix_synchro_management
1342  *
1343  */
1344 void simcall_sem_release(smx_sem_t sem)
1345 {
1346   smx_simcall_t simcall = SIMIX_simcall_mine();
1347
1348   simcall->call = SIMCALL_SEM_RELEASE;
1349   simcall->sem_release.sem = sem;
1350
1351   SIMIX_simcall_push(simcall->issuer);
1352 }
1353 /**
1354  * \ingroup simix_synchro_management
1355  *
1356  */
1357 int simcall_sem_would_block(smx_sem_t sem)
1358 {
1359   smx_simcall_t simcall = SIMIX_simcall_mine();
1360
1361   simcall->call = SIMCALL_SEM_WOULD_BLOCK;
1362   simcall->sem_would_block.sem = sem;
1363
1364   SIMIX_simcall_push(simcall->issuer);
1365   return simcall->sem_would_block.result;
1366 }
1367 /**
1368  * \ingroup simix_synchro_management
1369  *
1370  */
1371 void simcall_sem_acquire(smx_sem_t sem)
1372 {
1373   smx_simcall_t simcall = SIMIX_simcall_mine();
1374
1375   simcall->call = SIMCALL_SEM_ACQUIRE;
1376   simcall->sem_acquire.sem = sem;
1377
1378   SIMIX_simcall_push(simcall->issuer);
1379 }
1380 /**
1381  * \ingroup simix_synchro_management
1382  *
1383  */
1384 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1385 {
1386   xbt_assert(isfinite(timeout), "timeout is not finite!");
1387   
1388   smx_simcall_t simcall = SIMIX_simcall_mine();
1389
1390   simcall->call = SIMCALL_SEM_ACQUIRE_TIMEOUT;
1391   simcall->sem_acquire_timeout.sem = sem;
1392   simcall->sem_acquire_timeout.timeout = timeout;
1393
1394   SIMIX_simcall_push(simcall->issuer);
1395 }
1396 /**
1397  * \ingroup simix_synchro_management
1398  *
1399  */
1400 int simcall_sem_get_capacity(smx_sem_t sem)
1401 {
1402   smx_simcall_t simcall = SIMIX_simcall_mine();
1403
1404   simcall->call = SIMCALL_SEM_GET_CAPACITY;
1405   simcall->sem_get_capacity.sem = sem;
1406
1407   SIMIX_simcall_push(simcall->issuer);
1408   return simcall->sem_get_capacity.result;
1409 }
1410 /**
1411  * \ingroup simix_file_management
1412  *
1413  */
1414 double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
1415 {
1416   smx_simcall_t simcall = SIMIX_simcall_mine();
1417
1418   simcall->call = SIMCALL_FILE_READ;
1419   simcall->file_read.ptr = ptr;
1420   simcall->file_read.size = size;
1421   simcall->file_read.nmemb = nmemb;
1422   simcall->file_read.stream = stream;
1423   SIMIX_simcall_push(simcall->issuer);
1424
1425   return simcall->file_read.result;
1426 }
1427 /**
1428  * \ingroup simix_file_management
1429  *
1430  */
1431 size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
1432 {
1433   smx_simcall_t simcall = SIMIX_simcall_mine();
1434
1435   simcall->call = SIMCALL_FILE_WRITE;
1436   simcall->file_write.ptr = ptr;
1437   simcall->file_write.size = size;
1438   simcall->file_write.nmemb = nmemb;
1439   simcall->file_write.stream = stream;
1440   SIMIX_simcall_push(simcall->issuer);
1441
1442   return simcall->file_write.result;
1443 }
1444 /**
1445  * \ingroup simix_file_management
1446  * \brief
1447  */
1448 smx_file_t simcall_file_open(const char* mount, const char* path, const char* mode)
1449 {
1450   smx_simcall_t simcall = SIMIX_simcall_mine();
1451
1452   simcall->call = SIMCALL_FILE_OPEN;
1453   simcall->file_open.mount = mount;
1454   simcall->file_open.path = path;
1455   simcall->file_open.mode = mode;
1456   SIMIX_simcall_push(simcall->issuer);
1457
1458   return simcall->file_open.result;
1459 }
1460 /**
1461  * \ingroup simix_file_management
1462  *
1463  */
1464 int simcall_file_close(smx_file_t fp)
1465 {
1466   smx_simcall_t simcall = SIMIX_simcall_mine();
1467
1468   simcall->call = SIMCALL_FILE_CLOSE;
1469   simcall->file_close.fp = fp;
1470   SIMIX_simcall_push(simcall->issuer);
1471
1472   return simcall->file_close.result;
1473 }
1474 /**
1475  * \ingroup simix_file_management
1476  *
1477  */
1478 int simcall_file_stat(smx_file_t fd, s_file_stat_t *buf)
1479 {
1480   smx_simcall_t simcall = SIMIX_simcall_mine();
1481   simcall->call = SIMCALL_FILE_STAT;
1482   simcall->file_stat.fd = fd;
1483
1484   SIMIX_simcall_push(simcall->issuer);
1485
1486   *buf = simcall->file_stat.buf;
1487
1488   return simcall->file_stat.result;
1489 }
1490
1491 /**
1492  * \ingroup simix_file_management
1493  *
1494  */
1495 int simcall_file_unlink(smx_file_t fd)
1496 {
1497   smx_simcall_t simcall = SIMIX_simcall_mine();
1498   simcall->call = SIMCALL_FILE_UNLINK;
1499   simcall->file_unlink.fd = fd;
1500
1501   SIMIX_simcall_push(simcall->issuer);
1502
1503   return simcall->file_unlink.result;
1504 }
1505
1506 /* ************************************************************************** */
1507
1508 /** @brief returns a printable string representing a simcall */
1509 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1510   return simcall_names[kind];
1511 }