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 of a host.
164 * \param host A SIMIX host
165 * \return the current power peak value (double)
167 double simcall_host_get_power_peak_at(smx_host_t host, int pstate_index)
169 return simcall_BODY_host_get_power_peak_at(host, pstate_index);
173 * \ingroup simix_host_management
174 * \brief Returns the number of power states for a host.
176 * \param host A SIMIX host
177 * \return the number of power states
179 int simcall_host_get_nb_pstates(smx_host_t host)
181 return simcall_BODY_host_get_nb_pstates(host);
185 * \ingroup simix_host_management
186 * \brief Sets a new power peak for a host.
188 * \param host A SIMIX host
189 * \param pstate_index The state index to which the CPU power will be set
192 void simcall_host_set_power_peak_at(smx_host_t host, int pstate_index)
194 simcall_BODY_host_set_power_peak_at(host, pstate_index);
198 * \ingroup simix_host_management
199 * \brief Returns the total energy consumed by the host
201 * \param host A SIMIX host
202 * \return the energy consumed by the host (double)
204 double simcall_host_get_consumed_energy(smx_host_t host)
206 return simcall_BODY_host_get_consumed_energy(host);
211 * \ingroup simix_host_management
212 * \brief Creates an action that executes some computation of an host.
214 * This function creates a SURF action and allocates the data necessary
215 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
217 * \param name Name of the execution action to create
218 * \param host SIMIX host where the action will be executed
219 * \param computation_amount amount Computation amount (in bytes)
220 * \param priority computation priority
221 * \return A new SIMIX execution action
223 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
224 double computation_amount,
227 /* checking for infinite values */
228 xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
229 xbt_assert(isfinite(priority), "priority is not finite!");
231 return simcall_BODY_host_execute(name, host, computation_amount, priority);
235 * \ingroup simix_host_management
236 * \brief Creates an action that may involve parallel computation on
237 * several hosts and communication between them.
239 * \param name Name of the execution action to create
240 * \param host_nb Number of hosts where the action will be executed
241 * \param host_list Array (of size host_nb) of hosts where the action will be executed
242 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
243 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
244 * amount between each pair of hosts
245 * \param amount the SURF action amount
246 * \param rate the SURF action rate
247 * \return A new SIMIX execution action
249 smx_action_t simcall_host_parallel_execute(const char *name,
251 smx_host_t *host_list,
252 double *computation_amount,
253 double *communication_amount,
258 /* checking for infinite values */
259 for (i = 0 ; i < host_nb ; ++i) {
260 xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i);
261 for (j = 0 ; j < host_nb ; ++j) {
262 xbt_assert(isfinite(communication_amount[i + host_nb * j]),
263 "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j);
267 xbt_assert(isfinite(amount), "amount is not finite!");
268 xbt_assert(isfinite(rate), "rate is not finite!");
270 return simcall_BODY_host_parallel_execute(name, host_nb, host_list,
272 communication_amount,
278 * \ingroup simix_host_management
279 * \brief Destroys an execution action.
281 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
282 * \param execution The execution action to destroy
284 void simcall_host_execution_destroy(smx_action_t execution)
286 simcall_BODY_host_execution_destroy(execution);
290 * \ingroup simix_host_management
291 * \brief Cancels an execution action.
293 * This functions stops the execution. It calls a surf function.
294 * \param execution The execution action to cancel
296 void simcall_host_execution_cancel(smx_action_t execution)
298 simcall_BODY_host_execution_cancel(execution);
302 * \ingroup simix_host_management
303 * \brief Returns how much of an execution action remains to be done.
305 * \param execution The execution action
306 * \return The remaining amount
308 double simcall_host_execution_get_remains(smx_action_t execution)
310 return simcall_BODY_host_execution_get_remains(execution);
314 * \ingroup simix_host_management
315 * \brief Returns the state of an execution action.
317 * \param execution The execution action
320 e_smx_state_t simcall_host_execution_get_state(smx_action_t execution)
322 return simcall_BODY_host_execution_get_state(execution);
326 * \ingroup simix_host_management
327 * \brief Changes the priority of an execution action.
329 * This functions changes the priority only. It calls a surf function.
330 * \param execution The execution action
331 * \param priority The new priority
333 void simcall_host_execution_set_priority(smx_action_t execution, double priority)
335 /* checking for infinite values */
336 xbt_assert(isfinite(priority), "priority is not finite!");
338 simcall_BODY_host_execution_set_priority(execution, priority);
342 * \ingroup simix_host_management
343 * \brief Waits for the completion of an execution action and destroy it.
345 * \param execution The execution action
347 e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
349 return simcall_BODY_host_execution_wait(execution);
353 * \ingroup simix_process_management
354 * \brief Creates and runs a new SIMIX process.
356 * The structure and the corresponding thread are created and put in the list of ready processes.
358 * \param process the process created will be stored in this pointer
359 * \param name a name for the process. It is for user-level information and can be NULL.
360 * \param code the main function of the process
361 * \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.
362 * It can be retrieved with the function \ref simcall_process_get_data.
363 * \param hostname name of the host where the new agent is executed.
364 * \param kill_time time when the process is killed
365 * \param argc first argument passed to \a code
366 * \param argv second argument passed to \a code
367 * \param properties the properties of the process
368 * \param auto_restart either it is autorestarting or not.
370 void simcall_process_create(smx_process_t *process, const char *name,
371 xbt_main_func_t code,
373 const char *hostname,
375 int argc, char **argv,
376 xbt_dict_t properties,
379 simcall_BODY_process_create(process, name, code, data, hostname,
380 kill_time, argc, argv, properties,
385 * \ingroup simix_process_management
386 * \brief Kills a SIMIX process.
388 * This function simply kills a process.
390 * \param process poor victim
392 void simcall_process_kill(smx_process_t process)
394 simcall_BODY_process_kill(process);
398 * \ingroup simix_process_management
399 * \brief Kills all SIMIX processes.
401 void simcall_process_killall(int reset_pid)
403 simcall_BODY_process_killall(reset_pid);
407 * \ingroup simix_process_management
408 * \brief Cleans up a SIMIX process.
409 * \param process poor victim (must have already been killed)
411 void simcall_process_cleanup(smx_process_t process)
413 simcall_BODY_process_cleanup(process);
417 * \ingroup simix_process_management
418 * \brief Migrates an agent to another location.
420 * This function changes the value of the host on which \a process is running.
422 * \param process the process to migrate
423 * \param dest name of the new host
425 void simcall_process_change_host(smx_process_t process, smx_host_t dest)
427 simcall_BODY_process_change_host(process, dest);
431 * \ingroup simix_process_management
432 * \brief Suspends a process.
434 * This function suspends the process by suspending the action
435 * it was waiting for completion.
437 * \param process a SIMIX process
439 void simcall_process_suspend(smx_process_t process)
441 xbt_assert(process, "Invalid parameters");
443 simcall_BODY_process_suspend(process);
447 * \ingroup simix_process_management
448 * \brief Resumes a suspended process.
450 * This function resumes a suspended process by resuming the action
451 * it was waiting for completion.
453 * \param process a SIMIX process
455 void simcall_process_resume(smx_process_t process)
457 simcall_BODY_process_resume(process);
461 * \ingroup simix_process_management
462 * \brief Returns the amount of SIMIX processes in the system
464 * Maestro internal process is not counted, only user code processes are
466 int simcall_process_count(void)
468 return simcall_BODY_process_count();
472 * \ingroup simix_process_management
473 * \brief Return the PID of a #smx_process_t.
474 * \param process a SIMIX process
475 * \return the PID of this process
477 int simcall_process_get_PID(smx_process_t process)
479 if (process == SIMIX_process_self()) {
480 /* avoid a simcall if this function is called by the process itself */
481 return SIMIX_process_get_PID(process);
484 return simcall_BODY_process_get_PID(process);
488 * \ingroup simix_process_management
489 * \brief Return the parent PID of a #smx_process_t.
490 * \param process a SIMIX process
491 * \return the PID of this process parenrt
493 int simcall_process_get_PPID(smx_process_t process)
495 if (process == SIMIX_process_self()) {
496 /* avoid a simcall if this function is called by the process itself */
497 return SIMIX_process_get_PPID(process);
500 return simcall_BODY_process_get_PPID(process);
504 * \ingroup simix_process_management
505 * \brief Return the user data of a #smx_process_t.
506 * \param process a SIMIX process
507 * \return the user data of this process
509 void* simcall_process_get_data(smx_process_t process)
511 if (process == SIMIX_process_self()) {
512 /* avoid a simcall if this function is called by the process itself */
513 return SIMIX_process_get_data(process);
516 return simcall_BODY_process_get_data(process);
520 * \ingroup simix_process_management
521 * \brief Set the user data of a #smx_process_t.
523 * This functions sets the user data associated to \a process.
524 * \param process SIMIX process
525 * \param data User data
527 void simcall_process_set_data(smx_process_t process, void *data)
529 if (process == SIMIX_process_self()) {
530 /* avoid a simcall if this function is called by the process itself */
531 SIMIX_process_self_set_data(process, data);
534 simcall_BODY_process_set_data(process, data);
539 * \ingroup simix_process_management
540 * \brief Set the kill time of a process.
541 * \param process a process
542 * \param kill_time a double
544 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
547 if (kill_time > SIMIX_get_clock()) {
548 if (simix_global->kill_process_function) {
549 XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
550 sg_host_name(process->smx_host));
551 SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
557 * \ingroup simix_process_management
558 * \brief Return the location on which an agent is running.
560 * This functions returns the smx_host_t corresponding to the location on which
561 * \a process is running.
562 * \param process SIMIX process
565 smx_host_t simcall_process_get_host(smx_process_t process)
567 return simcall_BODY_process_get_host(process);
571 * \ingroup simix_process_management
572 * \brief Return the name of an agent.
574 * This functions checks whether \a process is a valid pointer or not and return its name.
575 * \param process SIMIX process
576 * \return The process name
578 const char* simcall_process_get_name(smx_process_t process)
580 if (process == SIMIX_process_self()) {
581 /* avoid a simcall if this function is called by the process itself */
582 return process->name;
584 return simcall_BODY_process_get_name(process);
588 * \ingroup simix_process_management
589 * \brief Returns true if the process is suspended .
591 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
592 * \param process SIMIX process
593 * \return 1, if the process is suspended, else 0.
595 int simcall_process_is_suspended(smx_process_t process)
597 return simcall_BODY_process_is_suspended(process);
601 * \ingroup simix_process_management
602 * \brief Return the properties
604 * This functions returns the properties associated with this process
606 xbt_dict_t simcall_process_get_properties(smx_process_t process)
608 return simcall_BODY_process_get_properties(process);
611 * \ingroup simix_process_management
612 * \brief Add an on_exit function
613 * Add an on_exit function which will be executed when the process exits/is killed.
615 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
617 simcall_BODY_process_on_exit(process, fun, data);
620 * \ingroup simix_process_management
621 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
622 * Will restart the process when the host comes back up if auto_restart is set to 1.
625 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
627 simcall_BODY_process_auto_restart_set(process, auto_restart);
631 * \ingroup simix_process_management
632 * \brief Restarts the process, killing it and starting it again from scratch.
634 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
636 return simcall_BODY_process_restart(process);
639 * \ingroup simix_process_management
640 * \brief Creates a new sleep SIMIX action.
642 * This function creates a SURF action and allocates the data necessary
643 * to create the SIMIX action. It can raise a host_error exception if the
644 * host crashed. The default SIMIX name of the action is "sleep".
646 * \param duration Time duration of the sleep.
647 * \return A result telling whether the sleep was successful
649 e_smx_state_t simcall_process_sleep(double duration)
651 /* checking for infinite values */
652 xbt_assert(isfinite(duration), "duration is not finite!");
653 return simcall_BODY_process_sleep(duration);
657 * \ingroup simix_rdv_management
658 * \brief Creates a new rendez-vous point
659 * \param name The name of the rendez-vous point
660 * \return The created rendez-vous point
662 smx_rdv_t simcall_rdv_create(const char *name)
664 return simcall_BODY_rdv_create(name);
669 * \ingroup simix_rdv_management
670 * \brief Destroy a rendez-vous point
671 * \param rdv The rendez-vous point to destroy
673 void simcall_rdv_destroy(smx_rdv_t rdv)
675 simcall_BODY_rdv_destroy(rdv);
678 * \ingroup simix_rdv_management
679 * \brief Returns a rendez-vous point knowing its name
681 smx_rdv_t simcall_rdv_get_by_name(const char *name)
683 xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
685 /* FIXME: this is a horrible loss of performance, so we hack it out by
686 * skipping the simcall (for now). It works in parallel, it won't work on
687 * distributed but probably we will change MSG for that. */
690 smx_simcall_t simcall = simcall_mine();
691 simcall->call = SIMCALL_RDV_GEY_BY_NAME;
692 simcall->rdv_get_by_name.name = name;
693 SIMIX_simcall_push(simcall->issuer);
694 return simcall->rdv_get_by_name.result;*/
696 return SIMIX_rdv_get_by_name(name);
700 * \ingroup simix_rdv_management
701 * \brief Counts the number of communication actions of a given host pending
702 * on a rendez-vous point.
703 * \param rdv The rendez-vous point
704 * \param host The host to be counted
705 * \return The number of comm actions pending in the rdv
707 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
709 return simcall_BODY_rdv_comm_count_by_host(rdv, host);
713 * \ingroup simix_rdv_management
714 * \brief returns the communication at the head of the rendez-vous
715 * \param rdv The rendez-vous point
716 * \return The communication or NULL if empty
718 smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
720 return simcall_BODY_rdv_get_head(rdv);
723 void simcall_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
725 simcall_BODY_rdv_set_receiver(rdv, process);
728 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
730 return simcall_BODY_rdv_get_receiver(rdv);
734 * \ingroup simix_comm_management
736 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
737 void *src_buff, size_t src_buff_size,
738 int (*match_fun)(void *, void *, smx_action_t), void *data,
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!");
744 xbt_assert(isfinite(timeout), "timeout is not finite!");
746 xbt_assert(rdv, "No rendez-vous point defined for send");
748 if (MC_is_active()) {
749 /* the model-checker wants two separate simcalls */
750 smx_action_t comm = simcall_comm_isend(rdv, task_size, rate,
751 src_buff, src_buff_size, match_fun, NULL, data, 0);
752 simcall_comm_wait(comm, timeout);
755 simcall_BODY_comm_send(rdv, task_size, rate, src_buff, src_buff_size,
756 match_fun, data, timeout);
761 * \ingroup simix_comm_management
763 smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
764 void *src_buff, size_t src_buff_size,
765 int (*match_fun)(void *, void *, smx_action_t),
766 void (*clean_fun)(void *),
770 /* checking for infinite values */
771 xbt_assert(isfinite(task_size), "task_size is not finite!");
772 xbt_assert(isfinite(rate), "rate is not finite!");
774 xbt_assert(rdv, "No rendez-vous point defined for isend");
776 return simcall_BODY_comm_isend(rdv, task_size, rate, src_buff,
777 src_buff_size, match_fun,
778 clean_fun, data, detached);
781 * \ingroup simix_comm_management
783 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
784 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
786 xbt_assert(isfinite(timeout), "timeout is not finite!");
787 xbt_assert(rdv, "No rendez-vous point defined for recv");
789 if (MC_is_active()) {
790 /* the model-checker wants two separate simcalls */
791 smx_action_t comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
793 simcall_comm_wait(comm, timeout);
796 simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size,
797 match_fun, data, timeout);
801 * \ingroup simix_comm_management
803 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
804 int (*match_fun)(void *, void *, smx_action_t), void *data)
806 xbt_assert(rdv, "No rendez-vous point defined for irecv");
808 return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size,
814 * \ingroup simix_comm_management
816 void simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
817 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout, double rate)
819 xbt_assert(isfinite(timeout), "timeout is not finite!");
820 xbt_assert(rdv, "No rendez-vous point defined for recv");
822 if (MC_is_active()) {
823 /* the model-checker wants two separate simcalls */
824 smx_action_t comm = simcall_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
825 match_fun, data, rate);
826 simcall_comm_wait(comm, timeout);
829 simcall_BODY_comm_recv_bounded(rdv, dst_buff, dst_buff_size,
830 match_fun, data, timeout, rate);
834 * \ingroup simix_comm_management
836 smx_action_t simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
837 int (*match_fun)(void *, void *, smx_action_t), void *data, double rate)
839 xbt_assert(rdv, "No rendez-vous point defined for irecv");
841 return simcall_BODY_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
842 match_fun, data, rate);
847 * \ingroup simix_comm_management
849 smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
850 int (*match_fun)(void *, void *, smx_action_t), void *data)
852 xbt_assert(rdv, "No rendez-vous point defined for iprobe");
854 return simcall_BODY_comm_iprobe(rdv, src, tag, match_fun, data);
857 void simcall_comm_destroy(smx_action_t comm)
859 xbt_assert(comm, "Invalid parameter");
861 /* FIXME remove this simcall type: comms are auto-destroyed now */
864 smx_simcall_t simcall = simcall_mine();
866 simcall->call = SIMCALL_COMM_DESTROY;
867 simcall->comm_destroy.comm = comm;
869 SIMIX_simcall_push(simcall->issuer);
874 * \ingroup simix_comm_management
876 void simcall_comm_cancel(smx_action_t comm)
878 simcall_BODY_comm_cancel(comm);
882 * \ingroup simix_comm_management
884 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
886 return simcall_BODY_comm_waitany(comms);
890 * \ingroup simix_comm_management
892 int simcall_comm_testany(xbt_dynar_t comms)
894 if (xbt_dynar_is_empty(comms))
896 return simcall_BODY_comm_testany(comms);
900 * \ingroup simix_comm_management
902 void simcall_comm_wait(smx_action_t comm, double timeout)
904 xbt_assert(isfinite(timeout), "timeout is not finite!");
905 simcall_BODY_comm_wait(comm, timeout);
910 * \brief Set the category of an action.
912 * This functions changes the category only. It calls a surf function.
913 * \param execution The execution action
914 * \param category The tracing category
916 void simcall_set_category(smx_action_t action, const char *category)
918 if (category == NULL) {
921 simcall_BODY_set_category(action, category);
926 * \ingroup simix_comm_management
929 int simcall_comm_test(smx_action_t comm)
931 return simcall_BODY_comm_test(comm);
935 * \ingroup simix_comm_management
938 double simcall_comm_get_remains(smx_action_t comm)
940 return simcall_BODY_comm_get_remains(comm);
944 * \ingroup simix_comm_management
947 e_smx_state_t simcall_comm_get_state(smx_action_t comm)
949 return simcall_BODY_comm_get_state(comm);
953 * \ingroup simix_comm_management
956 void *simcall_comm_get_src_data(smx_action_t comm)
958 return simcall_BODY_comm_get_src_data(comm);
962 * \ingroup simix_comm_management
965 void *simcall_comm_get_dst_data(smx_action_t comm)
967 return simcall_BODY_comm_get_dst_data(comm);
971 * \ingroup simix_comm_management
974 smx_process_t simcall_comm_get_src_proc(smx_action_t comm)
976 return simcall_BODY_comm_get_src_proc(comm);
980 * \ingroup simix_comm_management
983 smx_process_t simcall_comm_get_dst_proc(smx_action_t comm)
985 return simcall_BODY_comm_get_dst_proc(comm);
988 #ifdef HAVE_LATENCY_BOUND_TRACKING
989 int simcall_comm_is_latency_bounded(smx_action_t comm)
991 return simcall_BODY_comm_is_latency_bounded(comm);
996 * \ingroup simix_synchro_management
999 smx_mutex_t simcall_mutex_init(void)
1002 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
1005 return simcall_BODY_mutex_init();
1009 * \ingroup simix_synchro_management
1012 void simcall_mutex_destroy(smx_mutex_t mutex)
1014 simcall_BODY_mutex_destroy(mutex);
1018 * \ingroup simix_synchro_management
1021 void simcall_mutex_lock(smx_mutex_t mutex)
1023 simcall_BODY_mutex_lock(mutex);
1027 * \ingroup simix_synchro_management
1030 int simcall_mutex_trylock(smx_mutex_t mutex)
1032 return simcall_BODY_mutex_trylock(mutex);
1036 * \ingroup simix_synchro_management
1039 void simcall_mutex_unlock(smx_mutex_t mutex)
1041 simcall_BODY_mutex_unlock(mutex);
1045 * \ingroup simix_synchro_management
1048 smx_cond_t simcall_cond_init(void)
1050 return simcall_BODY_cond_init();
1054 * \ingroup simix_synchro_management
1057 void simcall_cond_destroy(smx_cond_t cond)
1059 simcall_BODY_cond_destroy(cond);
1063 * \ingroup simix_synchro_management
1066 void simcall_cond_signal(smx_cond_t cond)
1068 simcall_BODY_cond_signal(cond);
1072 * \ingroup simix_synchro_management
1075 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1077 simcall_BODY_cond_wait(cond, mutex);
1081 * \ingroup simix_synchro_management
1084 void simcall_cond_wait_timeout(smx_cond_t cond,
1088 xbt_assert(isfinite(timeout), "timeout is not finite!");
1089 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
1093 * \ingroup simix_synchro_management
1096 void simcall_cond_broadcast(smx_cond_t cond)
1098 simcall_BODY_cond_broadcast(cond);
1102 * \ingroup simix_synchro_management
1105 smx_sem_t simcall_sem_init(int capacity)
1107 return simcall_BODY_sem_init(capacity);
1111 * \ingroup simix_synchro_management
1114 void simcall_sem_destroy(smx_sem_t sem)
1116 simcall_sem_destroy(sem);
1120 * \ingroup simix_synchro_management
1123 void simcall_sem_release(smx_sem_t sem)
1125 simcall_BODY_sem_release(sem);
1129 * \ingroup simix_synchro_management
1132 int simcall_sem_would_block(smx_sem_t sem)
1134 return simcall_BODY_sem_would_block(sem);
1138 * \ingroup simix_synchro_management
1141 void simcall_sem_acquire(smx_sem_t sem)
1143 simcall_BODY_sem_acquire(sem);
1147 * \ingroup simix_synchro_management
1150 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1152 xbt_assert(isfinite(timeout), "timeout is not finite!");
1153 simcall_BODY_sem_acquire_timeout(sem, timeout);
1157 * \ingroup simix_synchro_management
1160 int simcall_sem_get_capacity(smx_sem_t sem)
1162 return simcall_BODY_sem_get_capacity(sem);
1166 * \ingroup simix_file_management
1169 size_t simcall_file_read(size_t size, smx_file_t fd)
1171 return simcall_BODY_file_read(size, fd);
1175 * \ingroup simix_file_management
1178 size_t simcall_file_write(size_t size, smx_file_t fd)
1180 return simcall_BODY_file_write(size, fd);
1184 * \ingroup simix_file_management
1187 smx_file_t simcall_file_open(const char* mount, const char* path)
1189 return simcall_BODY_file_open(mount, path);
1193 * \ingroup simix_file_management
1196 int simcall_file_close(smx_file_t fd)
1198 return simcall_BODY_file_close(fd);
1202 * \ingroup simix_file_management
1205 int simcall_file_unlink(smx_file_t fd)
1207 return simcall_BODY_file_unlink(fd);
1211 * \ingroup simix_file_management
1214 xbt_dict_t simcall_file_ls(const char* mount, const char* path)
1216 return simcall_BODY_file_ls(mount, path);
1219 * \ingroup simix_file_management
1222 size_t simcall_file_get_size (smx_file_t fd){
1223 return simcall_BODY_file_get_size(fd);
1228 void *simcall_mc_snapshot(void)
1230 return simcall_BODY_mc_snapshot();
1233 int simcall_mc_compare_snapshots(void *s1, void *s2){
1234 return simcall_BODY_mc_compare_snapshots(s1, s2);
1237 int simcall_mc_random(void)
1239 return simcall_BODY_mc_random();
1243 #endif /* HAVE_MC */
1245 /* ****************************************************************************************** */
1246 /* TUTORIAL: New API */
1247 /* All functions for simcall */
1248 /* ****************************************************************************************** */
1249 int simcall_new_api_fct(const char* param1, double param2){
1250 smx_simcall_t simcall = SIMIX_simcall_mine();
1251 simcall->call = SIMCALL_NEW_API_INIT;
1252 simcall->new_api.param1 = param1;
1253 simcall->new_api.param2 = param2;
1255 SIMIX_simcall_push(simcall->issuer);
1256 return simcall->new_api.result;
1259 /* ************************************************************************** */
1261 /** @brief returns a printable string representing a simcall */
1262 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1263 return simcall_names[kind];