1 /* smx_user.c - public interface to simix */
3 /* Copyright (c) 2010-2012. Da SimGrid team. All rights reserved. */
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. */
8 #include "smx_private.h"
11 #include <math.h> /* isfinite() */
13 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
15 /* generate strings from the enumeration values */
16 static const char* simcall_names[] = {
17 SIMCALL_LIST(SIMCALL_STRING_TYPE, SIMCALL_SEP_COMMA)
18 [SIMCALL_NONE] = "NONE"
21 SIMCALL_LIST(SIMCALL_FUNC, SIMCALL_SEP_NOTHING)
24 * \ingroup simix_host_management
25 * \brief Returns a host given its name.
27 * \param name The name of the host to get
28 * \return The corresponding host
30 smx_host_t simcall_host_get_by_name(const char *name)
32 return simcall_BODY_host_get_by_name(name);
36 * \ingroup simix_host_management
37 * \brief Returns the name of a host.
39 * \param host A SIMIX host
40 * \return The name of this host
42 const char* simcall_host_get_name(smx_host_t host)
44 return simcall_BODY_host_get_name(host);
48 * \ingroup simix_host_management
49 * \brief Returns a dict of the properties assigned to a host.
52 * \return The properties of this host
54 xbt_dict_t simcall_host_get_properties(smx_host_t host)
56 return simcall_BODY_host_get_properties(host);
60 * \ingroup simix_host_management
61 * \brief Returns a dict of the properties assigned to a router or AS.
63 * \param name The name of the router or AS
64 * \return The properties
66 xbt_dict_t simcall_asr_get_properties(const char *name)
68 return simcall_BODY_asr_get_properties(name);
73 * \ingroup simix_host_management
74 * \brief Returns the speed of the processor.
76 * The speed returned does not take into account the current load on the machine.
77 * \param host A SIMIX host
78 * \return The speed of this host (in Mflop/s)
80 double simcall_host_get_speed(smx_host_t host)
82 return simcall_BODY_host_get_speed(host);
86 * \ingroup simix_host_management
87 * \brief Returns the available speed of the processor.
89 * \return Speed currently available (in Mflop/s)
91 double simcall_host_get_available_speed(smx_host_t host)
93 return simcall_BODY_host_get_available_speed(host);
97 * \ingroup simix_host_management
98 * \brief Returns the state of a host.
100 * Two states are possible: 1 if the host is active or 0 if it has crashed.
101 * \param host A SIMIX host
102 * \return 1 if the host is available, 0 otherwise
104 int simcall_host_get_state(smx_host_t host)
106 return simcall_BODY_host_get_state(host);
110 * \ingroup simix_host_management
111 * \brief Returns the user data associated to a host.
113 * \param host SIMIX host
114 * \return the user data of this host
116 void* simcall_host_get_data(smx_host_t host)
118 return simcall_BODY_host_get_data(host);
122 * \ingroup simix_host_management
123 * \brief Sets the user data associated to a host.
125 * The host must not have previous user data associated to it.
126 * \param host A SIMIX host
127 * \param data The user data to set
129 void simcall_host_set_data(smx_host_t host, void *data)
131 simcall_host_set_data(host, data);
135 * \ingroup simix_host_management
136 * \brief Creates an action that executes some computation of an host.
138 * This function creates a SURF action and allocates the data necessary
139 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
141 * \param name Name of the execution action to create
142 * \param host SIMIX host where the action will be executed
143 * \param computation_amount amount Computation amount (in bytes)
144 * \param priority computation priority
145 * \return A new SIMIX execution action
148 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
149 double computation_amount,
152 /* checking for infinite values */
153 xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
154 xbt_assert(isfinite(priority), "priority is not finite!");
156 return simcall_BODY_host_execute(name, host, computation_amount, priority);
160 * \ingroup simix_host_management
161 * \brief Creates an action that may involve parallel computation on
162 * several hosts and communication between them.
164 * \param name Name of the execution action to create
165 * \param host_nb Number of hosts where the action will be executed
166 * \param host_list Array (of size host_nb) of hosts where the action will be executed
167 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
168 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
169 * amount between each pair of hosts
170 * \param amount the SURF action amount
171 * \param rate the SURF action rate
172 * \return A new SIMIX execution action
174 smx_action_t simcall_host_parallel_execute(const char *name,
176 smx_host_t *host_list,
177 double *computation_amount,
178 double *communication_amount,
183 /* checking for infinite values */
184 for (i = 0 ; i < host_nb ; ++i) {
185 xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i);
186 for (j = 0 ; j < host_nb ; ++j) {
187 xbt_assert(isfinite(communication_amount[i + host_nb * j]),
188 "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j);
192 xbt_assert(isfinite(amount), "amount is not finite!");
193 xbt_assert(isfinite(rate), "rate is not finite!");
195 return simcall_BODY_host_parallel_execute(name, host_nb, host_list,
197 communication_amount,
203 * \ingroup simix_host_management
204 * \brief Destroys an execution action.
206 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
207 * \param execution The execution action to destroy
209 void simcall_host_execution_destroy(smx_action_t execution)
211 simcall_BODY_host_execution_destroy(execution);
215 * \ingroup simix_host_management
216 * \brief Cancels an execution action.
218 * This functions stops the execution. It calls a surf function.
219 * \param execution The execution action to cancel
221 void simcall_host_execution_cancel(smx_action_t execution)
223 simcall_BODY_host_execution_cancel(execution);
227 * \ingroup simix_host_management
228 * \brief Returns how much of an execution action remains to be done.
230 * \param execution The execution action
231 * \return The remaining amount
233 double simcall_host_execution_get_remains(smx_action_t execution)
235 return simcall_BODY_host_execution_get_remains(execution);
239 * \ingroup simix_host_management
240 * \brief Returns the state of an execution action.
242 * \param execution The execution action
245 e_smx_state_t simcall_host_execution_get_state(smx_action_t execution)
247 return simcall_BODY_host_execution_get_state(execution);
251 * \ingroup simix_host_management
252 * \brief Changes the priority of an execution action.
254 * This functions changes the priority only. It calls a surf function.
255 * \param execution The execution action
256 * \param priority The new priority
258 void simcall_host_execution_set_priority(smx_action_t execution, double priority)
260 /* checking for infinite values */
261 xbt_assert(isfinite(priority), "priority is not finite!");
263 simcall_BODY_host_execution_set_priority(execution, priority);
267 * \ingroup simix_host_management
268 * \brief Waits for the completion of an execution action and destroy it.
270 * \param execution The execution action
272 e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
274 return simcall_BODY_host_execution_wait(execution);
279 * \ingroup simix_vm_management
280 * \brief Returns a dict of the properties assigned to a host.
283 * \return The properties of this host
285 void* simcall_vm_ws_create(const char *name, smx_host_t phys_host){
286 return simcall_BODY_vm_ws_create(name, phys_host);
289 void simcall_vm_start(smx_host_t vm) {
290 simcall_BODY_set_vm_state(vm, msg_vm_state_running);
293 void simcall_vm_suspend(smx_host_t vm)
295 /* will jump to SIMIX_pre_vm_suspend */
296 simcall_BODY_vm_suspend(vm);
299 void simcall_vm_resume(smx_host_t vm)
302 * simcall_BODY_ is defined in src/simix/smx_smurf_private.h.
303 * This function will jump to SIMIX_pre_vm_resume.
305 simcall_BODY_vm_resume(vm);
308 void simcall_vm_shutdown(smx_host_t vm)
310 /* will jump to SIMIX_pre_vm_shutdown */
311 simcall_BODY_vm_shutdown(vm);
314 void simcall_vm_destroy(smx_host_t vm)
317 * simcall_BODY_ is defined in src/simix/smx_smurf_private.h.
318 * This function will jump to SIMIX_pre_vm_destroy.
320 simcall_BODY_vm_destroy(vm);
324 * \ingroup simix_process_management
325 * \brief Creates and runs a new SIMIX process.
327 * The structure and the corresponding thread are created and put in the list of ready processes.
329 * \param process the process created will be stored in this pointer
330 * \param name a name for the process. It is for user-level information and can be NULL.
331 * \param code the main function of the process
332 * \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.
333 * It can be retrieved with the function \ref simcall_process_get_data.
334 * \param hostname name of the host where the new agent is executed.
335 * \param kill_time time when the process is killed
336 * \param argc first argument passed to \a code
337 * \param argv second argument passed to \a code
338 * \param properties the properties of the process
339 * \param auto_restart either it is autorestarting or not.
341 void simcall_process_create(smx_process_t *process, const char *name,
342 xbt_main_func_t code,
344 const char *hostname,
346 int argc, char **argv,
347 xbt_dict_t properties,
350 simcall_BODY_process_create(process, name, code, data, hostname,
351 kill_time, argc, argv, properties,
356 * \ingroup simix_process_management
357 * \brief Kills a SIMIX process.
359 * This function simply kills a process.
361 * \param process poor victim
363 void simcall_process_kill(smx_process_t process)
365 simcall_BODY_process_kill(process);
369 * \ingroup simix_process_management
370 * \brief Kills all SIMIX processes.
372 void simcall_process_killall(int reset_pid)
374 simcall_BODY_process_killall(reset_pid);
378 * \ingroup simix_process_management
379 * \brief Cleans up a SIMIX process.
380 * \param process poor victim (must have already been killed)
382 void simcall_process_cleanup(smx_process_t process)
384 simcall_BODY_process_cleanup(process);
388 * \ingroup simix_process_management
389 * \brief Migrates an agent to another location.
391 * This function changes the value of the host on which \a process is running.
393 * \param process the process to migrate
394 * \param dest name of the new host
396 void simcall_process_change_host(smx_process_t process, smx_host_t dest)
398 simcall_BODY_process_change_host(process, dest);
402 * \ingroup simix_process_management
403 * \brief Suspends a process.
405 * This function suspends the process by suspending the action
406 * it was waiting for completion.
408 * \param process a SIMIX process
410 void simcall_process_suspend(smx_process_t process)
412 xbt_assert(process, "Invalid parameters");
414 simcall_BODY_process_suspend(process);
418 * \ingroup simix_process_management
419 * \brief Resumes a suspended process.
421 * This function resumes a suspended process by resuming the action
422 * it was waiting for completion.
424 * \param process a SIMIX process
426 void simcall_process_resume(smx_process_t process)
428 simcall_BODY_process_resume(process);
432 * \ingroup simix_process_management
433 * \brief Returns the amount of SIMIX processes in the system
435 * Maestro internal process is not counted, only user code processes are
437 int simcall_process_count(void)
439 return simcall_BODY_process_count();
443 * \ingroup simix_process_management
444 * \brief Return the PID of a #smx_process_t.
445 * \param process a SIMIX process
446 * \return the PID of this process
448 int simcall_process_get_PID(smx_process_t process)
450 if (process == SIMIX_process_self()) {
451 /* avoid a simcall if this function is called by the process itself */
452 return SIMIX_process_get_PID(process);
455 return simcall_BODY_process_get_PID(process);
459 * \ingroup simix_process_management
460 * \brief Return the parent PID of a #smx_process_t.
461 * \param process a SIMIX process
462 * \return the PID of this process parenrt
464 int simcall_process_get_PPID(smx_process_t process)
466 if (process == SIMIX_process_self()) {
467 /* avoid a simcall if this function is called by the process itself */
468 return SIMIX_process_get_PPID(process);
471 return simcall_BODY_process_get_PPID(process);
475 * \ingroup simix_process_management
476 * \brief Return the user data of a #smx_process_t.
477 * \param process a SIMIX process
478 * \return the user data of this process
480 void* simcall_process_get_data(smx_process_t process)
482 if (process == SIMIX_process_self()) {
483 /* avoid a simcall if this function is called by the process itself */
484 return SIMIX_process_get_data(process);
487 return simcall_BODY_process_get_data(process);
491 * \ingroup simix_process_management
492 * \brief Set the user data of a #smx_process_t.
494 * This functions sets the user data associated to \a process.
495 * \param process SIMIX process
496 * \param data User data
498 void simcall_process_set_data(smx_process_t process, void *data)
500 if (process == SIMIX_process_self()) {
501 /* avoid a simcall if this function is called by the process itself */
502 SIMIX_process_self_set_data(process, data);
505 simcall_BODY_process_set_data(process, data);
510 * \ingroup simix_process_management
511 * \brief Set the kill time of a process.
512 * \param process a process
513 * \param kill_time a double
515 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
518 if (kill_time > SIMIX_get_clock()) {
519 if (simix_global->kill_process_function) {
520 XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
521 sg_host_name(process->smx_host));
522 SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
528 * \ingroup simix_process_management
529 * \brief Return the location on which an agent is running.
531 * This functions returns the smx_host_t corresponding to the location on which
532 * \a process is running.
533 * \param process SIMIX process
536 smx_host_t simcall_process_get_host(smx_process_t process)
538 return simcall_BODY_process_get_host(process);
542 * \ingroup simix_process_management
543 * \brief Return the name of an agent.
545 * This functions checks whether \a process is a valid pointer or not and return its name.
546 * \param process SIMIX process
547 * \return The process name
549 const char* simcall_process_get_name(smx_process_t process)
551 if (process == SIMIX_process_self()) {
552 /* avoid a simcall if this function is called by the process itself */
553 return process->name;
555 return simcall_BODY_process_get_name(process);
559 * \ingroup simix_process_management
560 * \brief Returns true if the process is suspended .
562 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
563 * \param process SIMIX process
564 * \return 1, if the process is suspended, else 0.
566 int simcall_process_is_suspended(smx_process_t process)
568 return simcall_BODY_process_is_suspended(process);
572 * \ingroup simix_process_management
573 * \brief Return the properties
575 * This functions returns the properties associated with this process
577 xbt_dict_t simcall_process_get_properties(smx_process_t process)
579 return simcall_BODY_process_get_properties(process);
582 * \ingroup simix_process_management
583 * \brief Add an on_exit function
584 * Add an on_exit function which will be executed when the process exits/is killed.
586 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
588 simcall_BODY_process_on_exit(process, fun, data);
591 * \ingroup simix_process_management
592 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
593 * Will restart the process when the host comes back up if auto_restart is set to 1.
596 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
598 simcall_BODY_process_auto_restart_set(process, auto_restart);
602 * \ingroup simix_process_management
603 * \brief Restarts the process, killing it and starting it again from scratch.
605 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
607 return simcall_BODY_process_restart(process);
610 * \ingroup simix_process_management
611 * \brief Creates a new sleep SIMIX action.
613 * This function creates a SURF action and allocates the data necessary
614 * to create the SIMIX action. It can raise a host_error exception if the
615 * host crashed. The default SIMIX name of the action is "sleep".
617 * \param duration Time duration of the sleep.
618 * \return A result telling whether the sleep was successful
620 e_smx_state_t simcall_process_sleep(double duration)
622 /* checking for infinite values */
623 xbt_assert(isfinite(duration), "duration is not finite!");
624 return simcall_BODY_process_sleep(duration);
628 * \ingroup simix_rdv_management
629 * \brief Creates a new rendez-vous point
630 * \param name The name of the rendez-vous point
631 * \return The created rendez-vous point
633 smx_rdv_t simcall_rdv_create(const char *name)
635 return simcall_BODY_rdv_create(name);
640 * \ingroup simix_rdv_management
641 * \brief Destroy a rendez-vous point
642 * \param rdv The rendez-vous point to destroy
644 void simcall_rdv_destroy(smx_rdv_t rdv)
646 simcall_BODY_rdv_destroy(rdv);
649 * \ingroup simix_rdv_management
650 * \brief Returns a rendez-vous point knowing its name
652 smx_rdv_t simcall_rdv_get_by_name(const char *name)
654 xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
656 /* FIXME: this is a horrible lost of performance, so we hack it out by
657 * skipping the simcall (for now). It works in parallel, it won't work on
658 * distributed but probably we will change MSG for that. */
661 smx_simcall_t simcall = simcall_mine();
662 simcall->call = SIMCALL_RDV_GEY_BY_NAME;
663 simcall->rdv_get_by_name.name = name;
664 SIMIX_simcall_push(simcall->issuer);
665 return simcall->rdv_get_by_name.result;*/
667 return SIMIX_rdv_get_by_name(name);
671 * \ingroup simix_rdv_management
672 * \brief Counts the number of communication actions of a given host pending
673 * on a rendez-vous point.
674 * \param rdv The rendez-vous point
675 * \param host The host to be counted
676 * \return The number of comm actions pending in the rdv
678 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
680 return simcall_BODY_rdv_comm_count_by_host(rdv, host);
684 * \ingroup simix_rdv_management
685 * \brief returns the communication at the head of the rendez-vous
686 * \param rdv The rendez-vous point
687 * \return The communication or NULL if empty
689 smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
691 return simcall_BODY_rdv_get_head(rdv);
694 void simcall_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
696 simcall_BODY_rdv_set_receiver(rdv, process);
699 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
701 return simcall_BODY_rdv_get_receiver(rdv);
705 * \ingroup simix_comm_management
707 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
708 void *src_buff, size_t src_buff_size,
709 int (*match_fun)(void *, void *, smx_action_t), void *data,
712 /* checking for infinite values */
713 xbt_assert(isfinite(task_size), "task_size is not finite!");
714 xbt_assert(isfinite(rate), "rate is not finite!");
715 xbt_assert(isfinite(timeout), "timeout is not finite!");
717 xbt_assert(rdv, "No rendez-vous point defined for send");
719 if (MC_is_active()) {
720 /* the model-checker wants two separate simcalls */
721 smx_action_t comm = simcall_comm_isend(rdv, task_size, rate,
722 src_buff, src_buff_size, match_fun, NULL, data, 0);
723 simcall_comm_wait(comm, timeout);
726 simcall_BODY_comm_send(rdv, task_size, rate, src_buff, src_buff_size,
727 match_fun, data, timeout);
732 * \ingroup simix_comm_management
734 smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
735 void *src_buff, size_t src_buff_size,
736 int (*match_fun)(void *, void *, smx_action_t),
737 void (*clean_fun)(void *),
741 /* checking for infinite values */
742 xbt_assert(isfinite(task_size), "task_size is not finite!");
743 xbt_assert(isfinite(rate), "rate is not finite!");
745 xbt_assert(rdv, "No rendez-vous point defined for isend");
747 return simcall_BODY_comm_isend(rdv, task_size, rate, src_buff,
748 src_buff_size, match_fun,
749 clean_fun, data, detached);
752 * \ingroup simix_comm_management
754 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
755 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
757 xbt_assert(isfinite(timeout), "timeout is not finite!");
758 xbt_assert(rdv, "No rendez-vous point defined for recv");
760 if (MC_is_active()) {
761 /* the model-checker wants two separate simcalls */
762 smx_action_t comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
764 simcall_comm_wait(comm, timeout);
767 simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size,
768 match_fun, data, timeout);
772 * \ingroup simix_comm_management
774 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
775 int (*match_fun)(void *, void *, smx_action_t), void *data)
777 xbt_assert(rdv, "No rendez-vous point defined for irecv");
779 return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size,
785 * \ingroup simix_comm_management
787 smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
788 int (*match_fun)(void *, void *, smx_action_t), void *data)
790 xbt_assert(rdv, "No rendez-vous point defined for iprobe");
792 return simcall_BODY_comm_iprobe(rdv, src, tag, match_fun, data);
795 void simcall_comm_destroy(smx_action_t comm)
797 xbt_assert(comm, "Invalid parameter");
799 /* FIXME remove this simcall type: comms are auto-destroyed now */
802 smx_simcall_t simcall = simcall_mine();
804 simcall->call = SIMCALL_COMM_DESTROY;
805 simcall->comm_destroy.comm = comm;
807 SIMIX_simcall_push(simcall->issuer);
812 * \ingroup simix_comm_management
814 void simcall_comm_cancel(smx_action_t comm)
816 simcall_BODY_comm_cancel(comm);
820 * \ingroup simix_comm_management
822 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
824 return simcall_BODY_comm_waitany(comms);
828 * \ingroup simix_comm_management
830 int simcall_comm_testany(xbt_dynar_t comms)
832 if (xbt_dynar_is_empty(comms))
834 return simcall_BODY_comm_testany(comms);
838 * \ingroup simix_comm_management
840 void simcall_comm_wait(smx_action_t comm, double timeout)
842 xbt_assert(isfinite(timeout), "timeout is not finite!");
843 simcall_BODY_comm_wait(comm, timeout);
848 * \brief Set the category of an action.
850 * This functions changes the category only. It calls a surf function.
851 * \param execution The execution action
852 * \param category The tracing category
854 void simcall_set_category(smx_action_t action, const char *category)
856 if (category == NULL) {
859 simcall_BODY_set_category(action, category);
864 * \ingroup simix_comm_management
867 int simcall_comm_test(smx_action_t comm)
869 return simcall_BODY_comm_test(comm);
873 * \ingroup simix_comm_management
876 double simcall_comm_get_remains(smx_action_t comm)
878 return simcall_BODY_comm_get_remains(comm);
882 * \ingroup simix_comm_management
885 e_smx_state_t simcall_comm_get_state(smx_action_t comm)
887 return simcall_BODY_comm_get_state(comm);
891 * \ingroup simix_comm_management
894 void *simcall_comm_get_src_data(smx_action_t comm)
896 return simcall_BODY_comm_get_src_data(comm);
900 * \ingroup simix_comm_management
903 void *simcall_comm_get_dst_data(smx_action_t comm)
905 return simcall_BODY_comm_get_dst_data(comm);
909 * \ingroup simix_comm_management
912 smx_process_t simcall_comm_get_src_proc(smx_action_t comm)
914 return simcall_BODY_comm_get_src_proc(comm);
918 * \ingroup simix_comm_management
921 smx_process_t simcall_comm_get_dst_proc(smx_action_t comm)
923 return simcall_BODY_comm_get_dst_proc(comm);
926 #ifdef HAVE_LATENCY_BOUND_TRACKING
927 int simcall_comm_is_latency_bounded(smx_action_t comm)
929 return simcall_BODY_comm_is_latency_bounded(comm);
934 * \ingroup simix_synchro_management
937 smx_mutex_t simcall_mutex_init(void)
940 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
943 return simcall_BODY_mutex_init();
947 * \ingroup simix_synchro_management
950 void simcall_mutex_destroy(smx_mutex_t mutex)
952 simcall_BODY_mutex_destroy(mutex);
956 * \ingroup simix_synchro_management
959 void simcall_mutex_lock(smx_mutex_t mutex)
961 simcall_BODY_mutex_lock(mutex);
965 * \ingroup simix_synchro_management
968 int simcall_mutex_trylock(smx_mutex_t mutex)
970 return simcall_BODY_mutex_trylock(mutex);
974 * \ingroup simix_synchro_management
977 void simcall_mutex_unlock(smx_mutex_t mutex)
979 simcall_BODY_mutex_unlock(mutex);
983 * \ingroup simix_synchro_management
986 smx_cond_t simcall_cond_init(void)
988 return simcall_BODY_cond_init();
992 * \ingroup simix_synchro_management
995 void simcall_cond_destroy(smx_cond_t cond)
997 simcall_BODY_cond_destroy(cond);
1001 * \ingroup simix_synchro_management
1004 void simcall_cond_signal(smx_cond_t cond)
1006 simcall_BODY_cond_signal(cond);
1010 * \ingroup simix_synchro_management
1013 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1015 simcall_BODY_cond_wait(cond, mutex);
1019 * \ingroup simix_synchro_management
1022 void simcall_cond_wait_timeout(smx_cond_t cond,
1026 xbt_assert(isfinite(timeout), "timeout is not finite!");
1027 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
1031 * \ingroup simix_synchro_management
1034 void simcall_cond_broadcast(smx_cond_t cond)
1036 simcall_BODY_cond_broadcast(cond);
1040 * \ingroup simix_synchro_management
1043 smx_sem_t simcall_sem_init(int capacity)
1045 return simcall_BODY_sem_init(capacity);
1049 * \ingroup simix_synchro_management
1052 void simcall_sem_destroy(smx_sem_t sem)
1054 simcall_sem_destroy(sem);
1058 * \ingroup simix_synchro_management
1061 void simcall_sem_release(smx_sem_t sem)
1063 simcall_BODY_sem_release(sem);
1067 * \ingroup simix_synchro_management
1070 int simcall_sem_would_block(smx_sem_t sem)
1072 return simcall_BODY_sem_would_block(sem);
1076 * \ingroup simix_synchro_management
1079 void simcall_sem_acquire(smx_sem_t sem)
1081 simcall_BODY_sem_acquire(sem);
1085 * \ingroup simix_synchro_management
1088 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1090 xbt_assert(isfinite(timeout), "timeout is not finite!");
1091 simcall_BODY_sem_acquire_timeout(sem, timeout);
1095 * \ingroup simix_synchro_management
1098 int simcall_sem_get_capacity(smx_sem_t sem)
1100 return simcall_BODY_sem_get_capacity(sem);
1104 * \ingroup simix_file_management
1107 double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
1109 return simcall_BODY_file_read(ptr, size, nmemb, stream);
1113 * \ingroup simix_file_management
1116 size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
1118 return simcall_BODY_file_write(ptr, size, nmemb, stream);
1122 * \ingroup simix_file_management
1125 smx_file_t simcall_file_open(const char* mount, const char* path, const char* mode)
1127 return simcall_BODY_file_open(mount, path, mode);
1131 * \ingroup simix_file_management
1134 int simcall_file_close(smx_file_t fp)
1136 return simcall_BODY_file_close(fp);
1140 * \ingroup simix_file_management
1143 int simcall_file_stat(smx_file_t fd, s_file_stat_t *buf)
1145 return simcall_BODY_file_stat(fd, buf);
1149 * \ingroup simix_file_management
1152 int simcall_file_unlink(smx_file_t fd)
1154 return simcall_BODY_file_unlink(fd);
1158 * \ingroup simix_file_management
1161 xbt_dict_t simcall_file_ls(const char* mount, const char* path)
1163 return simcall_BODY_file_ls(mount, path);
1168 void *simcall_mc_snapshot(void)
1170 return simcall_BODY_mc_snapshot();
1173 int simcall_mc_compare_snapshots(void *s1, void *s2){
1174 return simcall_BODY_mc_compare_snapshots(s1, s2);
1177 #endif /* HAVE_MC */
1179 /* ****************************************************************************************** */
1180 /* TUTORIAL: New API */
1181 /* All functions for simcall */
1182 /* ****************************************************************************************** */
1183 int simcall_new_api_fct(const char* param1, double param2){
1184 smx_simcall_t simcall = SIMIX_simcall_mine();
1185 simcall->call = SIMCALL_NEW_API_INIT;
1186 simcall->new_api.param1 = param1;
1187 simcall->new_api.param2 = param2;
1189 SIMIX_simcall_push(simcall->issuer);
1190 return simcall->new_api.result;
1193 /* ************************************************************************** */
1195 /** @brief returns a printable string representing a simcall */
1196 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1197 return simcall_names[kind];