Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5c8bfea28c172cedb6b30206fb9ccd265585e633
[simgrid.git] / src / simix / smx_user.c
1 /* smx_user.c - public interface to simix                                   */
2
3 /* Copyright (c) 2010-2013. The SimGrid Team.
4    All rights reserved.                                                     */
5
6 /* This program is free software; you can redistribute it and/or modify it
7  * under the terms of the license (GNU LGPL) which comes with this package. */
8
9 #include "smx_private.h"
10 #include "mc/mc.h"
11 #include "xbt/ex.h"
12 #include <math.h>         /* isfinite() */
13
14 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
15
16 /* generate strings from the enumeration values */
17 static const char* simcall_names[] = {
18 SIMCALL_LIST(SIMCALL_STRING_TYPE, SIMCALL_SEP_COMMA)
19 [SIMCALL_NONE] = "NONE"
20 };
21
22 SIMCALL_LIST(SIMCALL_FUNC, SIMCALL_SEP_NOTHING)
23
24 /**
25  * \ingroup simix_host_management
26  * \brief Returns a host given its name.
27  *
28  * \param name The name of the host to get
29  * \return The corresponding host
30  */
31 smx_host_t simcall_host_get_by_name(const char *name)
32 {
33   return simcall_BODY_host_get_by_name(name);
34 }
35
36 /**
37  * \ingroup simix_host_management
38  * \brief Returns the name of a host.
39  *
40  * \param host A SIMIX host
41  * \return The name of this host
42  */
43 const char* simcall_host_get_name(smx_host_t host)
44 {
45   return simcall_BODY_host_get_name(host);
46 }
47
48 /**
49  * \ingroup simix_host_management
50  * \brief Start the host if it is off
51  *
52  * \param host A SIMIX host
53  */
54 void simcall_host_on(smx_host_t host)
55 {
56   simcall_BODY_host_on(host);
57 }
58
59 /**
60  * \ingroup simix_host_management
61  * \brief Stop the host if it is on
62  *
63  * \param host A SIMIX host
64  */
65 void simcall_host_off(smx_host_t host)
66 {
67   simcall_BODY_host_off(host);
68 }
69
70 /**
71  * \ingroup simix_host_management
72  * \brief Returns a dict of the properties assigned to a host.
73  *
74  * \param host A host
75  * \return The properties of this host
76  */
77 xbt_dict_t simcall_host_get_properties(smx_host_t host)
78 {
79   return simcall_BODY_host_get_properties(host);
80 }
81
82 /**
83  * \ingroup simix_host_management
84  * \brief Returns a dict of the properties assigned to a router or AS.
85  *
86  * \param name The name of the router or AS
87  * \return The properties
88  */
89 xbt_dict_t simcall_asr_get_properties(const char *name)
90 {
91   return simcall_BODY_asr_get_properties(name);
92 }
93
94
95 /**
96  * \ingroup simix_host_management
97  * \brief Returns the speed of the processor.
98  *
99  * The speed returned does not take into account the current load on the machine.
100  * \param host A SIMIX host
101  * \return The speed of this host (in Mflop/s)
102  */
103 double simcall_host_get_speed(smx_host_t host)
104 {
105   return simcall_BODY_host_get_speed(host);
106 }
107
108 /**
109  * \ingroup simix_host_management
110  * \brief Returns the number of core of the processor.
111  *
112  * \param host A SIMIX host
113  * \return The number of core
114  */
115 int simcall_host_get_core(smx_host_t host)
116 {
117   return simcall_BODY_host_get_core(host);
118 }
119
120 /**
121  * \ingroup simix_host_management
122  * \brief Returns the list of processes attached to the host.
123  *
124  * \param host A SIMIX host
125  * \return the swag of attached processes
126  */
127 xbt_swag_t simcall_host_get_process_list(smx_host_t host)
128 {
129   return simcall_BODY_host_get_process_list(host);
130 }
131
132
133 /**
134  * \ingroup simix_host_management
135  * \brief Returns the available speed of the processor.
136  *
137  * \return Speed currently available (in Mflop/s)
138  */
139 double simcall_host_get_available_speed(smx_host_t host)
140 {
141   return simcall_BODY_host_get_available_speed(host);
142 }
143
144 /**
145  * \ingroup simix_host_management
146  * \brief Returns the state of a host.
147  *
148  * Two states are possible: 1 if the host is active or 0 if it has crashed.
149  * \param host A SIMIX host
150  * \return 1 if the host is available, 0 otherwise
151  */
152 int simcall_host_get_state(smx_host_t host)
153 {
154   return simcall_BODY_host_get_state(host);
155 }
156
157 /**
158  * \ingroup simix_host_management
159  * \brief Returns the user data associated to a host.
160  *
161  * \param host SIMIX host
162  * \return the user data of this host
163  */
164 void* simcall_host_get_data(smx_host_t host)
165 {
166   return simcall_BODY_host_get_data(host);
167 }
168
169 /**
170  * \ingroup simix_host_management
171  * \brief Sets the user data associated to a host.
172  *
173  * The host must not have previous user data associated to it.
174  * \param host A SIMIX host
175  * \param data The user data to set
176  */
177 void simcall_host_set_data(smx_host_t host, void *data)
178 {
179   simcall_host_set_data(host, data);
180 }
181
182 /**
183  * \ingroup simix_host_management
184  * \brief Returns the power peak of a host.
185  *
186  * \param host A SIMIX host
187  * \return the current power peak value (double)
188  */
189 double simcall_host_get_current_power_peak(smx_host_t host)
190 {
191   return simcall_BODY_host_get_current_power_peak(host);
192 }
193
194 /**
195  * \ingroup simix_host_management
196  * \brief Returns one power peak (in flops/s) of a host at a given pstate
197  *
198  * \param host A SIMIX host
199  * \param pstate_index pstate to test
200  * \return the current power peak value (double) for pstate_index
201  */
202 double simcall_host_get_power_peak_at(smx_host_t host, int pstate_index)
203 {
204   return simcall_BODY_host_get_power_peak_at(host, pstate_index);
205 }
206
207 /**
208  * \ingroup simix_host_management
209  * \brief Returns the number of power states for a host.
210  *
211  * \param host A SIMIX host
212  * \return the number of power states
213  */
214 int simcall_host_get_nb_pstates(smx_host_t host)
215 {
216   return simcall_BODY_host_get_nb_pstates(host);
217 }
218
219 /**
220  * \ingroup simix_host_management
221  * \brief Sets a new power peak for a host.
222  *
223  * \param host A SIMIX host
224  * \param pstate_index The pstate to which the CPU power will be set
225  * \return void
226  */
227 void simcall_host_set_power_peak_at(smx_host_t host, int pstate_index)
228 {
229         simcall_BODY_host_set_power_peak_at(host, pstate_index);
230 }
231
232 /**
233  * \ingroup simix_host_management
234  * \brief Returns the total energy consumed by the host (in Joules)
235  *
236  * \param host A SIMIX host
237  * \return the energy consumed by the host (double)
238  */
239 double simcall_host_get_consumed_energy(smx_host_t host)
240 {
241   return simcall_BODY_host_get_consumed_energy(host);
242 }
243
244
245 /**
246  * \ingroup simix_host_management
247  * \brief Creates an action that executes some computation of an host.
248  *
249  * This function creates a SURF action and allocates the data necessary
250  * to create the SIMIX action. It can raise a host_error exception if the host crashed.
251  *
252  * \param name Name of the execution action to create
253  * \param host SIMIX host where the action will be executed
254  * \param computation_amount amount Computation amount (in bytes)
255  * \param priority computation priority
256  * \return A new SIMIX execution action
257  */
258 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
259                                     double computation_amount,
260                                     double priority, double bound, unsigned long affinity_mask)
261 {
262   /* checking for infinite values */
263   xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
264   xbt_assert(isfinite(priority), "priority is not finite!");
265   
266   return simcall_BODY_host_execute(name, host, computation_amount, priority, bound, affinity_mask);
267 }
268
269 /**
270  * \ingroup simix_host_management
271  * \brief Creates an action that may involve parallel computation on
272  * several hosts and communication between them.
273  *
274  * \param name Name of the execution action to create
275  * \param host_nb Number of hosts where the action will be executed
276  * \param host_list Array (of size host_nb) of hosts where the action will be executed
277  * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
278  * \param communication_amount Array (of size host_nb * host_nb) representing the communication
279  * amount between each pair of hosts
280  * \param amount the SURF action amount
281  * \param rate the SURF action rate
282  * \return A new SIMIX execution action
283  */
284 smx_action_t simcall_host_parallel_execute(const char *name,
285                                          int host_nb,
286                                          smx_host_t *host_list,
287                                          double *computation_amount,
288                                          double *communication_amount,
289                                          double amount,
290                                          double rate)
291 {
292   int i,j;
293   /* checking for infinite values */
294   for (i = 0 ; i < host_nb ; ++i) {
295      xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i);
296      for (j = 0 ; j < host_nb ; ++j) {
297         xbt_assert(isfinite(communication_amount[i + host_nb * j]), 
298              "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j);
299      }   
300   }   
301  
302   xbt_assert(isfinite(amount), "amount is not finite!");
303   xbt_assert(isfinite(rate), "rate is not finite!");
304   
305   return simcall_BODY_host_parallel_execute(name, host_nb, host_list,
306                                             computation_amount,
307                                             communication_amount,
308                                             amount, rate);
309
310 }
311
312 /**
313  * \ingroup simix_host_management
314  * \brief Destroys an execution action.
315  *
316  * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
317  * \param execution The execution action to destroy
318  */
319 void simcall_host_execution_destroy(smx_action_t execution)
320 {
321   simcall_BODY_host_execution_destroy(execution);
322 }
323
324 /**
325  * \ingroup simix_host_management
326  * \brief Cancels an execution action.
327  *
328  * This functions stops the execution. It calls a surf function.
329  * \param execution The execution action to cancel
330  */
331 void simcall_host_execution_cancel(smx_action_t execution)
332 {
333   simcall_BODY_host_execution_cancel(execution);
334 }
335
336 /**
337  * \ingroup simix_host_management
338  * \brief Returns how much of an execution action remains to be done.
339  *
340  * \param execution The execution action
341  * \return The remaining amount
342  */
343 double simcall_host_execution_get_remains(smx_action_t execution)
344 {
345   return simcall_BODY_host_execution_get_remains(execution);
346 }
347
348 /**
349  * \ingroup simix_host_management
350  * \brief Returns the state of an execution action.
351  *
352  * \param execution The execution action
353  * \return The state
354  */
355 e_smx_state_t simcall_host_execution_get_state(smx_action_t execution)
356 {
357   return simcall_BODY_host_execution_get_state(execution);
358 }
359
360 /**
361  * \ingroup simix_host_management
362  * \brief Changes the priority of an execution action.
363  *
364  * This functions changes the priority only. It calls a surf function.
365  * \param execution The execution action
366  * \param priority The new priority
367  */
368 void simcall_host_execution_set_priority(smx_action_t execution, double priority)
369 {
370   /* checking for infinite values */
371   xbt_assert(isfinite(priority), "priority is not finite!");
372   
373   simcall_BODY_host_execution_set_priority(execution, priority);
374 }
375
376 /**
377  * \ingroup simix_host_management
378  * \brief Changes the capping (the maximum CPU utilization) of an execution action.
379  *
380  * This functions changes the capping only. It calls a surf function.
381  * \param execution The execution action
382  * \param bound The new bound
383  */
384 void simcall_host_execution_set_bound(smx_action_t execution, double bound)
385 {
386   simcall_BODY_host_execution_set_bound(execution, bound);
387 }
388
389 /**
390  * \ingroup simix_host_management
391  * \brief Changes the CPU affinity of an execution action.
392  *
393  * This functions changes the CPU affinity of an execution action. See taskset(1) on Linux.
394  * \param execution The execution action
395  * \param host Host
396  * \param mask Affinity mask
397  */
398 void simcall_host_execution_set_affinity(smx_action_t execution, smx_host_t host, unsigned long mask)
399 {
400   simcall_BODY_host_execution_set_affinity(execution, host, mask);
401 }
402
403 /**
404  * \ingroup simix_host_management
405  * \brief Waits for the completion of an execution action and destroy it.
406  *
407  * \param execution The execution action
408  */
409 e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
410 {
411   return simcall_BODY_host_execution_wait(execution);
412 }
413
414
415 /**
416  * \ingroup simix_vm_management
417  * \brief Create a VM on the given physical host.
418  *
419  * \param name VM name
420  * \param host Physical host
421  *
422  * \return The host object of the VM
423  */
424 void* simcall_vm_create(const char *name, smx_host_t phys_host){
425   /* will jump to SIMIX_pre_vm_create() in src/simix/smx_smurf_private.h */
426   return simcall_BODY_vm_create(name, phys_host);
427 }
428
429 /**
430  * \ingroup simix_vm_management
431  * \brief Start the given VM to the given physical host
432  *
433  * \param vm VM
434  */
435 void simcall_vm_start(smx_host_t vm)
436 {
437   /* will jump to SIMIX_pre_vm_start in src/simix/smx_smurf_private.h */
438   simcall_BODY_vm_start(vm);
439 }
440
441 /**
442  * \ingroup simix_vm_management
443  * \brief Get the state of the given VM
444  *
445  * \param vm VM
446  * \return The state of the VM
447  */
448 int simcall_vm_get_state(smx_host_t vm)
449 {
450   /* will jump to SIMIX_pre_vm_get_state in src/simix/smx_smurf_private.h */
451   return simcall_BODY_vm_get_state(vm);
452 }
453
454 /**
455  * \ingroup simix_vm_management
456  * \brief Get the name of the physical host on which the given VM runs.
457  *
458  * \param vm VM
459  * \return The name of the physical host
460  */
461 void *simcall_vm_get_pm(smx_host_t vm)
462 {
463   /* will jump to SIMIX_pre_vm_migrate in src/simix/smx_smurf_private.h */
464   return simcall_BODY_vm_get_pm(vm);
465 }
466
467 void simcall_vm_set_bound(smx_host_t vm, double bound)
468 {
469   /* will jump to SIMIX_pre_vm_set_bound in src/simix/smx_smurf_private.h */
470   simcall_BODY_vm_set_bound(vm, bound);
471 }
472
473 void simcall_vm_set_affinity(smx_host_t vm, smx_host_t pm, unsigned long mask)
474 {
475   /* will jump to SIMIX_pre_vm_set_affinity in src/simix/smx_smurf_private.h */
476   simcall_BODY_vm_set_affinity(vm, pm, mask);
477 }
478
479 void simcall_host_get_params(smx_host_t vm, ws_params_t params)
480 {
481   /* will jump to SIMIX_pre_host_get_params in src/simix/smx_smurf_private.h */
482   simcall_BODY_host_get_params(vm, params);
483 }
484
485 void simcall_host_set_params(smx_host_t vm, ws_params_t params)
486 {
487   /* will jump to SIMIX_pre_host_set_params in src/simix/smx_smurf_private.h */
488   simcall_BODY_host_set_params(vm, params);
489 }
490
491 /**
492  * \ingroup simix_vm_management
493  * \brief Migrate the given VM to the given physical host
494  *
495  * \param vm VM
496  * \param host Destination physical host
497  */
498 void simcall_vm_migrate(smx_host_t vm, smx_host_t host)
499 {
500   /* will jump to SIMIX_pre_vm_migrate in src/simix/smx_smurf_private.h */
501   simcall_BODY_vm_migrate(vm, host);
502 }
503
504 /**
505  * \ingroup simix_vm_management
506  * \brief Suspend the given VM
507  *
508  * \param vm VM
509  */
510 void simcall_vm_suspend(smx_host_t vm)
511 {
512   /* will jump to SIMIX_pre_vm_suspend in src/simix/smx_smurf_private.h */
513   simcall_BODY_vm_suspend(vm);
514 }
515
516 /**
517  * \ingroup simix_vm_management
518  * \brief Resume the given VM
519  *
520  * \param vm VM
521  */
522 void simcall_vm_resume(smx_host_t vm)
523 {
524   /* will jump to SIMIX_pre_vm_resume in src/simix/smx_smurf_private.h */
525   simcall_BODY_vm_resume(vm);
526 }
527
528 /**
529  * \ingroup simix_vm_management
530  * \brief Save the given VM
531  *
532  * \param vm VM
533  */
534 void simcall_vm_save(smx_host_t vm)
535 {
536   /* will jump to SIMIX_pre_vm_save in src/simix/smx_smurf_private.h */
537   simcall_BODY_vm_save(vm);
538 }
539
540 /**
541  * \ingroup simix_vm_management
542  * \brief Restore the given VM
543  *
544  * \param vm VM
545  */
546 void simcall_vm_restore(smx_host_t vm)
547 {
548   /* will jump to SIMIX_pre_vm_restore in src/simix/smx_smurf_private.h */
549   simcall_BODY_vm_restore(vm);
550 }
551
552 /**
553  * \ingroup simix_vm_management
554  * \brief Shutdown the given VM
555  *
556  * \param vm VM
557  */
558 void simcall_vm_shutdown(smx_host_t vm)
559 {
560   /* will jump to SIMIX_pre_vm_shutdown in src/simix/smx_smurf_private.h */
561   simcall_BODY_vm_shutdown(vm);
562 }
563
564 /**
565  * \ingroup simix_vm_management
566  * \brief Destroy the given VM
567  *
568  * \param vm VM
569  */
570 void simcall_vm_destroy(smx_host_t vm)
571 {
572    /* will jump to SIMIX_pre_vm_destroy in src/simix/smx_smurf_private.h */
573   simcall_BODY_vm_destroy(vm);
574 }
575
576
577 /**
578  * \ingroup simix_process_management
579  * \brief Creates and runs a new SIMIX process.
580  *
581  * The structure and the corresponding thread are created and put in the list of ready processes.
582  *
583  * \param process the process created will be stored in this pointer
584  * \param name a name for the process. It is for user-level information and can be NULL.
585  * \param code the main function of the process
586  * \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.
587  * It can be retrieved with the function \ref simcall_process_get_data.
588  * \param hostname name of the host where the new agent is executed.
589  * \param kill_time time when the process is killed
590  * \param argc first argument passed to \a code
591  * \param argv second argument passed to \a code
592  * \param properties the properties of the process
593  * \param auto_restart either it is autorestarting or not.
594  */
595 void simcall_process_create(smx_process_t *process, const char *name,
596                               xbt_main_func_t code,
597                               void *data,
598                               const char *hostname,
599                               double kill_time,
600                               int argc, char **argv,
601                               xbt_dict_t properties,
602                               int auto_restart)
603 {
604   simcall_BODY_process_create(process, name, code, data, hostname,
605                               kill_time, argc, argv, properties,
606                               auto_restart);
607 }
608
609 /**
610  * \ingroup simix_process_management
611  * \brief Kills a SIMIX process.
612  *
613  * This function simply kills a  process.
614  *
615  * \param process poor victim
616  */
617 void simcall_process_kill(smx_process_t process)
618 {
619   simcall_BODY_process_kill(process);
620 }
621
622 /**
623  * \ingroup simix_process_management
624  * \brief Kills all SIMIX processes.
625  */
626 void simcall_process_killall(int reset_pid)
627 {
628   simcall_BODY_process_killall(reset_pid);
629 }
630
631 /**
632  * \ingroup simix_process_management
633  * \brief Cleans up a SIMIX process.
634  * \param process poor victim (must have already been killed)
635  */
636 void simcall_process_cleanup(smx_process_t process)
637 {
638   simcall_BODY_process_cleanup(process);
639 }
640
641 /**
642  * \ingroup simix_process_management
643  * \brief Migrates an agent to another location.
644  *
645  * This function changes the value of the host on which \a process is running.
646  *
647  * \param process the process to migrate
648  * \param dest name of the new host
649  */
650 void simcall_process_change_host(smx_process_t process, smx_host_t dest)
651 {
652   simcall_BODY_process_change_host(process, dest);
653 }
654
655 /**
656  * \ingroup simix_process_management
657  * \brief Suspends a process.
658  *
659  * This function suspends the process by suspending the action
660  * it was waiting for completion.
661  *
662  * \param process a SIMIX process
663  */
664 void simcall_process_suspend(smx_process_t process)
665 {
666   xbt_assert(process, "Invalid parameters");
667
668   simcall_BODY_process_suspend(process);
669 }
670
671 /**
672  * \ingroup simix_process_management
673  * \brief Resumes a suspended process.
674  *
675  * This function resumes a suspended process by resuming the action
676  * it was waiting for completion.
677  *
678  * \param process a SIMIX process
679  */
680 void simcall_process_resume(smx_process_t process)
681 {
682   simcall_BODY_process_resume(process);
683 }
684
685 /**
686  * \ingroup simix_process_management
687  * \brief Returns the amount of SIMIX processes in the system
688  *
689  * Maestro internal process is not counted, only user code processes are
690  */
691 int simcall_process_count(void)
692 {
693   return simcall_BODY_process_count();
694 }
695
696 /**
697  * \ingroup simix_process_management
698  * \brief Return the PID of a #smx_process_t.
699  * \param process a SIMIX process
700  * \return the PID of this process
701  */
702 int simcall_process_get_PID(smx_process_t process)
703 {
704   if (process == SIMIX_process_self()) {
705     /* avoid a simcall if this function is called by the process itself */
706     return SIMIX_process_get_PID(process);
707   }
708
709   return simcall_BODY_process_get_PID(process);
710 }
711
712 /**
713  * \ingroup simix_process_management
714  * \brief Return the parent PID of a #smx_process_t.
715  * \param process a SIMIX process
716  * \return the PID of this process parenrt
717  */
718 int simcall_process_get_PPID(smx_process_t process)
719 {
720   if (process == SIMIX_process_self()) {
721     /* avoid a simcall if this function is called by the process itself */
722     return SIMIX_process_get_PPID(process);
723   }
724
725   return simcall_BODY_process_get_PPID(process);
726 }
727
728 /**
729  * \ingroup simix_process_management
730  * \brief Return the user data of a #smx_process_t.
731  * \param process a SIMIX process
732  * \return the user data of this process
733  */
734 void* simcall_process_get_data(smx_process_t process)
735 {
736   if (process == SIMIX_process_self()) {
737     /* avoid a simcall if this function is called by the process itself */
738     return SIMIX_process_get_data(process);
739   }
740
741   return simcall_BODY_process_get_data(process);
742 }
743
744 /**
745  * \ingroup simix_process_management
746  * \brief Set the user data of a #smx_process_t.
747  *
748  * This functions sets the user data associated to \a process.
749  * \param process SIMIX process
750  * \param data User data
751  */
752 void simcall_process_set_data(smx_process_t process, void *data)
753 {
754   if (process == SIMIX_process_self()) {
755     /* avoid a simcall if this function is called by the process itself */
756     SIMIX_process_self_set_data(process, data);
757   }
758   else {
759     simcall_BODY_process_set_data(process, data);
760   }
761 }
762
763 /**
764  * \ingroup simix_process_management
765  * \brief Set the kill time of a process.
766  * \param process a process
767  * \param kill_time a double
768  */
769 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
770 {
771
772   if (kill_time > SIMIX_get_clock()) {
773     if (simix_global->kill_process_function) {
774       XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
775           sg_host_name(process->smx_host));
776       SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
777     }
778   }
779 }
780
781 /**
782  * \ingroup simix_process_management
783  * \brief Return the location on which an agent is running.
784  *
785  * This functions returns the smx_host_t corresponding to the location on which
786  * \a process is running.
787  * \param process SIMIX process
788  * \return SIMIX host
789  */
790 smx_host_t simcall_process_get_host(smx_process_t process)
791 {
792   return simcall_BODY_process_get_host(process);
793 }
794
795 /**
796  * \ingroup simix_process_management
797  * \brief Return the name of an agent.
798  *
799  * This functions checks whether \a process is a valid pointer or not and return its name.
800  * \param process SIMIX process
801  * \return The process name
802  */
803 const char* simcall_process_get_name(smx_process_t process)
804 {
805   if (process == SIMIX_process_self()) {
806     /* avoid a simcall if this function is called by the process itself */
807     return process->name;
808   }
809   return simcall_BODY_process_get_name(process);
810 }
811
812 /**
813  * \ingroup simix_process_management
814  * \brief Returns true if the process is suspended .
815  *
816  * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
817  * \param process SIMIX process
818  * \return 1, if the process is suspended, else 0.
819  */
820 int simcall_process_is_suspended(smx_process_t process)
821 {
822   return  simcall_BODY_process_is_suspended(process);
823 }
824
825 /**
826  * \ingroup simix_process_management
827  * \brief Return the properties
828  *
829  * This functions returns the properties associated with this process
830  */
831 xbt_dict_t simcall_process_get_properties(smx_process_t process)
832 {
833   return simcall_BODY_process_get_properties(process);
834 }
835 /**
836  * \ingroup simix_process_management
837  * \brief Add an on_exit function
838  * Add an on_exit function which will be executed when the process exits/is killed.
839  */
840 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
841 {
842   simcall_BODY_process_on_exit(process, fun, data);
843 }
844 /**
845  * \ingroup simix_process_management
846  * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
847  * Will restart the process when the host comes back up if auto_restart is set to 1.
848  */
849
850 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
851 {
852   simcall_BODY_process_auto_restart_set(process, auto_restart);
853 }
854
855 /**
856  * \ingroup simix_process_management
857  * \brief Restarts the process, killing it and starting it again from scratch.
858  */
859 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
860 {
861   return simcall_BODY_process_restart(process);
862 }
863 /**
864  * \ingroup simix_process_management
865  * \brief Creates a new sleep SIMIX action.
866  *
867  * This function creates a SURF action and allocates the data necessary
868  * to create the SIMIX action. It can raise a host_error exception if the
869  * host crashed. The default SIMIX name of the action is "sleep".
870  *
871  *   \param duration Time duration of the sleep.
872  *   \return A result telling whether the sleep was successful
873  */
874 e_smx_state_t simcall_process_sleep(double duration)
875 {
876   /* checking for infinite values */
877   xbt_assert(isfinite(duration), "duration is not finite!");
878   return simcall_BODY_process_sleep(duration);
879 }
880
881 /**
882  *  \ingroup simix_rdv_management
883  *  \brief Creates a new rendez-vous point
884  *  \param name The name of the rendez-vous point
885  *  \return The created rendez-vous point
886  */
887 smx_rdv_t simcall_rdv_create(const char *name)
888 {
889   return simcall_BODY_rdv_create(name);
890 }
891
892
893 /**
894  *  \ingroup simix_rdv_management
895  *  \brief Destroy a rendez-vous point
896  *  \param rdv The rendez-vous point to destroy
897  */
898 void simcall_rdv_destroy(smx_rdv_t rdv)
899 {
900   simcall_BODY_rdv_destroy(rdv);
901 }
902 /**
903  *  \ingroup simix_rdv_management
904  *  \brief Returns a rendez-vous point knowing its name
905  */
906 smx_rdv_t simcall_rdv_get_by_name(const char *name)
907 {
908   xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
909
910   /* FIXME: this is a horrible loss of performance, so we hack it out by
911    * skipping the simcall (for now). It works in parallel, it won't work on
912    * distributed but probably we will change MSG for that. */
913
914   /*
915   smx_simcall_t simcall = simcall_mine();
916   simcall->call = SIMCALL_RDV_GEY_BY_NAME;
917   simcall->rdv_get_by_name.name = name;
918   SIMIX_simcall_push(simcall->issuer);
919   return simcall->rdv_get_by_name.result;*/
920
921   return SIMIX_rdv_get_by_name(name);
922 }
923
924 /**
925  *  \ingroup simix_rdv_management
926  *  \brief Counts the number of communication actions of a given host pending
927  *         on a rendez-vous point.
928  *  \param rdv The rendez-vous point
929  *  \param host The host to be counted
930  *  \return The number of comm actions pending in the rdv
931  */
932 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
933 {
934   return simcall_BODY_rdv_comm_count_by_host(rdv, host);
935 }
936
937 /**
938  *  \ingroup simix_rdv_management
939  *  \brief returns the communication at the head of the rendez-vous
940  *  \param rdv The rendez-vous point
941  *  \return The communication or NULL if empty
942  */
943 smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
944 {
945   return simcall_BODY_rdv_get_head(rdv);
946 }
947
948 void simcall_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
949 {
950   simcall_BODY_rdv_set_receiver(rdv, process);
951 }
952
953 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
954 {
955   return simcall_BODY_rdv_get_receiver(rdv);
956 }
957
958 /**
959  * \ingroup simix_comm_management
960  */
961 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
962                          void *src_buff, size_t src_buff_size,
963                          int (*match_fun)(void *, void *, smx_action_t), void *data,
964                          double timeout)
965 {
966   /* checking for infinite values */
967   xbt_assert(isfinite(task_size), "task_size is not finite!");
968   xbt_assert(isfinite(rate), "rate is not finite!");
969   xbt_assert(isfinite(timeout), "timeout is not finite!");
970   
971   xbt_assert(rdv, "No rendez-vous point defined for send");
972
973   if (MC_is_active()) {
974     /* the model-checker wants two separate simcalls */
975     smx_action_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */
976     comm = simcall_comm_isend(rdv, task_size, rate,
977         src_buff, src_buff_size, match_fun, NULL, data, 0);
978     simcall_comm_wait(comm, timeout);
979     comm = NULL;
980   }
981   else {
982     simcall_BODY_comm_send(rdv, task_size, rate, src_buff, src_buff_size,
983                          match_fun, data, timeout);
984   }
985 }
986
987 /**
988  * \ingroup simix_comm_management
989  */
990 smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
991                               void *src_buff, size_t src_buff_size,
992                               int (*match_fun)(void *, void *, smx_action_t),
993                               void (*clean_fun)(void *),
994                               void *data,
995                               int detached)
996 {
997   /* checking for infinite values */
998   xbt_assert(isfinite(task_size), "task_size is not finite!");
999   xbt_assert(isfinite(rate), "rate is not finite!");
1000   
1001   xbt_assert(rdv, "No rendez-vous point defined for isend");
1002
1003   return simcall_BODY_comm_isend(rdv, task_size, rate, src_buff,
1004                                  src_buff_size, match_fun,
1005                                  clean_fun, data, detached);
1006 }
1007 /**
1008  * \ingroup simix_comm_management
1009  */
1010 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
1011                          int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
1012 {
1013   xbt_assert(isfinite(timeout), "timeout is not finite!");
1014   xbt_assert(rdv, "No rendez-vous point defined for recv");
1015
1016   if (MC_is_active()) {
1017     /* the model-checker wants two separate simcalls */
1018     smx_action_t comm = NULL; /* MC needs the comm to be set to NULL during the simcall */
1019     comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
1020         match_fun, data);
1021     simcall_comm_wait(comm, timeout);
1022     comm = NULL;
1023   }
1024   else {
1025     simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size,
1026                            match_fun, data, timeout);
1027   }
1028 }
1029 /**
1030  * \ingroup simix_comm_management
1031  */
1032 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
1033                                   int (*match_fun)(void *, void *, smx_action_t), void *data)
1034 {
1035   xbt_assert(rdv, "No rendez-vous point defined for irecv");
1036
1037   return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size, 
1038                                  match_fun, data);
1039 }
1040
1041
1042 /**
1043  * \ingroup simix_comm_management
1044  */
1045 void simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
1046                          int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout, double rate)
1047 {
1048   xbt_assert(isfinite(timeout), "timeout is not finite!");
1049   xbt_assert(rdv, "No rendez-vous point defined for recv");
1050
1051   if (MC_is_active()) {
1052     /* the model-checker wants two separate simcalls */
1053     smx_action_t comm = simcall_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
1054         match_fun, data, rate);
1055     simcall_comm_wait(comm, timeout);
1056   }
1057   else {
1058     simcall_BODY_comm_recv_bounded(rdv, dst_buff, dst_buff_size,
1059                            match_fun, data, timeout, rate);
1060   }
1061 }
1062 /**
1063  * \ingroup simix_comm_management
1064  */
1065 smx_action_t simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
1066                                   int (*match_fun)(void *, void *, smx_action_t), void *data, double rate)
1067 {
1068   xbt_assert(rdv, "No rendez-vous point defined for irecv");
1069
1070   return simcall_BODY_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
1071                                  match_fun, data, rate);
1072 }
1073
1074
1075 /**
1076  * \ingroup simix_comm_management
1077  */
1078 smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
1079                                 int (*match_fun)(void *, void *, smx_action_t), void *data)
1080 {
1081   xbt_assert(rdv, "No rendez-vous point defined for iprobe");
1082
1083   return simcall_BODY_comm_iprobe(rdv, src, tag, match_fun, data);
1084 }
1085
1086 void simcall_comm_destroy(smx_action_t comm)
1087 {
1088   xbt_assert(comm, "Invalid parameter");
1089
1090   /* FIXME remove this simcall type: comms are auto-destroyed now */
1091
1092   /*
1093   smx_simcall_t simcall = simcall_mine();
1094
1095   simcall->call = SIMCALL_COMM_DESTROY;
1096   simcall->comm_destroy.comm = comm;
1097
1098   SIMIX_simcall_push(simcall->issuer);
1099   */
1100 }
1101
1102 /**
1103  * \ingroup simix_comm_management
1104  */
1105 void simcall_comm_cancel(smx_action_t comm)
1106 {
1107   simcall_BODY_comm_cancel(comm);
1108 }
1109
1110 /**
1111  * \ingroup simix_comm_management
1112  */
1113 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
1114 {
1115   return simcall_BODY_comm_waitany(comms);
1116 }
1117
1118 /**
1119  * \ingroup simix_comm_management
1120  */
1121 int simcall_comm_testany(xbt_dynar_t comms)
1122 {
1123   if (xbt_dynar_is_empty(comms))
1124     return -1;
1125   return simcall_BODY_comm_testany(comms);
1126 }
1127
1128 /**
1129  * \ingroup simix_comm_management
1130  */
1131 void simcall_comm_wait(smx_action_t comm, double timeout)
1132 {
1133   xbt_assert(isfinite(timeout), "timeout is not finite!");
1134   simcall_BODY_comm_wait(comm, timeout);
1135 }
1136
1137 #ifdef HAVE_TRACING
1138 /**
1139  * \brief Set the category of an action.
1140  *
1141  * This functions changes the category only. It calls a surf function.
1142  * \param execution The execution action
1143  * \param category The tracing category
1144  */
1145 void simcall_set_category(smx_action_t action, const char *category)
1146 {
1147   if (category == NULL) {
1148     return;
1149   }
1150   simcall_BODY_set_category(action, category);
1151 }
1152 #endif
1153
1154 /**
1155  * \ingroup simix_comm_management
1156  *
1157  */
1158 int simcall_comm_test(smx_action_t comm)
1159 {
1160   return simcall_BODY_comm_test(comm);
1161 }
1162
1163 /**
1164  * \ingroup simix_comm_management
1165  *
1166  */
1167 double simcall_comm_get_remains(smx_action_t comm)
1168 {
1169   return simcall_BODY_comm_get_remains(comm);
1170 }
1171
1172 /**
1173  * \ingroup simix_comm_management
1174  *
1175  */
1176 e_smx_state_t simcall_comm_get_state(smx_action_t comm)
1177 {
1178   return simcall_BODY_comm_get_state(comm);
1179 }
1180
1181 /**
1182  * \ingroup simix_comm_management
1183  *
1184  */
1185 void *simcall_comm_get_src_data(smx_action_t comm)
1186 {
1187   return simcall_BODY_comm_get_src_data(comm);
1188 }
1189
1190 /**
1191  * \ingroup simix_comm_management
1192  *
1193  */
1194 void *simcall_comm_get_dst_data(smx_action_t comm)
1195 {
1196   return simcall_BODY_comm_get_dst_data(comm);
1197 }
1198
1199 /**
1200  * \ingroup simix_comm_management
1201  *
1202  */
1203 smx_process_t simcall_comm_get_src_proc(smx_action_t comm)
1204 {
1205   return simcall_BODY_comm_get_src_proc(comm);
1206 }
1207
1208 /**
1209  * \ingroup simix_comm_management
1210  *
1211  */
1212 smx_process_t simcall_comm_get_dst_proc(smx_action_t comm)
1213 {
1214   return simcall_BODY_comm_get_dst_proc(comm);  
1215 }
1216
1217 #ifdef HAVE_LATENCY_BOUND_TRACKING
1218 int simcall_comm_is_latency_bounded(smx_action_t comm)
1219 {
1220   return simcall_BODY_comm_is_latency_bounded(comm);
1221 }
1222 #endif
1223
1224 /**
1225  * \ingroup simix_synchro_management
1226  *
1227  */
1228 smx_mutex_t simcall_mutex_init(void)
1229 {
1230   if(!simix_global) {
1231     fprintf(stderr,"You must run MSG_init before using MSG\n"); // We can't use xbt_die since we may get there before the initialization
1232     xbt_abort();
1233   }
1234   return simcall_BODY_mutex_init();
1235 }
1236
1237 /**
1238  * \ingroup simix_synchro_management
1239  *
1240  */
1241 void simcall_mutex_destroy(smx_mutex_t mutex)
1242 {
1243   simcall_BODY_mutex_destroy(mutex);
1244 }
1245
1246 /**
1247  * \ingroup simix_synchro_management
1248  *
1249  */
1250 void simcall_mutex_lock(smx_mutex_t mutex)
1251 {
1252   simcall_BODY_mutex_lock(mutex);  
1253 }
1254
1255 /**
1256  * \ingroup simix_synchro_management
1257  *
1258  */
1259 int simcall_mutex_trylock(smx_mutex_t mutex)
1260 {
1261   return simcall_BODY_mutex_trylock(mutex);  
1262 }
1263
1264 /**
1265  * \ingroup simix_synchro_management
1266  *
1267  */
1268 void simcall_mutex_unlock(smx_mutex_t mutex)
1269 {
1270   simcall_BODY_mutex_unlock(mutex); 
1271 }
1272
1273 /**
1274  * \ingroup simix_synchro_management
1275  *
1276  */
1277 smx_cond_t simcall_cond_init(void)
1278 {
1279   return simcall_BODY_cond_init();
1280 }
1281
1282 /**
1283  * \ingroup simix_synchro_management
1284  *
1285  */
1286 void simcall_cond_destroy(smx_cond_t cond)
1287 {
1288   simcall_BODY_cond_destroy(cond);
1289 }
1290
1291 /**
1292  * \ingroup simix_synchro_management
1293  *
1294  */
1295 void simcall_cond_signal(smx_cond_t cond)
1296 {
1297   simcall_BODY_cond_signal(cond);
1298 }
1299
1300 /**
1301  * \ingroup simix_synchro_management
1302  *
1303  */
1304 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1305 {
1306   simcall_BODY_cond_wait(cond, mutex);
1307 }
1308
1309 /**
1310  * \ingroup simix_synchro_management
1311  *
1312  */
1313 void simcall_cond_wait_timeout(smx_cond_t cond,
1314                                  smx_mutex_t mutex,
1315                                  double timeout)
1316 {
1317   xbt_assert(isfinite(timeout), "timeout is not finite!");
1318   simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
1319 }
1320
1321 /**
1322  * \ingroup simix_synchro_management
1323  *
1324  */
1325 void simcall_cond_broadcast(smx_cond_t cond)
1326 {
1327   simcall_BODY_cond_broadcast(cond);
1328 }
1329
1330 /**
1331  * \ingroup simix_synchro_management
1332  *
1333  */
1334 smx_sem_t simcall_sem_init(int capacity)
1335 {
1336   return simcall_BODY_sem_init(capacity);  
1337 }
1338
1339 /**
1340  * \ingroup simix_synchro_management
1341  *
1342  */
1343 void simcall_sem_destroy(smx_sem_t sem)
1344 {
1345   simcall_sem_destroy(sem);
1346 }
1347
1348 /**
1349  * \ingroup simix_synchro_management
1350  *
1351  */
1352 void simcall_sem_release(smx_sem_t sem)
1353 {
1354   simcall_BODY_sem_release(sem);  
1355 }
1356
1357 /**
1358  * \ingroup simix_synchro_management
1359  *
1360  */
1361 int simcall_sem_would_block(smx_sem_t sem)
1362 {
1363   return simcall_BODY_sem_would_block(sem);
1364 }
1365
1366 /**
1367  * \ingroup simix_synchro_management
1368  *
1369  */
1370 void simcall_sem_acquire(smx_sem_t sem)
1371 {
1372   simcall_BODY_sem_acquire(sem);
1373 }
1374
1375 /**
1376  * \ingroup simix_synchro_management
1377  *
1378  */
1379 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1380 {
1381   xbt_assert(isfinite(timeout), "timeout is not finite!");
1382   simcall_BODY_sem_acquire_timeout(sem, timeout);
1383 }
1384
1385 /**
1386  * \ingroup simix_synchro_management
1387  *
1388  */
1389 int simcall_sem_get_capacity(smx_sem_t sem)
1390 {
1391   return simcall_BODY_sem_get_capacity(sem);
1392 }
1393
1394 /**
1395  * \ingroup simix_file_management
1396  * \brief Returns the user data associated to a file.
1397  *
1398  * \param fd A simix file
1399  * \return the user data of this file
1400  */
1401 void* simcall_file_get_data(smx_file_t fd)
1402 {
1403   return simcall_BODY_file_get_data(fd);
1404 }
1405
1406 /**
1407  * \ingroup simix_file_management
1408  * \brief Sets the user data associated to a file.
1409  *
1410  * \param fd A SIMIX file
1411  * \param data The user data to set
1412  */
1413 void simcall_file_set_data(smx_file_t fd, void *data)
1414 {
1415   simcall_file_set_data(fd, data);
1416 }
1417
1418 /**
1419  * \ingroup simix_file_management
1420  *
1421  */
1422 sg_storage_size_t simcall_file_read(smx_file_t fd, sg_storage_size_t size)
1423 {
1424   return simcall_BODY_file_read(fd, size);
1425 }
1426
1427 /**
1428  * \ingroup simix_file_management
1429  *
1430  */
1431 sg_storage_size_t simcall_file_write(smx_file_t fd, sg_storage_size_t size)
1432 {
1433   return simcall_BODY_file_write(fd, size);
1434 }
1435
1436 /**
1437  * \ingroup simix_file_management
1438  * \brief
1439  */
1440 smx_file_t simcall_file_open(const char* mount, const char* path)
1441 {
1442   return simcall_BODY_file_open(mount, path);
1443 }
1444
1445 /**
1446  * \ingroup simix_file_management
1447  *
1448  */
1449 int simcall_file_close(smx_file_t fd)
1450 {
1451   return simcall_BODY_file_close(fd);
1452 }
1453
1454 /**
1455  * \ingroup simix_file_management
1456  *
1457  */
1458 int simcall_file_unlink(smx_file_t fd)
1459 {
1460   return simcall_BODY_file_unlink(fd);
1461 }
1462
1463 /**
1464  * \ingroup simix_file_management
1465  *
1466  */
1467 xbt_dict_t simcall_file_ls(const char* mount, const char* path)
1468 {
1469   return simcall_BODY_file_ls(mount, path);
1470 }
1471 /**
1472  * \ingroup simix_file_management
1473  *
1474  */
1475 sg_storage_size_t simcall_file_get_size (smx_file_t fd){
1476   return simcall_BODY_file_get_size(fd);
1477 }
1478
1479 /**
1480  * \ingroup simix_file_management
1481  *
1482  */
1483 xbt_dynar_t simcall_file_get_info(smx_file_t fd)
1484 {
1485   return simcall_BODY_file_get_info(fd);
1486 }
1487
1488 /**
1489  * \ingroup simix_file_management
1490  *
1491  */
1492 void simcall_storage_file_rename(smx_storage_t storage, const char* src,  const char* dest)
1493 {
1494   return simcall_BODY_storage_file_rename(storage, src, dest);
1495 }
1496
1497 /**
1498  * \ingroup simix_storage_management
1499  * \brief Returns the free space size on a given storage element.
1500  * \param storage name
1501  * \return Return the free space size on a given storage element (as sg_storage_size_t)
1502  */
1503 sg_storage_size_t simcall_storage_get_free_size (const char* name){
1504   return simcall_BODY_storage_get_free_size(name);
1505 }
1506
1507 /**
1508  * \ingroup simix_storage_management
1509  * \brief Returns the used space size on a given storage element.
1510  * \param storage name
1511  * \return Return the used space size on a given storage element (as sg_storage_size_t)
1512  */
1513 sg_storage_size_t simcall_storage_get_used_size (const char* name){
1514   return simcall_BODY_storage_get_used_size(name);
1515 }
1516
1517 /**
1518  * \ingroup simix_storage_management
1519  * \brief Returns the list of storages mounted on an host.
1520  * \param host A SIMIX host
1521  * \return a dict containing all storages mounted on the host
1522  */
1523 xbt_dict_t simcall_host_get_storage_list(smx_host_t host)
1524 {
1525   return simcall_BODY_host_get_storage_list(host);
1526 }
1527
1528 /**
1529  * \ingroup simix_storage_management
1530  * \brief Returns a dict of the properties assigned to a storage element.
1531  *
1532  * \param storage A storage element
1533  * \return The properties of this storage element
1534  */
1535 xbt_dict_t simcall_storage_get_properties(smx_storage_t storage)
1536 {
1537   return simcall_BODY_storage_get_properties(storage);
1538 }
1539
1540 /**
1541  * \ingroup simix_storage_management
1542  * \brief Returns a dict containing the content of a storage element.
1543  *
1544  * \param storage A storage element
1545  * \return The content of this storage element as a dict (full path file => size)
1546  */
1547 xbt_dict_t simcall_storage_get_content(smx_storage_t storage)
1548 {
1549   return simcall_BODY_storage_get_content(storage);
1550 }
1551
1552 #ifdef HAVE_MC
1553
1554 void *simcall_mc_snapshot(void)
1555 {
1556   return simcall_BODY_mc_snapshot();
1557 }
1558
1559 int simcall_mc_compare_snapshots(void *s1, void *s2){ 
1560   return simcall_BODY_mc_compare_snapshots(s1, s2);
1561 }
1562
1563 int simcall_mc_random(int min, int max)
1564 {
1565   return simcall_BODY_mc_random(min, max);
1566 }
1567
1568
1569 #endif /* HAVE_MC */
1570
1571 /* ****************************************************************************************** */
1572 /* TUTORIAL: New API                                                                          */
1573 /* All functions for simcall                                                                  */
1574 /* ****************************************************************************************** */
1575 int simcall_new_api_fct(const char* param1, double param2){
1576   smx_simcall_t simcall = SIMIX_simcall_mine();
1577   simcall->call = SIMCALL_NEW_API_INIT;
1578   simcall->new_api.param1 = param1;
1579   simcall->new_api.param2 = param2;
1580
1581   SIMIX_simcall_push(simcall->issuer);
1582   return simcall->new_api.result;
1583 }
1584
1585 /* ************************************************************************** */
1586
1587 /** @brief returns a printable string representing a simcall */
1588 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1589   return simcall_names[kind];
1590 }