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 number of core of the processor.
89 * \param host A SIMIX host
90 * \return The number of core
92 int simcall_host_get_core(smx_host_t host)
94 return simcall_BODY_host_get_core(host);
98 * \ingroup simix_host_management
99 * \brief Returns the list of processes attached to the host.
101 * \param host A SIMIX host
102 * \return the swag of attached processes
104 xbt_swag_t simcall_host_get_process_list(smx_host_t host)
106 return simcall_BODY_host_get_process_list(host);
111 * \ingroup simix_host_management
112 * \brief Returns the available speed of the processor.
114 * \return Speed currently available (in Mflop/s)
116 double simcall_host_get_available_speed(smx_host_t host)
118 return simcall_BODY_host_get_available_speed(host);
122 * \ingroup simix_host_management
123 * \brief Returns the state of a host.
125 * Two states are possible: 1 if the host is active or 0 if it has crashed.
126 * \param host A SIMIX host
127 * \return 1 if the host is available, 0 otherwise
129 int simcall_host_get_state(smx_host_t host)
131 return simcall_BODY_host_get_state(host);
135 * \ingroup simix_host_management
136 * \brief Returns the user data associated to a host.
138 * \param host SIMIX host
139 * \return the user data of this host
141 void* simcall_host_get_data(smx_host_t host)
143 return simcall_BODY_host_get_data(host);
147 * \ingroup simix_host_management
148 * \brief Sets the user data associated to a host.
150 * The host must not have previous user data associated to it.
151 * \param host A SIMIX host
152 * \param data The user data to set
154 void simcall_host_set_data(smx_host_t host, void *data)
156 simcall_host_set_data(host, data);
160 * \ingroup simix_host_management
161 * \brief Creates an action that executes some computation of an host.
163 * This function creates a SURF action and allocates the data necessary
164 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
166 * \param name Name of the execution action to create
167 * \param host SIMIX host where the action will be executed
168 * \param computation_amount amount Computation amount (in bytes)
169 * \param priority computation priority
170 * \return A new SIMIX execution action
173 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
174 double computation_amount,
177 /* checking for infinite values */
178 xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
179 xbt_assert(isfinite(priority), "priority is not finite!");
181 return simcall_BODY_host_execute(name, host, computation_amount, priority);
185 * \ingroup simix_host_management
186 * \brief Creates an action that may involve parallel computation on
187 * several hosts and communication between them.
189 * \param name Name of the execution action to create
190 * \param host_nb Number of hosts where the action will be executed
191 * \param host_list Array (of size host_nb) of hosts where the action will be executed
192 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
193 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
194 * amount between each pair of hosts
195 * \param amount the SURF action amount
196 * \param rate the SURF action rate
197 * \return A new SIMIX execution action
199 smx_action_t simcall_host_parallel_execute(const char *name,
201 smx_host_t *host_list,
202 double *computation_amount,
203 double *communication_amount,
208 /* checking for infinite values */
209 for (i = 0 ; i < host_nb ; ++i) {
210 xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i);
211 for (j = 0 ; j < host_nb ; ++j) {
212 xbt_assert(isfinite(communication_amount[i + host_nb * j]),
213 "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j);
217 xbt_assert(isfinite(amount), "amount is not finite!");
218 xbt_assert(isfinite(rate), "rate is not finite!");
220 return simcall_BODY_host_parallel_execute(name, host_nb, host_list,
222 communication_amount,
228 * \ingroup simix_host_management
229 * \brief Destroys an execution action.
231 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
232 * \param execution The execution action to destroy
234 void simcall_host_execution_destroy(smx_action_t execution)
236 simcall_BODY_host_execution_destroy(execution);
240 * \ingroup simix_host_management
241 * \brief Cancels an execution action.
243 * This functions stops the execution. It calls a surf function.
244 * \param execution The execution action to cancel
246 void simcall_host_execution_cancel(smx_action_t execution)
248 simcall_BODY_host_execution_cancel(execution);
252 * \ingroup simix_host_management
253 * \brief Returns how much of an execution action remains to be done.
255 * \param execution The execution action
256 * \return The remaining amount
258 double simcall_host_execution_get_remains(smx_action_t execution)
260 return simcall_BODY_host_execution_get_remains(execution);
264 * \ingroup simix_host_management
265 * \brief Returns the state of an execution action.
267 * \param execution The execution action
270 e_smx_state_t simcall_host_execution_get_state(smx_action_t execution)
272 return simcall_BODY_host_execution_get_state(execution);
276 * \ingroup simix_host_management
277 * \brief Changes the priority of an execution action.
279 * This functions changes the priority only. It calls a surf function.
280 * \param execution The execution action
281 * \param priority The new priority
283 void simcall_host_execution_set_priority(smx_action_t execution, double priority)
285 /* checking for infinite values */
286 xbt_assert(isfinite(priority), "priority is not finite!");
288 simcall_BODY_host_execution_set_priority(execution, priority);
292 * \ingroup simix_host_management
293 * \brief Waits for the completion of an execution action and destroy it.
295 * \param execution The execution action
297 e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
299 return simcall_BODY_host_execution_wait(execution);
303 * \ingroup simix_process_management
304 * \brief Creates and runs a new SIMIX process.
306 * The structure and the corresponding thread are created and put in the list of ready processes.
308 * \param process the process created will be stored in this pointer
309 * \param name a name for the process. It is for user-level information and can be NULL.
310 * \param code the main function of the process
311 * \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.
312 * It can be retrieved with the function \ref simcall_process_get_data.
313 * \param hostname name of the host where the new agent is executed.
314 * \param kill_time time when the process is killed
315 * \param argc first argument passed to \a code
316 * \param argv second argument passed to \a code
317 * \param properties the properties of the process
318 * \param auto_restart either it is autorestarting or not.
320 void simcall_process_create(smx_process_t *process, const char *name,
321 xbt_main_func_t code,
323 const char *hostname,
325 int argc, char **argv,
326 xbt_dict_t properties,
329 simcall_BODY_process_create(process, name, code, data, hostname,
330 kill_time, argc, argv, properties,
335 * \ingroup simix_process_management
336 * \brief Kills a SIMIX process.
338 * This function simply kills a process.
340 * \param process poor victim
342 void simcall_process_kill(smx_process_t process)
344 simcall_BODY_process_kill(process);
348 * \ingroup simix_process_management
349 * \brief Kills all SIMIX processes.
351 void simcall_process_killall(int reset_pid)
353 simcall_BODY_process_killall(reset_pid);
357 * \ingroup simix_process_management
358 * \brief Cleans up a SIMIX process.
359 * \param process poor victim (must have already been killed)
361 void simcall_process_cleanup(smx_process_t process)
363 simcall_BODY_process_cleanup(process);
367 * \ingroup simix_process_management
368 * \brief Migrates an agent to another location.
370 * This function changes the value of the host on which \a process is running.
372 * \param process the process to migrate
373 * \param dest name of the new host
375 void simcall_process_change_host(smx_process_t process, smx_host_t dest)
377 simcall_BODY_process_change_host(process, dest);
381 * \ingroup simix_process_management
382 * \brief Suspends a process.
384 * This function suspends the process by suspending the action
385 * it was waiting for completion.
387 * \param process a SIMIX process
389 void simcall_process_suspend(smx_process_t process)
391 xbt_assert(process, "Invalid parameters");
393 simcall_BODY_process_suspend(process);
397 * \ingroup simix_process_management
398 * \brief Resumes a suspended process.
400 * This function resumes a suspended process by resuming the action
401 * it was waiting for completion.
403 * \param process a SIMIX process
405 void simcall_process_resume(smx_process_t process)
407 simcall_BODY_process_resume(process);
411 * \ingroup simix_process_management
412 * \brief Returns the amount of SIMIX processes in the system
414 * Maestro internal process is not counted, only user code processes are
416 int simcall_process_count(void)
418 return simcall_BODY_process_count();
422 * \ingroup simix_process_management
423 * \brief Return the PID of a #smx_process_t.
424 * \param process a SIMIX process
425 * \return the PID of this process
427 int simcall_process_get_PID(smx_process_t process)
429 if (process == SIMIX_process_self()) {
430 /* avoid a simcall if this function is called by the process itself */
431 return SIMIX_process_get_PID(process);
434 return simcall_BODY_process_get_PID(process);
438 * \ingroup simix_process_management
439 * \brief Return the parent PID of a #smx_process_t.
440 * \param process a SIMIX process
441 * \return the PID of this process parenrt
443 int simcall_process_get_PPID(smx_process_t process)
445 if (process == SIMIX_process_self()) {
446 /* avoid a simcall if this function is called by the process itself */
447 return SIMIX_process_get_PPID(process);
450 return simcall_BODY_process_get_PPID(process);
454 * \ingroup simix_process_management
455 * \brief Return the user data of a #smx_process_t.
456 * \param process a SIMIX process
457 * \return the user data of this process
459 void* simcall_process_get_data(smx_process_t process)
461 if (process == SIMIX_process_self()) {
462 /* avoid a simcall if this function is called by the process itself */
463 return SIMIX_process_get_data(process);
466 return simcall_BODY_process_get_data(process);
470 * \ingroup simix_process_management
471 * \brief Set the user data of a #smx_process_t.
473 * This functions sets the user data associated to \a process.
474 * \param process SIMIX process
475 * \param data User data
477 void simcall_process_set_data(smx_process_t process, void *data)
479 if (process == SIMIX_process_self()) {
480 /* avoid a simcall if this function is called by the process itself */
481 SIMIX_process_self_set_data(process, data);
484 simcall_BODY_process_set_data(process, data);
489 * \ingroup simix_process_management
490 * \brief Set the kill time of a process.
491 * \param process a process
492 * \param kill_time a double
494 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
497 if (kill_time > SIMIX_get_clock()) {
498 if (simix_global->kill_process_function) {
499 XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
500 sg_host_name(process->smx_host));
501 SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
507 * \ingroup simix_process_management
508 * \brief Return the location on which an agent is running.
510 * This functions returns the smx_host_t corresponding to the location on which
511 * \a process is running.
512 * \param process SIMIX process
515 smx_host_t simcall_process_get_host(smx_process_t process)
517 return simcall_BODY_process_get_host(process);
521 * \ingroup simix_process_management
522 * \brief Return the name of an agent.
524 * This functions checks whether \a process is a valid pointer or not and return its name.
525 * \param process SIMIX process
526 * \return The process name
528 const char* simcall_process_get_name(smx_process_t process)
530 if (process == SIMIX_process_self()) {
531 /* avoid a simcall if this function is called by the process itself */
532 return process->name;
534 return simcall_BODY_process_get_name(process);
538 * \ingroup simix_process_management
539 * \brief Returns true if the process is suspended .
541 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
542 * \param process SIMIX process
543 * \return 1, if the process is suspended, else 0.
545 int simcall_process_is_suspended(smx_process_t process)
547 return simcall_BODY_process_is_suspended(process);
551 * \ingroup simix_process_management
552 * \brief Return the properties
554 * This functions returns the properties associated with this process
556 xbt_dict_t simcall_process_get_properties(smx_process_t process)
558 return simcall_BODY_process_get_properties(process);
561 * \ingroup simix_process_management
562 * \brief Add an on_exit function
563 * Add an on_exit function which will be executed when the process exits/is killed.
565 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
567 simcall_BODY_process_on_exit(process, fun, data);
570 * \ingroup simix_process_management
571 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
572 * Will restart the process when the host comes back up if auto_restart is set to 1.
575 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
577 simcall_BODY_process_auto_restart_set(process, auto_restart);
581 * \ingroup simix_process_management
582 * \brief Restarts the process, killing it and starting it again from scratch.
584 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
586 return simcall_BODY_process_restart(process);
589 * \ingroup simix_process_management
590 * \brief Creates a new sleep SIMIX action.
592 * This function creates a SURF action and allocates the data necessary
593 * to create the SIMIX action. It can raise a host_error exception if the
594 * host crashed. The default SIMIX name of the action is "sleep".
596 * \param duration Time duration of the sleep.
597 * \return A result telling whether the sleep was successful
599 e_smx_state_t simcall_process_sleep(double duration)
601 /* checking for infinite values */
602 xbt_assert(isfinite(duration), "duration is not finite!");
603 return simcall_BODY_process_sleep(duration);
607 * \ingroup simix_rdv_management
608 * \brief Creates a new rendez-vous point
609 * \param name The name of the rendez-vous point
610 * \return The created rendez-vous point
612 smx_rdv_t simcall_rdv_create(const char *name)
614 return simcall_BODY_rdv_create(name);
619 * \ingroup simix_rdv_management
620 * \brief Destroy a rendez-vous point
621 * \param rdv The rendez-vous point to destroy
623 void simcall_rdv_destroy(smx_rdv_t rdv)
625 simcall_BODY_rdv_destroy(rdv);
628 * \ingroup simix_rdv_management
629 * \brief Returns a rendez-vous point knowing its name
631 smx_rdv_t simcall_rdv_get_by_name(const char *name)
633 xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
635 /* FIXME: this is a horrible loss of performance, so we hack it out by
636 * skipping the simcall (for now). It works in parallel, it won't work on
637 * distributed but probably we will change MSG for that. */
640 smx_simcall_t simcall = simcall_mine();
641 simcall->call = SIMCALL_RDV_GEY_BY_NAME;
642 simcall->rdv_get_by_name.name = name;
643 SIMIX_simcall_push(simcall->issuer);
644 return simcall->rdv_get_by_name.result;*/
646 return SIMIX_rdv_get_by_name(name);
650 * \ingroup simix_rdv_management
651 * \brief Counts the number of communication actions of a given host pending
652 * on a rendez-vous point.
653 * \param rdv The rendez-vous point
654 * \param host The host to be counted
655 * \return The number of comm actions pending in the rdv
657 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
659 return simcall_BODY_rdv_comm_count_by_host(rdv, host);
663 * \ingroup simix_rdv_management
664 * \brief returns the communication at the head of the rendez-vous
665 * \param rdv The rendez-vous point
666 * \return The communication or NULL if empty
668 smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
670 return simcall_BODY_rdv_get_head(rdv);
673 void simcall_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
675 simcall_BODY_rdv_set_receiver(rdv, process);
678 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
680 return simcall_BODY_rdv_get_receiver(rdv);
684 * \ingroup simix_comm_management
686 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
687 void *src_buff, size_t src_buff_size,
688 int (*match_fun)(void *, void *, smx_action_t), void *data,
691 /* checking for infinite values */
692 xbt_assert(isfinite(task_size), "task_size is not finite!");
693 xbt_assert(isfinite(rate), "rate is not finite!");
694 xbt_assert(isfinite(timeout), "timeout is not finite!");
696 xbt_assert(rdv, "No rendez-vous point defined for send");
698 if (MC_is_active()) {
699 /* the model-checker wants two separate simcalls */
700 smx_action_t comm = simcall_comm_isend(rdv, task_size, rate,
701 src_buff, src_buff_size, match_fun, NULL, data, 0);
702 simcall_comm_wait(comm, timeout);
705 simcall_BODY_comm_send(rdv, task_size, rate, src_buff, src_buff_size,
706 match_fun, data, timeout);
711 * \ingroup simix_comm_management
713 smx_action_t simcall_comm_isend(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),
716 void (*clean_fun)(void *),
720 /* checking for infinite values */
721 xbt_assert(isfinite(task_size), "task_size is not finite!");
722 xbt_assert(isfinite(rate), "rate is not finite!");
724 xbt_assert(rdv, "No rendez-vous point defined for isend");
726 return simcall_BODY_comm_isend(rdv, task_size, rate, src_buff,
727 src_buff_size, match_fun,
728 clean_fun, data, detached);
731 * \ingroup simix_comm_management
733 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
734 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
736 xbt_assert(isfinite(timeout), "timeout is not finite!");
737 xbt_assert(rdv, "No rendez-vous point defined for recv");
739 if (MC_is_active()) {
740 /* the model-checker wants two separate simcalls */
741 smx_action_t comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
743 simcall_comm_wait(comm, timeout);
746 simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size,
747 match_fun, data, timeout);
751 * \ingroup simix_comm_management
753 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
754 int (*match_fun)(void *, void *, smx_action_t), void *data)
756 xbt_assert(rdv, "No rendez-vous point defined for irecv");
758 return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size,
764 * \ingroup simix_comm_management
766 void simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
767 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout, double rate)
769 xbt_assert(isfinite(timeout), "timeout is not finite!");
770 xbt_assert(rdv, "No rendez-vous point defined for recv");
772 if (MC_is_active()) {
773 /* the model-checker wants two separate simcalls */
774 smx_action_t comm = simcall_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
775 match_fun, data, rate);
776 simcall_comm_wait(comm, timeout);
779 simcall_BODY_comm_recv_bounded(rdv, dst_buff, dst_buff_size,
780 match_fun, data, timeout, rate);
784 * \ingroup simix_comm_management
786 smx_action_t simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
787 int (*match_fun)(void *, void *, smx_action_t), void *data, double rate)
789 xbt_assert(rdv, "No rendez-vous point defined for irecv");
791 return simcall_BODY_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
792 match_fun, data, rate);
797 * \ingroup simix_comm_management
799 smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
800 int (*match_fun)(void *, void *, smx_action_t), void *data)
802 xbt_assert(rdv, "No rendez-vous point defined for iprobe");
804 return simcall_BODY_comm_iprobe(rdv, src, tag, match_fun, data);
807 void simcall_comm_destroy(smx_action_t comm)
809 xbt_assert(comm, "Invalid parameter");
811 /* FIXME remove this simcall type: comms are auto-destroyed now */
814 smx_simcall_t simcall = simcall_mine();
816 simcall->call = SIMCALL_COMM_DESTROY;
817 simcall->comm_destroy.comm = comm;
819 SIMIX_simcall_push(simcall->issuer);
824 * \ingroup simix_comm_management
826 void simcall_comm_cancel(smx_action_t comm)
828 simcall_BODY_comm_cancel(comm);
832 * \ingroup simix_comm_management
834 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
836 return simcall_BODY_comm_waitany(comms);
840 * \ingroup simix_comm_management
842 int simcall_comm_testany(xbt_dynar_t comms)
844 if (xbt_dynar_is_empty(comms))
846 return simcall_BODY_comm_testany(comms);
850 * \ingroup simix_comm_management
852 void simcall_comm_wait(smx_action_t comm, double timeout)
854 xbt_assert(isfinite(timeout), "timeout is not finite!");
855 simcall_BODY_comm_wait(comm, timeout);
860 * \brief Set the category of an action.
862 * This functions changes the category only. It calls a surf function.
863 * \param execution The execution action
864 * \param category The tracing category
866 void simcall_set_category(smx_action_t action, const char *category)
868 if (category == NULL) {
871 simcall_BODY_set_category(action, category);
876 * \ingroup simix_comm_management
879 int simcall_comm_test(smx_action_t comm)
881 return simcall_BODY_comm_test(comm);
885 * \ingroup simix_comm_management
888 double simcall_comm_get_remains(smx_action_t comm)
890 return simcall_BODY_comm_get_remains(comm);
894 * \ingroup simix_comm_management
897 e_smx_state_t simcall_comm_get_state(smx_action_t comm)
899 return simcall_BODY_comm_get_state(comm);
903 * \ingroup simix_comm_management
906 void *simcall_comm_get_src_data(smx_action_t comm)
908 return simcall_BODY_comm_get_src_data(comm);
912 * \ingroup simix_comm_management
915 void *simcall_comm_get_dst_data(smx_action_t comm)
917 return simcall_BODY_comm_get_dst_data(comm);
921 * \ingroup simix_comm_management
924 smx_process_t simcall_comm_get_src_proc(smx_action_t comm)
926 return simcall_BODY_comm_get_src_proc(comm);
930 * \ingroup simix_comm_management
933 smx_process_t simcall_comm_get_dst_proc(smx_action_t comm)
935 return simcall_BODY_comm_get_dst_proc(comm);
938 #ifdef HAVE_LATENCY_BOUND_TRACKING
939 int simcall_comm_is_latency_bounded(smx_action_t comm)
941 return simcall_BODY_comm_is_latency_bounded(comm);
946 * \ingroup simix_synchro_management
949 smx_mutex_t simcall_mutex_init(void)
952 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
955 return simcall_BODY_mutex_init();
959 * \ingroup simix_synchro_management
962 void simcall_mutex_destroy(smx_mutex_t mutex)
964 simcall_BODY_mutex_destroy(mutex);
968 * \ingroup simix_synchro_management
971 void simcall_mutex_lock(smx_mutex_t mutex)
973 simcall_BODY_mutex_lock(mutex);
977 * \ingroup simix_synchro_management
980 int simcall_mutex_trylock(smx_mutex_t mutex)
982 return simcall_BODY_mutex_trylock(mutex);
986 * \ingroup simix_synchro_management
989 void simcall_mutex_unlock(smx_mutex_t mutex)
991 simcall_BODY_mutex_unlock(mutex);
995 * \ingroup simix_synchro_management
998 smx_cond_t simcall_cond_init(void)
1000 return simcall_BODY_cond_init();
1004 * \ingroup simix_synchro_management
1007 void simcall_cond_destroy(smx_cond_t cond)
1009 simcall_BODY_cond_destroy(cond);
1013 * \ingroup simix_synchro_management
1016 void simcall_cond_signal(smx_cond_t cond)
1018 simcall_BODY_cond_signal(cond);
1022 * \ingroup simix_synchro_management
1025 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1027 simcall_BODY_cond_wait(cond, mutex);
1031 * \ingroup simix_synchro_management
1034 void simcall_cond_wait_timeout(smx_cond_t cond,
1038 xbt_assert(isfinite(timeout), "timeout is not finite!");
1039 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
1043 * \ingroup simix_synchro_management
1046 void simcall_cond_broadcast(smx_cond_t cond)
1048 simcall_BODY_cond_broadcast(cond);
1052 * \ingroup simix_synchro_management
1055 smx_sem_t simcall_sem_init(int capacity)
1057 return simcall_BODY_sem_init(capacity);
1061 * \ingroup simix_synchro_management
1064 void simcall_sem_destroy(smx_sem_t sem)
1066 simcall_sem_destroy(sem);
1070 * \ingroup simix_synchro_management
1073 void simcall_sem_release(smx_sem_t sem)
1075 simcall_BODY_sem_release(sem);
1079 * \ingroup simix_synchro_management
1082 int simcall_sem_would_block(smx_sem_t sem)
1084 return simcall_BODY_sem_would_block(sem);
1088 * \ingroup simix_synchro_management
1091 void simcall_sem_acquire(smx_sem_t sem)
1093 simcall_BODY_sem_acquire(sem);
1097 * \ingroup simix_synchro_management
1100 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1102 xbt_assert(isfinite(timeout), "timeout is not finite!");
1103 simcall_BODY_sem_acquire_timeout(sem, timeout);
1107 * \ingroup simix_synchro_management
1110 int simcall_sem_get_capacity(smx_sem_t sem)
1112 return simcall_BODY_sem_get_capacity(sem);
1116 * \ingroup simix_file_management
1119 size_t simcall_file_read(size_t size, smx_file_t fd)
1121 return simcall_BODY_file_read(size, fd);
1125 * \ingroup simix_file_management
1128 size_t simcall_file_write(size_t size, smx_file_t fd)
1130 return simcall_BODY_file_write(size, fd);
1134 * \ingroup simix_file_management
1137 smx_file_t simcall_file_open(const char* mount, const char* path)
1139 return simcall_BODY_file_open(mount, path);
1143 * \ingroup simix_file_management
1146 int simcall_file_close(smx_file_t fd)
1148 return simcall_BODY_file_close(fd);
1152 * \ingroup simix_file_management
1155 int simcall_file_unlink(smx_file_t fd)
1157 return simcall_BODY_file_unlink(fd);
1161 * \ingroup simix_file_management
1164 xbt_dict_t simcall_file_ls(const char* mount, const char* path)
1166 return simcall_BODY_file_ls(mount, path);
1169 * \ingroup simix_file_management
1172 size_t simcall_file_get_size (smx_file_t fd){
1173 return simcall_BODY_file_get_size(fd);
1178 void *simcall_mc_snapshot(void)
1180 return simcall_BODY_mc_snapshot();
1183 int simcall_mc_compare_snapshots(void *s1, void *s2){
1184 return simcall_BODY_mc_compare_snapshots(s1, s2);
1187 int simcall_mc_random(void)
1189 return simcall_BODY_mc_random();
1193 #endif /* HAVE_MC */
1195 /* ****************************************************************************************** */
1196 /* TUTORIAL: New API */
1197 /* All functions for simcall */
1198 /* ****************************************************************************************** */
1199 int simcall_new_api_fct(const char* param1, double param2){
1200 smx_simcall_t simcall = SIMIX_simcall_mine();
1201 simcall->call = SIMCALL_NEW_API_INIT;
1202 simcall->new_api.param1 = param1;
1203 simcall->new_api.param2 = param2;
1205 SIMIX_simcall_push(simcall->issuer);
1206 return simcall->new_api.result;
1209 /* ************************************************************************** */
1211 /** @brief returns a printable string representing a simcall */
1212 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1213 return simcall_names[kind];