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);
100 * \ingroup simix_host_management
101 * \brief Returns the available speed of the processor.
103 * \return Speed currently available (in Mflop/s)
105 double simcall_host_get_available_speed(smx_host_t host)
107 return simcall_BODY_host_get_available_speed(host);
111 * \ingroup simix_host_management
112 * \brief Returns the state of a host.
114 * Two states are possible: 1 if the host is active or 0 if it has crashed.
115 * \param host A SIMIX host
116 * \return 1 if the host is available, 0 otherwise
118 int simcall_host_get_state(smx_host_t host)
120 return simcall_BODY_host_get_state(host);
124 * \ingroup simix_host_management
125 * \brief Returns the user data associated to a host.
127 * \param host SIMIX host
128 * \return the user data of this host
130 void* simcall_host_get_data(smx_host_t host)
132 return simcall_BODY_host_get_data(host);
136 * \ingroup simix_host_management
137 * \brief Sets the user data associated to a host.
139 * The host must not have previous user data associated to it.
140 * \param host A SIMIX host
141 * \param data The user data to set
143 void simcall_host_set_data(smx_host_t host, void *data)
145 simcall_host_set_data(host, data);
149 * \ingroup simix_host_management
150 * \brief Returns the power peak of a host.
152 * \param host A SIMIX host
153 * \return the current power peak value (double)
155 double simcall_host_get_current_power_peak(smx_host_t host)
157 return simcall_BODY_host_get_current_power_peak(host);
161 * \ingroup simix_host_management
162 * \brief Returns one power peak (in flops/s) of a host at a given pstate
164 * \param host A SIMIX host
165 * \param pstate_index pstate to test
166 * \return the current power peak value (double) for pstate_index
168 double simcall_host_get_power_peak_at(smx_host_t host, int pstate_index)
170 return simcall_BODY_host_get_power_peak_at(host, pstate_index);
174 * \ingroup simix_host_management
175 * \brief Returns the number of power states for a host.
177 * \param host A SIMIX host
178 * \return the number of power states
180 int simcall_host_get_nb_pstates(smx_host_t host)
182 return simcall_BODY_host_get_nb_pstates(host);
186 * \ingroup simix_host_management
187 * \brief Sets a new power peak for a host.
189 * \param host A SIMIX host
190 * \param pstate_index The pstate to which the CPU power will be set
193 void simcall_host_set_power_peak_at(smx_host_t host, int pstate_index)
195 simcall_BODY_host_set_power_peak_at(host, pstate_index);
199 * \ingroup simix_host_management
200 * \brief Returns the total energy consumed by the host (in Joules)
202 * \param host A SIMIX host
203 * \return the energy consumed by the host (double)
205 double simcall_host_get_consumed_energy(smx_host_t host)
207 return simcall_BODY_host_get_consumed_energy(host);
212 * \ingroup simix_host_management
213 * \brief Creates an action that executes some computation of an host.
215 * This function creates a SURF action and allocates the data necessary
216 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
218 * \param name Name of the execution action to create
219 * \param host SIMIX host where the action will be executed
220 * \param computation_amount amount Computation amount (in bytes)
221 * \param priority computation priority
222 * \return A new SIMIX execution action
224 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
225 double computation_amount,
228 /* checking for infinite values */
229 xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
230 xbt_assert(isfinite(priority), "priority is not finite!");
232 return simcall_BODY_host_execute(name, host, computation_amount, priority);
236 * \ingroup simix_host_management
237 * \brief Creates an action that may involve parallel computation on
238 * several hosts and communication between them.
240 * \param name Name of the execution action to create
241 * \param host_nb Number of hosts where the action will be executed
242 * \param host_list Array (of size host_nb) of hosts where the action will be executed
243 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
244 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
245 * amount between each pair of hosts
246 * \param amount the SURF action amount
247 * \param rate the SURF action rate
248 * \return A new SIMIX execution action
250 smx_action_t simcall_host_parallel_execute(const char *name,
252 smx_host_t *host_list,
253 double *computation_amount,
254 double *communication_amount,
259 /* checking for infinite values */
260 for (i = 0 ; i < host_nb ; ++i) {
261 xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i);
262 for (j = 0 ; j < host_nb ; ++j) {
263 xbt_assert(isfinite(communication_amount[i + host_nb * j]),
264 "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j);
268 xbt_assert(isfinite(amount), "amount is not finite!");
269 xbt_assert(isfinite(rate), "rate is not finite!");
271 return simcall_BODY_host_parallel_execute(name, host_nb, host_list,
273 communication_amount,
279 * \ingroup simix_host_management
280 * \brief Destroys an execution action.
282 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
283 * \param execution The execution action to destroy
285 void simcall_host_execution_destroy(smx_action_t execution)
287 simcall_BODY_host_execution_destroy(execution);
291 * \ingroup simix_host_management
292 * \brief Cancels an execution action.
294 * This functions stops the execution. It calls a surf function.
295 * \param execution The execution action to cancel
297 void simcall_host_execution_cancel(smx_action_t execution)
299 simcall_BODY_host_execution_cancel(execution);
303 * \ingroup simix_host_management
304 * \brief Returns how much of an execution action remains to be done.
306 * \param execution The execution action
307 * \return The remaining amount
309 double simcall_host_execution_get_remains(smx_action_t execution)
311 return simcall_BODY_host_execution_get_remains(execution);
315 * \ingroup simix_host_management
316 * \brief Returns the state of an execution action.
318 * \param execution The execution action
321 e_smx_state_t simcall_host_execution_get_state(smx_action_t execution)
323 return simcall_BODY_host_execution_get_state(execution);
327 * \ingroup simix_host_management
328 * \brief Changes the priority of an execution action.
330 * This functions changes the priority only. It calls a surf function.
331 * \param execution The execution action
332 * \param priority The new priority
334 void simcall_host_execution_set_priority(smx_action_t execution, double priority)
336 /* checking for infinite values */
337 xbt_assert(isfinite(priority), "priority is not finite!");
339 simcall_BODY_host_execution_set_priority(execution, priority);
343 * \ingroup simix_host_management
344 * \brief Waits for the completion of an execution action and destroy it.
346 * \param execution The execution action
348 e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
350 return simcall_BODY_host_execution_wait(execution);
354 * \ingroup simix_process_management
355 * \brief Creates and runs a new SIMIX process.
357 * The structure and the corresponding thread are created and put in the list of ready processes.
359 * \param process the process created will be stored in this pointer
360 * \param name a name for the process. It is for user-level information and can be NULL.
361 * \param code the main function of the process
362 * \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.
363 * It can be retrieved with the function \ref simcall_process_get_data.
364 * \param hostname name of the host where the new agent is executed.
365 * \param kill_time time when the process is killed
366 * \param argc first argument passed to \a code
367 * \param argv second argument passed to \a code
368 * \param properties the properties of the process
369 * \param auto_restart either it is autorestarting or not.
371 void simcall_process_create(smx_process_t *process, const char *name,
372 xbt_main_func_t code,
374 const char *hostname,
376 int argc, char **argv,
377 xbt_dict_t properties,
380 simcall_BODY_process_create(process, name, code, data, hostname,
381 kill_time, argc, argv, properties,
386 * \ingroup simix_process_management
387 * \brief Kills a SIMIX process.
389 * This function simply kills a process.
391 * \param process poor victim
393 void simcall_process_kill(smx_process_t process)
395 simcall_BODY_process_kill(process);
399 * \ingroup simix_process_management
400 * \brief Kills all SIMIX processes.
402 void simcall_process_killall(int reset_pid)
404 simcall_BODY_process_killall(reset_pid);
408 * \ingroup simix_process_management
409 * \brief Cleans up a SIMIX process.
410 * \param process poor victim (must have already been killed)
412 void simcall_process_cleanup(smx_process_t process)
414 simcall_BODY_process_cleanup(process);
418 * \ingroup simix_process_management
419 * \brief Migrates an agent to another location.
421 * This function changes the value of the host on which \a process is running.
423 * \param process the process to migrate
424 * \param dest name of the new host
426 void simcall_process_change_host(smx_process_t process, smx_host_t dest)
428 simcall_BODY_process_change_host(process, dest);
432 * \ingroup simix_process_management
433 * \brief Suspends a process.
435 * This function suspends the process by suspending the action
436 * it was waiting for completion.
438 * \param process a SIMIX process
440 void simcall_process_suspend(smx_process_t process)
442 xbt_assert(process, "Invalid parameters");
444 simcall_BODY_process_suspend(process);
448 * \ingroup simix_process_management
449 * \brief Resumes a suspended process.
451 * This function resumes a suspended process by resuming the action
452 * it was waiting for completion.
454 * \param process a SIMIX process
456 void simcall_process_resume(smx_process_t process)
458 simcall_BODY_process_resume(process);
462 * \ingroup simix_process_management
463 * \brief Returns the amount of SIMIX processes in the system
465 * Maestro internal process is not counted, only user code processes are
467 int simcall_process_count(void)
469 return simcall_BODY_process_count();
473 * \ingroup simix_process_management
474 * \brief Return the PID of a #smx_process_t.
475 * \param process a SIMIX process
476 * \return the PID of this process
478 int simcall_process_get_PID(smx_process_t process)
480 if (process == SIMIX_process_self()) {
481 /* avoid a simcall if this function is called by the process itself */
482 return SIMIX_process_get_PID(process);
485 return simcall_BODY_process_get_PID(process);
489 * \ingroup simix_process_management
490 * \brief Return the parent PID of a #smx_process_t.
491 * \param process a SIMIX process
492 * \return the PID of this process parenrt
494 int simcall_process_get_PPID(smx_process_t process)
496 if (process == SIMIX_process_self()) {
497 /* avoid a simcall if this function is called by the process itself */
498 return SIMIX_process_get_PPID(process);
501 return simcall_BODY_process_get_PPID(process);
505 * \ingroup simix_process_management
506 * \brief Return the user data of a #smx_process_t.
507 * \param process a SIMIX process
508 * \return the user data of this process
510 void* simcall_process_get_data(smx_process_t process)
512 if (process == SIMIX_process_self()) {
513 /* avoid a simcall if this function is called by the process itself */
514 return SIMIX_process_get_data(process);
517 return simcall_BODY_process_get_data(process);
521 * \ingroup simix_process_management
522 * \brief Set the user data of a #smx_process_t.
524 * This functions sets the user data associated to \a process.
525 * \param process SIMIX process
526 * \param data User data
528 void simcall_process_set_data(smx_process_t process, void *data)
530 if (process == SIMIX_process_self()) {
531 /* avoid a simcall if this function is called by the process itself */
532 SIMIX_process_self_set_data(process, data);
535 simcall_BODY_process_set_data(process, data);
540 * \ingroup simix_process_management
541 * \brief Set the kill time of a process.
542 * \param process a process
543 * \param kill_time a double
545 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
548 if (kill_time > SIMIX_get_clock()) {
549 if (simix_global->kill_process_function) {
550 XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
551 sg_host_name(process->smx_host));
552 SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
558 * \ingroup simix_process_management
559 * \brief Return the location on which an agent is running.
561 * This functions returns the smx_host_t corresponding to the location on which
562 * \a process is running.
563 * \param process SIMIX process
566 smx_host_t simcall_process_get_host(smx_process_t process)
568 return simcall_BODY_process_get_host(process);
572 * \ingroup simix_process_management
573 * \brief Return the name of an agent.
575 * This functions checks whether \a process is a valid pointer or not and return its name.
576 * \param process SIMIX process
577 * \return The process name
579 const char* simcall_process_get_name(smx_process_t process)
581 if (process == SIMIX_process_self()) {
582 /* avoid a simcall if this function is called by the process itself */
583 return process->name;
585 return simcall_BODY_process_get_name(process);
589 * \ingroup simix_process_management
590 * \brief Returns true if the process is suspended .
592 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
593 * \param process SIMIX process
594 * \return 1, if the process is suspended, else 0.
596 int simcall_process_is_suspended(smx_process_t process)
598 return simcall_BODY_process_is_suspended(process);
602 * \ingroup simix_process_management
603 * \brief Return the properties
605 * This functions returns the properties associated with this process
607 xbt_dict_t simcall_process_get_properties(smx_process_t process)
609 return simcall_BODY_process_get_properties(process);
612 * \ingroup simix_process_management
613 * \brief Add an on_exit function
614 * Add an on_exit function which will be executed when the process exits/is killed.
616 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
618 simcall_BODY_process_on_exit(process, fun, data);
621 * \ingroup simix_process_management
622 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
623 * Will restart the process when the host comes back up if auto_restart is set to 1.
626 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
628 simcall_BODY_process_auto_restart_set(process, auto_restart);
632 * \ingroup simix_process_management
633 * \brief Restarts the process, killing it and starting it again from scratch.
635 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
637 return simcall_BODY_process_restart(process);
640 * \ingroup simix_process_management
641 * \brief Creates a new sleep SIMIX action.
643 * This function creates a SURF action and allocates the data necessary
644 * to create the SIMIX action. It can raise a host_error exception if the
645 * host crashed. The default SIMIX name of the action is "sleep".
647 * \param duration Time duration of the sleep.
648 * \return A result telling whether the sleep was successful
650 e_smx_state_t simcall_process_sleep(double duration)
652 /* checking for infinite values */
653 xbt_assert(isfinite(duration), "duration is not finite!");
654 return simcall_BODY_process_sleep(duration);
658 * \ingroup simix_rdv_management
659 * \brief Creates a new rendez-vous point
660 * \param name The name of the rendez-vous point
661 * \return The created rendez-vous point
663 smx_rdv_t simcall_rdv_create(const char *name)
665 return simcall_BODY_rdv_create(name);
670 * \ingroup simix_rdv_management
671 * \brief Destroy a rendez-vous point
672 * \param rdv The rendez-vous point to destroy
674 void simcall_rdv_destroy(smx_rdv_t rdv)
676 simcall_BODY_rdv_destroy(rdv);
679 * \ingroup simix_rdv_management
680 * \brief Returns a rendez-vous point knowing its name
682 smx_rdv_t simcall_rdv_get_by_name(const char *name)
684 xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
686 /* FIXME: this is a horrible loss of performance, so we hack it out by
687 * skipping the simcall (for now). It works in parallel, it won't work on
688 * distributed but probably we will change MSG for that. */
691 smx_simcall_t simcall = simcall_mine();
692 simcall->call = SIMCALL_RDV_GEY_BY_NAME;
693 simcall->rdv_get_by_name.name = name;
694 SIMIX_simcall_push(simcall->issuer);
695 return simcall->rdv_get_by_name.result;*/
697 return SIMIX_rdv_get_by_name(name);
701 * \ingroup simix_rdv_management
702 * \brief Counts the number of communication actions of a given host pending
703 * on a rendez-vous point.
704 * \param rdv The rendez-vous point
705 * \param host The host to be counted
706 * \return The number of comm actions pending in the rdv
708 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
710 return simcall_BODY_rdv_comm_count_by_host(rdv, host);
714 * \ingroup simix_rdv_management
715 * \brief returns the communication at the head of the rendez-vous
716 * \param rdv The rendez-vous point
717 * \return The communication or NULL if empty
719 smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
721 return simcall_BODY_rdv_get_head(rdv);
724 void simcall_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
726 simcall_BODY_rdv_set_receiver(rdv, process);
729 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
731 return simcall_BODY_rdv_get_receiver(rdv);
735 * \ingroup simix_comm_management
737 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
738 void *src_buff, size_t src_buff_size,
739 int (*match_fun)(void *, void *, smx_action_t), void *data,
742 /* checking for infinite values */
743 xbt_assert(isfinite(task_size), "task_size is not finite!");
744 xbt_assert(isfinite(rate), "rate is not finite!");
745 xbt_assert(isfinite(timeout), "timeout is not finite!");
747 xbt_assert(rdv, "No rendez-vous point defined for send");
749 if (MC_is_active()) {
750 /* the model-checker wants two separate simcalls */
751 smx_action_t comm = simcall_comm_isend(rdv, task_size, rate,
752 src_buff, src_buff_size, match_fun, NULL, data, 0);
753 simcall_comm_wait(comm, timeout);
756 simcall_BODY_comm_send(rdv, task_size, rate, src_buff, src_buff_size,
757 match_fun, data, timeout);
762 * \ingroup simix_comm_management
764 smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
765 void *src_buff, size_t src_buff_size,
766 int (*match_fun)(void *, void *, smx_action_t),
767 void (*clean_fun)(void *),
771 /* checking for infinite values */
772 xbt_assert(isfinite(task_size), "task_size is not finite!");
773 xbt_assert(isfinite(rate), "rate is not finite!");
775 xbt_assert(rdv, "No rendez-vous point defined for isend");
777 return simcall_BODY_comm_isend(rdv, task_size, rate, src_buff,
778 src_buff_size, match_fun,
779 clean_fun, data, detached);
782 * \ingroup simix_comm_management
784 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
785 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
787 xbt_assert(isfinite(timeout), "timeout is not finite!");
788 xbt_assert(rdv, "No rendez-vous point defined for recv");
790 if (MC_is_active()) {
791 /* the model-checker wants two separate simcalls */
792 smx_action_t comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
794 simcall_comm_wait(comm, timeout);
797 simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size,
798 match_fun, data, timeout);
802 * \ingroup simix_comm_management
804 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
805 int (*match_fun)(void *, void *, smx_action_t), void *data)
807 xbt_assert(rdv, "No rendez-vous point defined for irecv");
809 return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size,
815 * \ingroup simix_comm_management
817 void simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
818 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout, double rate)
820 xbt_assert(isfinite(timeout), "timeout is not finite!");
821 xbt_assert(rdv, "No rendez-vous point defined for recv");
823 if (MC_is_active()) {
824 /* the model-checker wants two separate simcalls */
825 smx_action_t comm = simcall_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
826 match_fun, data, rate);
827 simcall_comm_wait(comm, timeout);
830 simcall_BODY_comm_recv_bounded(rdv, dst_buff, dst_buff_size,
831 match_fun, data, timeout, rate);
835 * \ingroup simix_comm_management
837 smx_action_t simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
838 int (*match_fun)(void *, void *, smx_action_t), void *data, double rate)
840 xbt_assert(rdv, "No rendez-vous point defined for irecv");
842 return simcall_BODY_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
843 match_fun, data, rate);
848 * \ingroup simix_comm_management
850 smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
851 int (*match_fun)(void *, void *, smx_action_t), void *data)
853 xbt_assert(rdv, "No rendez-vous point defined for iprobe");
855 return simcall_BODY_comm_iprobe(rdv, src, tag, match_fun, data);
858 void simcall_comm_destroy(smx_action_t comm)
860 xbt_assert(comm, "Invalid parameter");
862 /* FIXME remove this simcall type: comms are auto-destroyed now */
865 smx_simcall_t simcall = simcall_mine();
867 simcall->call = SIMCALL_COMM_DESTROY;
868 simcall->comm_destroy.comm = comm;
870 SIMIX_simcall_push(simcall->issuer);
875 * \ingroup simix_comm_management
877 void simcall_comm_cancel(smx_action_t comm)
879 simcall_BODY_comm_cancel(comm);
883 * \ingroup simix_comm_management
885 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
887 return simcall_BODY_comm_waitany(comms);
891 * \ingroup simix_comm_management
893 int simcall_comm_testany(xbt_dynar_t comms)
895 if (xbt_dynar_is_empty(comms))
897 return simcall_BODY_comm_testany(comms);
901 * \ingroup simix_comm_management
903 void simcall_comm_wait(smx_action_t comm, double timeout)
905 xbt_assert(isfinite(timeout), "timeout is not finite!");
906 simcall_BODY_comm_wait(comm, timeout);
911 * \brief Set the category of an action.
913 * This functions changes the category only. It calls a surf function.
914 * \param execution The execution action
915 * \param category The tracing category
917 void simcall_set_category(smx_action_t action, const char *category)
919 if (category == NULL) {
922 simcall_BODY_set_category(action, category);
927 * \ingroup simix_comm_management
930 int simcall_comm_test(smx_action_t comm)
932 return simcall_BODY_comm_test(comm);
936 * \ingroup simix_comm_management
939 double simcall_comm_get_remains(smx_action_t comm)
941 return simcall_BODY_comm_get_remains(comm);
945 * \ingroup simix_comm_management
948 e_smx_state_t simcall_comm_get_state(smx_action_t comm)
950 return simcall_BODY_comm_get_state(comm);
954 * \ingroup simix_comm_management
957 void *simcall_comm_get_src_data(smx_action_t comm)
959 return simcall_BODY_comm_get_src_data(comm);
963 * \ingroup simix_comm_management
966 void *simcall_comm_get_dst_data(smx_action_t comm)
968 return simcall_BODY_comm_get_dst_data(comm);
972 * \ingroup simix_comm_management
975 smx_process_t simcall_comm_get_src_proc(smx_action_t comm)
977 return simcall_BODY_comm_get_src_proc(comm);
981 * \ingroup simix_comm_management
984 smx_process_t simcall_comm_get_dst_proc(smx_action_t comm)
986 return simcall_BODY_comm_get_dst_proc(comm);
989 #ifdef HAVE_LATENCY_BOUND_TRACKING
990 int simcall_comm_is_latency_bounded(smx_action_t comm)
992 return simcall_BODY_comm_is_latency_bounded(comm);
997 * \ingroup simix_synchro_management
1000 smx_mutex_t simcall_mutex_init(void)
1003 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
1006 return simcall_BODY_mutex_init();
1010 * \ingroup simix_synchro_management
1013 void simcall_mutex_destroy(smx_mutex_t mutex)
1015 simcall_BODY_mutex_destroy(mutex);
1019 * \ingroup simix_synchro_management
1022 void simcall_mutex_lock(smx_mutex_t mutex)
1024 simcall_BODY_mutex_lock(mutex);
1028 * \ingroup simix_synchro_management
1031 int simcall_mutex_trylock(smx_mutex_t mutex)
1033 return simcall_BODY_mutex_trylock(mutex);
1037 * \ingroup simix_synchro_management
1040 void simcall_mutex_unlock(smx_mutex_t mutex)
1042 simcall_BODY_mutex_unlock(mutex);
1046 * \ingroup simix_synchro_management
1049 smx_cond_t simcall_cond_init(void)
1051 return simcall_BODY_cond_init();
1055 * \ingroup simix_synchro_management
1058 void simcall_cond_destroy(smx_cond_t cond)
1060 simcall_BODY_cond_destroy(cond);
1064 * \ingroup simix_synchro_management
1067 void simcall_cond_signal(smx_cond_t cond)
1069 simcall_BODY_cond_signal(cond);
1073 * \ingroup simix_synchro_management
1076 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1078 simcall_BODY_cond_wait(cond, mutex);
1082 * \ingroup simix_synchro_management
1085 void simcall_cond_wait_timeout(smx_cond_t cond,
1089 xbt_assert(isfinite(timeout), "timeout is not finite!");
1090 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
1094 * \ingroup simix_synchro_management
1097 void simcall_cond_broadcast(smx_cond_t cond)
1099 simcall_BODY_cond_broadcast(cond);
1103 * \ingroup simix_synchro_management
1106 smx_sem_t simcall_sem_init(int capacity)
1108 return simcall_BODY_sem_init(capacity);
1112 * \ingroup simix_synchro_management
1115 void simcall_sem_destroy(smx_sem_t sem)
1117 simcall_sem_destroy(sem);
1121 * \ingroup simix_synchro_management
1124 void simcall_sem_release(smx_sem_t sem)
1126 simcall_BODY_sem_release(sem);
1130 * \ingroup simix_synchro_management
1133 int simcall_sem_would_block(smx_sem_t sem)
1135 return simcall_BODY_sem_would_block(sem);
1139 * \ingroup simix_synchro_management
1142 void simcall_sem_acquire(smx_sem_t sem)
1144 simcall_BODY_sem_acquire(sem);
1148 * \ingroup simix_synchro_management
1151 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1153 xbt_assert(isfinite(timeout), "timeout is not finite!");
1154 simcall_BODY_sem_acquire_timeout(sem, timeout);
1158 * \ingroup simix_synchro_management
1161 int simcall_sem_get_capacity(smx_sem_t sem)
1163 return simcall_BODY_sem_get_capacity(sem);
1167 * \ingroup simix_file_management
1170 size_t simcall_file_read(size_t size, smx_file_t fd)
1172 return simcall_BODY_file_read(size, fd);
1176 * \ingroup simix_file_management
1179 size_t simcall_file_write(size_t size, smx_file_t fd)
1181 return simcall_BODY_file_write(size, fd);
1185 * \ingroup simix_file_management
1188 smx_file_t simcall_file_open(const char* mount, const char* path)
1190 return simcall_BODY_file_open(mount, path);
1194 * \ingroup simix_file_management
1197 int simcall_file_close(smx_file_t fd)
1199 return simcall_BODY_file_close(fd);
1203 * \ingroup simix_file_management
1206 int simcall_file_unlink(smx_file_t fd)
1208 return simcall_BODY_file_unlink(fd);
1212 * \ingroup simix_file_management
1215 xbt_dict_t simcall_file_ls(const char* mount, const char* path)
1217 return simcall_BODY_file_ls(mount, path);
1220 * \ingroup simix_file_management
1223 size_t simcall_file_get_size (smx_file_t fd){
1224 return simcall_BODY_file_get_size(fd);
1229 void *simcall_mc_snapshot(void)
1231 return simcall_BODY_mc_snapshot();
1234 int simcall_mc_compare_snapshots(void *s1, void *s2){
1235 return simcall_BODY_mc_compare_snapshots(s1, s2);
1238 int simcall_mc_random(void)
1240 return simcall_BODY_mc_random();
1244 #endif /* HAVE_MC */
1246 /* ****************************************************************************************** */
1247 /* TUTORIAL: New API */
1248 /* All functions for simcall */
1249 /* ****************************************************************************************** */
1250 int simcall_new_api_fct(const char* param1, double param2){
1251 smx_simcall_t simcall = SIMIX_simcall_mine();
1252 simcall->call = SIMCALL_NEW_API_INIT;
1253 simcall->new_api.param1 = param1;
1254 simcall->new_api.param2 = param2;
1256 SIMIX_simcall_push(simcall->issuer);
1257 return simcall->new_api.result;
1260 /* ************************************************************************** */
1262 /** @brief returns a printable string representing a simcall */
1263 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1264 return simcall_names[kind];