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_migrate(smx_host_t vm)
295 /* will jump to SIMIX_pre_vm_migrate */
296 simcall_BODY_vm_migrate(vm);
299 void simcall_vm_suspend(smx_host_t vm)
301 /* will jump to SIMIX_pre_vm_suspend */
302 simcall_BODY_vm_suspend(vm);
305 void simcall_vm_resume(smx_host_t vm)
308 * simcall_BODY_ is defined in src/simix/smx_smurf_private.h.
309 * This function will jump to SIMIX_pre_vm_resume.
311 simcall_BODY_vm_resume(vm);
314 void simcall_vm_shutdown(smx_host_t vm)
316 /* will jump to SIMIX_pre_vm_shutdown */
317 simcall_BODY_vm_shutdown(vm);
320 void simcall_vm_destroy(smx_host_t vm)
323 * simcall_BODY_ is defined in src/simix/smx_smurf_private.h.
324 * This function will jump to SIMIX_pre_vm_destroy.
326 simcall_BODY_vm_destroy(vm);
330 * \ingroup simix_process_management
331 * \brief Creates and runs a new SIMIX process.
333 * The structure and the corresponding thread are created and put in the list of ready processes.
335 * \param process the process created will be stored in this pointer
336 * \param name a name for the process. It is for user-level information and can be NULL.
337 * \param code the main function of the process
338 * \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.
339 * It can be retrieved with the function \ref simcall_process_get_data.
340 * \param hostname name of the host where the new agent is executed.
341 * \param kill_time time when the process is killed
342 * \param argc first argument passed to \a code
343 * \param argv second argument passed to \a code
344 * \param properties the properties of the process
345 * \param auto_restart either it is autorestarting or not.
347 void simcall_process_create(smx_process_t *process, const char *name,
348 xbt_main_func_t code,
350 const char *hostname,
352 int argc, char **argv,
353 xbt_dict_t properties,
356 simcall_BODY_process_create(process, name, code, data, hostname,
357 kill_time, argc, argv, properties,
362 * \ingroup simix_process_management
363 * \brief Kills a SIMIX process.
365 * This function simply kills a process.
367 * \param process poor victim
369 void simcall_process_kill(smx_process_t process)
371 simcall_BODY_process_kill(process);
375 * \ingroup simix_process_management
376 * \brief Kills all SIMIX processes.
378 void simcall_process_killall(int reset_pid)
380 simcall_BODY_process_killall(reset_pid);
384 * \ingroup simix_process_management
385 * \brief Cleans up a SIMIX process.
386 * \param process poor victim (must have already been killed)
388 void simcall_process_cleanup(smx_process_t process)
390 simcall_BODY_process_cleanup(process);
394 * \ingroup simix_process_management
395 * \brief Migrates an agent to another location.
397 * This function changes the value of the host on which \a process is running.
399 * \param process the process to migrate
400 * \param dest name of the new host
402 void simcall_process_change_host(smx_process_t process, smx_host_t dest)
404 simcall_BODY_process_change_host(process, dest);
408 * \ingroup simix_process_management
409 * \brief Suspends a process.
411 * This function suspends the process by suspending the action
412 * it was waiting for completion.
414 * \param process a SIMIX process
416 void simcall_process_suspend(smx_process_t process)
418 xbt_assert(process, "Invalid parameters");
420 simcall_BODY_process_suspend(process);
424 * \ingroup simix_process_management
425 * \brief Resumes a suspended process.
427 * This function resumes a suspended process by resuming the action
428 * it was waiting for completion.
430 * \param process a SIMIX process
432 void simcall_process_resume(smx_process_t process)
434 simcall_BODY_process_resume(process);
438 * \ingroup simix_process_management
439 * \brief Returns the amount of SIMIX processes in the system
441 * Maestro internal process is not counted, only user code processes are
443 int simcall_process_count(void)
445 return simcall_BODY_process_count();
449 * \ingroup simix_process_management
450 * \brief Return the PID of a #smx_process_t.
451 * \param process a SIMIX process
452 * \return the PID of this process
454 int simcall_process_get_PID(smx_process_t process)
456 if (process == SIMIX_process_self()) {
457 /* avoid a simcall if this function is called by the process itself */
458 return SIMIX_process_get_PID(process);
461 return simcall_BODY_process_get_PID(process);
465 * \ingroup simix_process_management
466 * \brief Return the parent PID of a #smx_process_t.
467 * \param process a SIMIX process
468 * \return the PID of this process parenrt
470 int simcall_process_get_PPID(smx_process_t process)
472 if (process == SIMIX_process_self()) {
473 /* avoid a simcall if this function is called by the process itself */
474 return SIMIX_process_get_PPID(process);
477 return simcall_BODY_process_get_PPID(process);
481 * \ingroup simix_process_management
482 * \brief Return the user data of a #smx_process_t.
483 * \param process a SIMIX process
484 * \return the user data of this process
486 void* simcall_process_get_data(smx_process_t process)
488 if (process == SIMIX_process_self()) {
489 /* avoid a simcall if this function is called by the process itself */
490 return SIMIX_process_get_data(process);
493 return simcall_BODY_process_get_data(process);
497 * \ingroup simix_process_management
498 * \brief Set the user data of a #smx_process_t.
500 * This functions sets the user data associated to \a process.
501 * \param process SIMIX process
502 * \param data User data
504 void simcall_process_set_data(smx_process_t process, void *data)
506 if (process == SIMIX_process_self()) {
507 /* avoid a simcall if this function is called by the process itself */
508 SIMIX_process_self_set_data(process, data);
511 simcall_BODY_process_set_data(process, data);
516 * \ingroup simix_process_management
517 * \brief Set the kill time of a process.
518 * \param process a process
519 * \param kill_time a double
521 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
524 if (kill_time > SIMIX_get_clock()) {
525 if (simix_global->kill_process_function) {
526 XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
527 sg_host_name(process->smx_host));
528 SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
534 * \ingroup simix_process_management
535 * \brief Return the location on which an agent is running.
537 * This functions returns the smx_host_t corresponding to the location on which
538 * \a process is running.
539 * \param process SIMIX process
542 smx_host_t simcall_process_get_host(smx_process_t process)
544 return simcall_BODY_process_get_host(process);
548 * \ingroup simix_process_management
549 * \brief Return the name of an agent.
551 * This functions checks whether \a process is a valid pointer or not and return its name.
552 * \param process SIMIX process
553 * \return The process name
555 const char* simcall_process_get_name(smx_process_t process)
557 if (process == SIMIX_process_self()) {
558 /* avoid a simcall if this function is called by the process itself */
559 return process->name;
561 return simcall_BODY_process_get_name(process);
565 * \ingroup simix_process_management
566 * \brief Returns true if the process is suspended .
568 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
569 * \param process SIMIX process
570 * \return 1, if the process is suspended, else 0.
572 int simcall_process_is_suspended(smx_process_t process)
574 return simcall_BODY_process_is_suspended(process);
578 * \ingroup simix_process_management
579 * \brief Return the properties
581 * This functions returns the properties associated with this process
583 xbt_dict_t simcall_process_get_properties(smx_process_t process)
585 return simcall_BODY_process_get_properties(process);
588 * \ingroup simix_process_management
589 * \brief Add an on_exit function
590 * Add an on_exit function which will be executed when the process exits/is killed.
592 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
594 simcall_BODY_process_on_exit(process, fun, data);
597 * \ingroup simix_process_management
598 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
599 * Will restart the process when the host comes back up if auto_restart is set to 1.
602 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
604 simcall_BODY_process_auto_restart_set(process, auto_restart);
608 * \ingroup simix_process_management
609 * \brief Restarts the process, killing it and starting it again from scratch.
611 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
613 return simcall_BODY_process_restart(process);
616 * \ingroup simix_process_management
617 * \brief Creates a new sleep SIMIX action.
619 * This function creates a SURF action and allocates the data necessary
620 * to create the SIMIX action. It can raise a host_error exception if the
621 * host crashed. The default SIMIX name of the action is "sleep".
623 * \param duration Time duration of the sleep.
624 * \return A result telling whether the sleep was successful
626 e_smx_state_t simcall_process_sleep(double duration)
628 /* checking for infinite values */
629 xbt_assert(isfinite(duration), "duration is not finite!");
630 return simcall_BODY_process_sleep(duration);
634 * \ingroup simix_rdv_management
635 * \brief Creates a new rendez-vous point
636 * \param name The name of the rendez-vous point
637 * \return The created rendez-vous point
639 smx_rdv_t simcall_rdv_create(const char *name)
641 return simcall_BODY_rdv_create(name);
646 * \ingroup simix_rdv_management
647 * \brief Destroy a rendez-vous point
648 * \param rdv The rendez-vous point to destroy
650 void simcall_rdv_destroy(smx_rdv_t rdv)
652 simcall_BODY_rdv_destroy(rdv);
655 * \ingroup simix_rdv_management
656 * \brief Returns a rendez-vous point knowing its name
658 smx_rdv_t simcall_rdv_get_by_name(const char *name)
660 xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
662 /* FIXME: this is a horrible lost of performance, so we hack it out by
663 * skipping the simcall (for now). It works in parallel, it won't work on
664 * distributed but probably we will change MSG for that. */
667 smx_simcall_t simcall = simcall_mine();
668 simcall->call = SIMCALL_RDV_GEY_BY_NAME;
669 simcall->rdv_get_by_name.name = name;
670 SIMIX_simcall_push(simcall->issuer);
671 return simcall->rdv_get_by_name.result;*/
673 return SIMIX_rdv_get_by_name(name);
677 * \ingroup simix_rdv_management
678 * \brief Counts the number of communication actions of a given host pending
679 * on a rendez-vous point.
680 * \param rdv The rendez-vous point
681 * \param host The host to be counted
682 * \return The number of comm actions pending in the rdv
684 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
686 return simcall_BODY_rdv_comm_count_by_host(rdv, host);
690 * \ingroup simix_rdv_management
691 * \brief returns the communication at the head of the rendez-vous
692 * \param rdv The rendez-vous point
693 * \return The communication or NULL if empty
695 smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
697 return simcall_BODY_rdv_get_head(rdv);
700 void simcall_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
702 simcall_BODY_rdv_set_receiver(rdv, process);
705 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
707 return simcall_BODY_rdv_get_receiver(rdv);
711 * \ingroup simix_comm_management
713 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
714 void *src_buff, size_t src_buff_size,
715 int (*match_fun)(void *, void *, smx_action_t), void *data,
718 /* checking for infinite values */
719 xbt_assert(isfinite(task_size), "task_size is not finite!");
720 xbt_assert(isfinite(rate), "rate is not finite!");
721 xbt_assert(isfinite(timeout), "timeout is not finite!");
723 xbt_assert(rdv, "No rendez-vous point defined for send");
725 if (MC_is_active()) {
726 /* the model-checker wants two separate simcalls */
727 smx_action_t comm = simcall_comm_isend(rdv, task_size, rate,
728 src_buff, src_buff_size, match_fun, NULL, data, 0);
729 simcall_comm_wait(comm, timeout);
732 simcall_BODY_comm_send(rdv, task_size, rate, src_buff, src_buff_size,
733 match_fun, data, timeout);
738 * \ingroup simix_comm_management
740 smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
741 void *src_buff, size_t src_buff_size,
742 int (*match_fun)(void *, void *, smx_action_t),
743 void (*clean_fun)(void *),
747 /* checking for infinite values */
748 xbt_assert(isfinite(task_size), "task_size is not finite!");
749 xbt_assert(isfinite(rate), "rate is not finite!");
751 xbt_assert(rdv, "No rendez-vous point defined for isend");
753 return simcall_BODY_comm_isend(rdv, task_size, rate, src_buff,
754 src_buff_size, match_fun,
755 clean_fun, data, detached);
758 * \ingroup simix_comm_management
760 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
761 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
763 xbt_assert(isfinite(timeout), "timeout is not finite!");
764 xbt_assert(rdv, "No rendez-vous point defined for recv");
766 if (MC_is_active()) {
767 /* the model-checker wants two separate simcalls */
768 smx_action_t comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
770 simcall_comm_wait(comm, timeout);
773 simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size,
774 match_fun, data, timeout);
778 * \ingroup simix_comm_management
780 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
781 int (*match_fun)(void *, void *, smx_action_t), void *data)
783 xbt_assert(rdv, "No rendez-vous point defined for irecv");
785 return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size,
791 * \ingroup simix_comm_management
793 smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
794 int (*match_fun)(void *, void *, smx_action_t), void *data)
796 xbt_assert(rdv, "No rendez-vous point defined for iprobe");
798 return simcall_BODY_comm_iprobe(rdv, src, tag, match_fun, data);
801 void simcall_comm_destroy(smx_action_t comm)
803 xbt_assert(comm, "Invalid parameter");
805 /* FIXME remove this simcall type: comms are auto-destroyed now */
808 smx_simcall_t simcall = simcall_mine();
810 simcall->call = SIMCALL_COMM_DESTROY;
811 simcall->comm_destroy.comm = comm;
813 SIMIX_simcall_push(simcall->issuer);
818 * \ingroup simix_comm_management
820 void simcall_comm_cancel(smx_action_t comm)
822 simcall_BODY_comm_cancel(comm);
826 * \ingroup simix_comm_management
828 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
830 return simcall_BODY_comm_waitany(comms);
834 * \ingroup simix_comm_management
836 int simcall_comm_testany(xbt_dynar_t comms)
838 if (xbt_dynar_is_empty(comms))
840 return simcall_BODY_comm_testany(comms);
844 * \ingroup simix_comm_management
846 void simcall_comm_wait(smx_action_t comm, double timeout)
848 xbt_assert(isfinite(timeout), "timeout is not finite!");
849 simcall_BODY_comm_wait(comm, timeout);
854 * \brief Set the category of an action.
856 * This functions changes the category only. It calls a surf function.
857 * \param execution The execution action
858 * \param category The tracing category
860 void simcall_set_category(smx_action_t action, const char *category)
862 if (category == NULL) {
865 simcall_BODY_set_category(action, category);
870 * \ingroup simix_comm_management
873 int simcall_comm_test(smx_action_t comm)
875 return simcall_BODY_comm_test(comm);
879 * \ingroup simix_comm_management
882 double simcall_comm_get_remains(smx_action_t comm)
884 return simcall_BODY_comm_get_remains(comm);
888 * \ingroup simix_comm_management
891 e_smx_state_t simcall_comm_get_state(smx_action_t comm)
893 return simcall_BODY_comm_get_state(comm);
897 * \ingroup simix_comm_management
900 void *simcall_comm_get_src_data(smx_action_t comm)
902 return simcall_BODY_comm_get_src_data(comm);
906 * \ingroup simix_comm_management
909 void *simcall_comm_get_dst_data(smx_action_t comm)
911 return simcall_BODY_comm_get_dst_data(comm);
915 * \ingroup simix_comm_management
918 smx_process_t simcall_comm_get_src_proc(smx_action_t comm)
920 return simcall_BODY_comm_get_src_proc(comm);
924 * \ingroup simix_comm_management
927 smx_process_t simcall_comm_get_dst_proc(smx_action_t comm)
929 return simcall_BODY_comm_get_dst_proc(comm);
932 #ifdef HAVE_LATENCY_BOUND_TRACKING
933 int simcall_comm_is_latency_bounded(smx_action_t comm)
935 return simcall_BODY_comm_is_latency_bounded(comm);
940 * \ingroup simix_synchro_management
943 smx_mutex_t simcall_mutex_init(void)
946 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
949 return simcall_BODY_mutex_init();
953 * \ingroup simix_synchro_management
956 void simcall_mutex_destroy(smx_mutex_t mutex)
958 simcall_BODY_mutex_destroy(mutex);
962 * \ingroup simix_synchro_management
965 void simcall_mutex_lock(smx_mutex_t mutex)
967 simcall_BODY_mutex_lock(mutex);
971 * \ingroup simix_synchro_management
974 int simcall_mutex_trylock(smx_mutex_t mutex)
976 return simcall_BODY_mutex_trylock(mutex);
980 * \ingroup simix_synchro_management
983 void simcall_mutex_unlock(smx_mutex_t mutex)
985 simcall_BODY_mutex_unlock(mutex);
989 * \ingroup simix_synchro_management
992 smx_cond_t simcall_cond_init(void)
994 return simcall_BODY_cond_init();
998 * \ingroup simix_synchro_management
1001 void simcall_cond_destroy(smx_cond_t cond)
1003 simcall_BODY_cond_destroy(cond);
1007 * \ingroup simix_synchro_management
1010 void simcall_cond_signal(smx_cond_t cond)
1012 simcall_BODY_cond_signal(cond);
1016 * \ingroup simix_synchro_management
1019 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1021 simcall_BODY_cond_wait(cond, mutex);
1025 * \ingroup simix_synchro_management
1028 void simcall_cond_wait_timeout(smx_cond_t cond,
1032 xbt_assert(isfinite(timeout), "timeout is not finite!");
1033 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
1037 * \ingroup simix_synchro_management
1040 void simcall_cond_broadcast(smx_cond_t cond)
1042 simcall_BODY_cond_broadcast(cond);
1046 * \ingroup simix_synchro_management
1049 smx_sem_t simcall_sem_init(int capacity)
1051 return simcall_BODY_sem_init(capacity);
1055 * \ingroup simix_synchro_management
1058 void simcall_sem_destroy(smx_sem_t sem)
1060 simcall_sem_destroy(sem);
1064 * \ingroup simix_synchro_management
1067 void simcall_sem_release(smx_sem_t sem)
1069 simcall_BODY_sem_release(sem);
1073 * \ingroup simix_synchro_management
1076 int simcall_sem_would_block(smx_sem_t sem)
1078 return simcall_BODY_sem_would_block(sem);
1082 * \ingroup simix_synchro_management
1085 void simcall_sem_acquire(smx_sem_t sem)
1087 simcall_BODY_sem_acquire(sem);
1091 * \ingroup simix_synchro_management
1094 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1096 xbt_assert(isfinite(timeout), "timeout is not finite!");
1097 simcall_BODY_sem_acquire_timeout(sem, timeout);
1101 * \ingroup simix_synchro_management
1104 int simcall_sem_get_capacity(smx_sem_t sem)
1106 return simcall_BODY_sem_get_capacity(sem);
1110 * \ingroup simix_file_management
1113 double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
1115 return simcall_BODY_file_read(ptr, size, nmemb, stream);
1119 * \ingroup simix_file_management
1122 size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
1124 return simcall_BODY_file_write(ptr, size, nmemb, stream);
1128 * \ingroup simix_file_management
1131 smx_file_t simcall_file_open(const char* mount, const char* path, const char* mode)
1133 return simcall_BODY_file_open(mount, path, mode);
1137 * \ingroup simix_file_management
1140 int simcall_file_close(smx_file_t fp)
1142 return simcall_BODY_file_close(fp);
1146 * \ingroup simix_file_management
1149 int simcall_file_stat(smx_file_t fd, s_file_stat_t *buf)
1151 return simcall_BODY_file_stat(fd, buf);
1155 * \ingroup simix_file_management
1158 int simcall_file_unlink(smx_file_t fd)
1160 return simcall_BODY_file_unlink(fd);
1164 * \ingroup simix_file_management
1167 xbt_dict_t simcall_file_ls(const char* mount, const char* path)
1169 return simcall_BODY_file_ls(mount, path);
1174 void *simcall_mc_snapshot(void)
1176 return simcall_BODY_mc_snapshot();
1179 int simcall_mc_compare_snapshots(void *s1, void *s2){
1180 return simcall_BODY_mc_compare_snapshots(s1, s2);
1183 #endif /* HAVE_MC */
1185 /* ****************************************************************************************** */
1186 /* TUTORIAL: New API */
1187 /* All functions for simcall */
1188 /* ****************************************************************************************** */
1189 int simcall_new_api_fct(const char* param1, double param2){
1190 smx_simcall_t simcall = SIMIX_simcall_mine();
1191 simcall->call = SIMCALL_NEW_API_INIT;
1192 simcall->new_api.param1 = param1;
1193 simcall->new_api.param2 = param2;
1195 SIMIX_simcall_push(simcall->issuer);
1196 return simcall->new_api.result;
1199 /* ************************************************************************** */
1201 /** @brief returns a printable string representing a simcall */
1202 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1203 return simcall_names[kind];