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 Returns the power peak of a host.
163 * \param host A SIMIX host
164 * \return the current power peak value (double)
166 double simcall_host_get_current_power_peak(smx_host_t host)
168 return simcall_BODY_host_get_current_power_peak(host);
172 * \ingroup simix_host_management
173 * \brief Returns one power peak (in flops/s) of a host at a given pstate
175 * \param host A SIMIX host
176 * \param pstate_index pstate to test
177 * \return the current power peak value (double) for pstate_index
179 double simcall_host_get_power_peak_at(smx_host_t host, int pstate_index)
181 return simcall_BODY_host_get_power_peak_at(host, pstate_index);
185 * \ingroup simix_host_management
186 * \brief Returns the number of power states for a host.
188 * \param host A SIMIX host
189 * \return the number of power states
191 int simcall_host_get_nb_pstates(smx_host_t host)
193 return simcall_BODY_host_get_nb_pstates(host);
197 * \ingroup simix_host_management
198 * \brief Sets a new power peak for a host.
200 * \param host A SIMIX host
201 * \param pstate_index The pstate to which the CPU power will be set
204 void simcall_host_set_power_peak_at(smx_host_t host, int pstate_index)
206 simcall_BODY_host_set_power_peak_at(host, pstate_index);
210 * \ingroup simix_host_management
211 * \brief Returns the total energy consumed by the host (in Joules)
213 * \param host A SIMIX host
214 * \return the energy consumed by the host (double)
216 double simcall_host_get_consumed_energy(smx_host_t host)
218 return simcall_BODY_host_get_consumed_energy(host);
223 * \ingroup simix_host_management
224 * \brief Creates an action that executes some computation of an host.
226 * This function creates a SURF action and allocates the data necessary
227 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
229 * \param name Name of the execution action to create
230 * \param host SIMIX host where the action will be executed
231 * \param computation_amount amount Computation amount (in bytes)
232 * \param priority computation priority
233 * \return A new SIMIX execution action
235 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
236 double computation_amount,
239 /* checking for infinite values */
240 xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
241 xbt_assert(isfinite(priority), "priority is not finite!");
243 return simcall_BODY_host_execute(name, host, computation_amount, priority);
247 * \ingroup simix_host_management
248 * \brief Creates an action that may involve parallel computation on
249 * several hosts and communication between them.
251 * \param name Name of the execution action to create
252 * \param host_nb Number of hosts where the action will be executed
253 * \param host_list Array (of size host_nb) of hosts where the action will be executed
254 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
255 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
256 * amount between each pair of hosts
257 * \param amount the SURF action amount
258 * \param rate the SURF action rate
259 * \return A new SIMIX execution action
261 smx_action_t simcall_host_parallel_execute(const char *name,
263 smx_host_t *host_list,
264 double *computation_amount,
265 double *communication_amount,
270 /* checking for infinite values */
271 for (i = 0 ; i < host_nb ; ++i) {
272 xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i);
273 for (j = 0 ; j < host_nb ; ++j) {
274 xbt_assert(isfinite(communication_amount[i + host_nb * j]),
275 "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j);
279 xbt_assert(isfinite(amount), "amount is not finite!");
280 xbt_assert(isfinite(rate), "rate is not finite!");
282 return simcall_BODY_host_parallel_execute(name, host_nb, host_list,
284 communication_amount,
290 * \ingroup simix_host_management
291 * \brief Destroys an execution action.
293 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
294 * \param execution The execution action to destroy
296 void simcall_host_execution_destroy(smx_action_t execution)
298 simcall_BODY_host_execution_destroy(execution);
302 * \ingroup simix_host_management
303 * \brief Cancels an execution action.
305 * This functions stops the execution. It calls a surf function.
306 * \param execution The execution action to cancel
308 void simcall_host_execution_cancel(smx_action_t execution)
310 simcall_BODY_host_execution_cancel(execution);
314 * \ingroup simix_host_management
315 * \brief Returns how much of an execution action remains to be done.
317 * \param execution The execution action
318 * \return The remaining amount
320 double simcall_host_execution_get_remains(smx_action_t execution)
322 return simcall_BODY_host_execution_get_remains(execution);
326 * \ingroup simix_host_management
327 * \brief Returns the state of an execution action.
329 * \param execution The execution action
332 e_smx_state_t simcall_host_execution_get_state(smx_action_t execution)
334 return simcall_BODY_host_execution_get_state(execution);
338 * \ingroup simix_host_management
339 * \brief Changes the priority of an execution action.
341 * This functions changes the priority only. It calls a surf function.
342 * \param execution The execution action
343 * \param priority The new priority
345 void simcall_host_execution_set_priority(smx_action_t execution, double priority)
347 /* checking for infinite values */
348 xbt_assert(isfinite(priority), "priority is not finite!");
350 simcall_BODY_host_execution_set_priority(execution, priority);
354 * \ingroup simix_host_management
355 * \brief Waits for the completion of an execution action and destroy it.
357 * \param execution The execution action
359 e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
361 return simcall_BODY_host_execution_wait(execution);
365 * \ingroup simix_process_management
366 * \brief Creates and runs a new SIMIX process.
368 * The structure and the corresponding thread are created and put in the list of ready processes.
370 * \param process the process created will be stored in this pointer
371 * \param name a name for the process. It is for user-level information and can be NULL.
372 * \param code the main function of the process
373 * \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.
374 * It can be retrieved with the function \ref simcall_process_get_data.
375 * \param hostname name of the host where the new agent is executed.
376 * \param kill_time time when the process is killed
377 * \param argc first argument passed to \a code
378 * \param argv second argument passed to \a code
379 * \param properties the properties of the process
380 * \param auto_restart either it is autorestarting or not.
382 void simcall_process_create(smx_process_t *process, const char *name,
383 xbt_main_func_t code,
385 const char *hostname,
387 int argc, char **argv,
388 xbt_dict_t properties,
391 simcall_BODY_process_create(process, name, code, data, hostname,
392 kill_time, argc, argv, properties,
397 * \ingroup simix_process_management
398 * \brief Kills a SIMIX process.
400 * This function simply kills a process.
402 * \param process poor victim
404 void simcall_process_kill(smx_process_t process)
406 simcall_BODY_process_kill(process);
410 * \ingroup simix_process_management
411 * \brief Kills all SIMIX processes.
413 void simcall_process_killall(int reset_pid)
415 simcall_BODY_process_killall(reset_pid);
419 * \ingroup simix_process_management
420 * \brief Cleans up a SIMIX process.
421 * \param process poor victim (must have already been killed)
423 void simcall_process_cleanup(smx_process_t process)
425 simcall_BODY_process_cleanup(process);
429 * \ingroup simix_process_management
430 * \brief Migrates an agent to another location.
432 * This function changes the value of the host on which \a process is running.
434 * \param process the process to migrate
435 * \param dest name of the new host
437 void simcall_process_change_host(smx_process_t process, smx_host_t dest)
439 simcall_BODY_process_change_host(process, dest);
443 * \ingroup simix_process_management
444 * \brief Suspends a process.
446 * This function suspends the process by suspending the action
447 * it was waiting for completion.
449 * \param process a SIMIX process
451 void simcall_process_suspend(smx_process_t process)
453 xbt_assert(process, "Invalid parameters");
455 simcall_BODY_process_suspend(process);
459 * \ingroup simix_process_management
460 * \brief Resumes a suspended process.
462 * This function resumes a suspended process by resuming the action
463 * it was waiting for completion.
465 * \param process a SIMIX process
467 void simcall_process_resume(smx_process_t process)
469 simcall_BODY_process_resume(process);
473 * \ingroup simix_process_management
474 * \brief Returns the amount of SIMIX processes in the system
476 * Maestro internal process is not counted, only user code processes are
478 int simcall_process_count(void)
480 return simcall_BODY_process_count();
484 * \ingroup simix_process_management
485 * \brief Return the PID of a #smx_process_t.
486 * \param process a SIMIX process
487 * \return the PID of this process
489 int simcall_process_get_PID(smx_process_t process)
491 if (process == SIMIX_process_self()) {
492 /* avoid a simcall if this function is called by the process itself */
493 return SIMIX_process_get_PID(process);
496 return simcall_BODY_process_get_PID(process);
500 * \ingroup simix_process_management
501 * \brief Return the parent PID of a #smx_process_t.
502 * \param process a SIMIX process
503 * \return the PID of this process parenrt
505 int simcall_process_get_PPID(smx_process_t process)
507 if (process == SIMIX_process_self()) {
508 /* avoid a simcall if this function is called by the process itself */
509 return SIMIX_process_get_PPID(process);
512 return simcall_BODY_process_get_PPID(process);
516 * \ingroup simix_process_management
517 * \brief Return the user data of a #smx_process_t.
518 * \param process a SIMIX process
519 * \return the user data of this process
521 void* simcall_process_get_data(smx_process_t process)
523 if (process == SIMIX_process_self()) {
524 /* avoid a simcall if this function is called by the process itself */
525 return SIMIX_process_get_data(process);
528 return simcall_BODY_process_get_data(process);
532 * \ingroup simix_process_management
533 * \brief Set the user data of a #smx_process_t.
535 * This functions sets the user data associated to \a process.
536 * \param process SIMIX process
537 * \param data User data
539 void simcall_process_set_data(smx_process_t process, void *data)
541 if (process == SIMIX_process_self()) {
542 /* avoid a simcall if this function is called by the process itself */
543 SIMIX_process_self_set_data(process, data);
546 simcall_BODY_process_set_data(process, data);
551 * \ingroup simix_process_management
552 * \brief Set the kill time of a process.
553 * \param process a process
554 * \param kill_time a double
556 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
559 if (kill_time > SIMIX_get_clock()) {
560 if (simix_global->kill_process_function) {
561 XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
562 sg_host_name(process->smx_host));
563 SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
569 * \ingroup simix_process_management
570 * \brief Return the location on which an agent is running.
572 * This functions returns the smx_host_t corresponding to the location on which
573 * \a process is running.
574 * \param process SIMIX process
577 smx_host_t simcall_process_get_host(smx_process_t process)
579 return simcall_BODY_process_get_host(process);
583 * \ingroup simix_process_management
584 * \brief Return the name of an agent.
586 * This functions checks whether \a process is a valid pointer or not and return its name.
587 * \param process SIMIX process
588 * \return The process name
590 const char* simcall_process_get_name(smx_process_t process)
592 if (process == SIMIX_process_self()) {
593 /* avoid a simcall if this function is called by the process itself */
594 return process->name;
596 return simcall_BODY_process_get_name(process);
600 * \ingroup simix_process_management
601 * \brief Returns true if the process is suspended .
603 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
604 * \param process SIMIX process
605 * \return 1, if the process is suspended, else 0.
607 int simcall_process_is_suspended(smx_process_t process)
609 return simcall_BODY_process_is_suspended(process);
613 * \ingroup simix_process_management
614 * \brief Return the properties
616 * This functions returns the properties associated with this process
618 xbt_dict_t simcall_process_get_properties(smx_process_t process)
620 return simcall_BODY_process_get_properties(process);
623 * \ingroup simix_process_management
624 * \brief Add an on_exit function
625 * Add an on_exit function which will be executed when the process exits/is killed.
627 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
629 simcall_BODY_process_on_exit(process, fun, data);
632 * \ingroup simix_process_management
633 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
634 * Will restart the process when the host comes back up if auto_restart is set to 1.
637 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
639 simcall_BODY_process_auto_restart_set(process, auto_restart);
643 * \ingroup simix_process_management
644 * \brief Restarts the process, killing it and starting it again from scratch.
646 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
648 return simcall_BODY_process_restart(process);
651 * \ingroup simix_process_management
652 * \brief Creates a new sleep SIMIX action.
654 * This function creates a SURF action and allocates the data necessary
655 * to create the SIMIX action. It can raise a host_error exception if the
656 * host crashed. The default SIMIX name of the action is "sleep".
658 * \param duration Time duration of the sleep.
659 * \return A result telling whether the sleep was successful
661 e_smx_state_t simcall_process_sleep(double duration)
663 /* checking for infinite values */
664 xbt_assert(isfinite(duration), "duration is not finite!");
665 return simcall_BODY_process_sleep(duration);
669 * \ingroup simix_rdv_management
670 * \brief Creates a new rendez-vous point
671 * \param name The name of the rendez-vous point
672 * \return The created rendez-vous point
674 smx_rdv_t simcall_rdv_create(const char *name)
676 return simcall_BODY_rdv_create(name);
681 * \ingroup simix_rdv_management
682 * \brief Destroy a rendez-vous point
683 * \param rdv The rendez-vous point to destroy
685 void simcall_rdv_destroy(smx_rdv_t rdv)
687 simcall_BODY_rdv_destroy(rdv);
690 * \ingroup simix_rdv_management
691 * \brief Returns a rendez-vous point knowing its name
693 smx_rdv_t simcall_rdv_get_by_name(const char *name)
695 xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
697 /* FIXME: this is a horrible loss of performance, so we hack it out by
698 * skipping the simcall (for now). It works in parallel, it won't work on
699 * distributed but probably we will change MSG for that. */
702 smx_simcall_t simcall = simcall_mine();
703 simcall->call = SIMCALL_RDV_GEY_BY_NAME;
704 simcall->rdv_get_by_name.name = name;
705 SIMIX_simcall_push(simcall->issuer);
706 return simcall->rdv_get_by_name.result;*/
708 return SIMIX_rdv_get_by_name(name);
712 * \ingroup simix_rdv_management
713 * \brief Counts the number of communication actions of a given host pending
714 * on a rendez-vous point.
715 * \param rdv The rendez-vous point
716 * \param host The host to be counted
717 * \return The number of comm actions pending in the rdv
719 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
721 return simcall_BODY_rdv_comm_count_by_host(rdv, host);
725 * \ingroup simix_rdv_management
726 * \brief returns the communication at the head of the rendez-vous
727 * \param rdv The rendez-vous point
728 * \return The communication or NULL if empty
730 smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
732 return simcall_BODY_rdv_get_head(rdv);
735 void simcall_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
737 simcall_BODY_rdv_set_receiver(rdv, process);
740 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
742 return simcall_BODY_rdv_get_receiver(rdv);
746 * \ingroup simix_comm_management
748 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
749 void *src_buff, size_t src_buff_size,
750 int (*match_fun)(void *, void *, smx_action_t), void *data,
753 /* checking for infinite values */
754 xbt_assert(isfinite(task_size), "task_size is not finite!");
755 xbt_assert(isfinite(rate), "rate is not finite!");
756 xbt_assert(isfinite(timeout), "timeout is not finite!");
758 xbt_assert(rdv, "No rendez-vous point defined for send");
760 if (MC_is_active()) {
761 /* the model-checker wants two separate simcalls */
762 smx_action_t comm = simcall_comm_isend(rdv, task_size, rate,
763 src_buff, src_buff_size, match_fun, NULL, data, 0);
764 simcall_comm_wait(comm, timeout);
767 simcall_BODY_comm_send(rdv, task_size, rate, src_buff, src_buff_size,
768 match_fun, data, timeout);
773 * \ingroup simix_comm_management
775 smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
776 void *src_buff, size_t src_buff_size,
777 int (*match_fun)(void *, void *, smx_action_t),
778 void (*clean_fun)(void *),
782 /* checking for infinite values */
783 xbt_assert(isfinite(task_size), "task_size is not finite!");
784 xbt_assert(isfinite(rate), "rate is not finite!");
786 xbt_assert(rdv, "No rendez-vous point defined for isend");
788 return simcall_BODY_comm_isend(rdv, task_size, rate, src_buff,
789 src_buff_size, match_fun,
790 clean_fun, data, detached);
793 * \ingroup simix_comm_management
795 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
796 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
798 xbt_assert(isfinite(timeout), "timeout is not finite!");
799 xbt_assert(rdv, "No rendez-vous point defined for recv");
801 if (MC_is_active()) {
802 /* the model-checker wants two separate simcalls */
803 smx_action_t comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
805 simcall_comm_wait(comm, timeout);
808 simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size,
809 match_fun, data, timeout);
813 * \ingroup simix_comm_management
815 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
816 int (*match_fun)(void *, void *, smx_action_t), void *data)
818 xbt_assert(rdv, "No rendez-vous point defined for irecv");
820 return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size,
826 * \ingroup simix_comm_management
828 void simcall_comm_recv_bounded(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
829 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout, double rate)
831 xbt_assert(isfinite(timeout), "timeout is not finite!");
832 xbt_assert(rdv, "No rendez-vous point defined for recv");
834 if (MC_is_active()) {
835 /* the model-checker wants two separate simcalls */
836 smx_action_t comm = simcall_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
837 match_fun, data, rate);
838 simcall_comm_wait(comm, timeout);
841 simcall_BODY_comm_recv_bounded(rdv, dst_buff, dst_buff_size,
842 match_fun, data, timeout, rate);
846 * \ingroup simix_comm_management
848 smx_action_t simcall_comm_irecv_bounded(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
849 int (*match_fun)(void *, void *, smx_action_t), void *data, double rate)
851 xbt_assert(rdv, "No rendez-vous point defined for irecv");
853 return simcall_BODY_comm_irecv_bounded(rdv, dst_buff, dst_buff_size,
854 match_fun, data, rate);
859 * \ingroup simix_comm_management
861 smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
862 int (*match_fun)(void *, void *, smx_action_t), void *data)
864 xbt_assert(rdv, "No rendez-vous point defined for iprobe");
866 return simcall_BODY_comm_iprobe(rdv, src, tag, match_fun, data);
869 void simcall_comm_destroy(smx_action_t comm)
871 xbt_assert(comm, "Invalid parameter");
873 /* FIXME remove this simcall type: comms are auto-destroyed now */
876 smx_simcall_t simcall = simcall_mine();
878 simcall->call = SIMCALL_COMM_DESTROY;
879 simcall->comm_destroy.comm = comm;
881 SIMIX_simcall_push(simcall->issuer);
886 * \ingroup simix_comm_management
888 void simcall_comm_cancel(smx_action_t comm)
890 simcall_BODY_comm_cancel(comm);
894 * \ingroup simix_comm_management
896 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
898 return simcall_BODY_comm_waitany(comms);
902 * \ingroup simix_comm_management
904 int simcall_comm_testany(xbt_dynar_t comms)
906 if (xbt_dynar_is_empty(comms))
908 return simcall_BODY_comm_testany(comms);
912 * \ingroup simix_comm_management
914 void simcall_comm_wait(smx_action_t comm, double timeout)
916 xbt_assert(isfinite(timeout), "timeout is not finite!");
917 simcall_BODY_comm_wait(comm, timeout);
922 * \brief Set the category of an action.
924 * This functions changes the category only. It calls a surf function.
925 * \param execution The execution action
926 * \param category The tracing category
928 void simcall_set_category(smx_action_t action, const char *category)
930 if (category == NULL) {
933 simcall_BODY_set_category(action, category);
938 * \ingroup simix_comm_management
941 int simcall_comm_test(smx_action_t comm)
943 return simcall_BODY_comm_test(comm);
947 * \ingroup simix_comm_management
950 double simcall_comm_get_remains(smx_action_t comm)
952 return simcall_BODY_comm_get_remains(comm);
956 * \ingroup simix_comm_management
959 e_smx_state_t simcall_comm_get_state(smx_action_t comm)
961 return simcall_BODY_comm_get_state(comm);
965 * \ingroup simix_comm_management
968 void *simcall_comm_get_src_data(smx_action_t comm)
970 return simcall_BODY_comm_get_src_data(comm);
974 * \ingroup simix_comm_management
977 void *simcall_comm_get_dst_data(smx_action_t comm)
979 return simcall_BODY_comm_get_dst_data(comm);
983 * \ingroup simix_comm_management
986 smx_process_t simcall_comm_get_src_proc(smx_action_t comm)
988 return simcall_BODY_comm_get_src_proc(comm);
992 * \ingroup simix_comm_management
995 smx_process_t simcall_comm_get_dst_proc(smx_action_t comm)
997 return simcall_BODY_comm_get_dst_proc(comm);
1000 #ifdef HAVE_LATENCY_BOUND_TRACKING
1001 int simcall_comm_is_latency_bounded(smx_action_t comm)
1003 return simcall_BODY_comm_is_latency_bounded(comm);
1008 * \ingroup simix_synchro_management
1011 smx_mutex_t simcall_mutex_init(void)
1014 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
1017 return simcall_BODY_mutex_init();
1021 * \ingroup simix_synchro_management
1024 void simcall_mutex_destroy(smx_mutex_t mutex)
1026 simcall_BODY_mutex_destroy(mutex);
1030 * \ingroup simix_synchro_management
1033 void simcall_mutex_lock(smx_mutex_t mutex)
1035 simcall_BODY_mutex_lock(mutex);
1039 * \ingroup simix_synchro_management
1042 int simcall_mutex_trylock(smx_mutex_t mutex)
1044 return simcall_BODY_mutex_trylock(mutex);
1048 * \ingroup simix_synchro_management
1051 void simcall_mutex_unlock(smx_mutex_t mutex)
1053 simcall_BODY_mutex_unlock(mutex);
1057 * \ingroup simix_synchro_management
1060 smx_cond_t simcall_cond_init(void)
1062 return simcall_BODY_cond_init();
1066 * \ingroup simix_synchro_management
1069 void simcall_cond_destroy(smx_cond_t cond)
1071 simcall_BODY_cond_destroy(cond);
1075 * \ingroup simix_synchro_management
1078 void simcall_cond_signal(smx_cond_t cond)
1080 simcall_BODY_cond_signal(cond);
1084 * \ingroup simix_synchro_management
1087 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
1089 simcall_BODY_cond_wait(cond, mutex);
1093 * \ingroup simix_synchro_management
1096 void simcall_cond_wait_timeout(smx_cond_t cond,
1100 xbt_assert(isfinite(timeout), "timeout is not finite!");
1101 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
1105 * \ingroup simix_synchro_management
1108 void simcall_cond_broadcast(smx_cond_t cond)
1110 simcall_BODY_cond_broadcast(cond);
1114 * \ingroup simix_synchro_management
1117 smx_sem_t simcall_sem_init(int capacity)
1119 return simcall_BODY_sem_init(capacity);
1123 * \ingroup simix_synchro_management
1126 void simcall_sem_destroy(smx_sem_t sem)
1128 simcall_sem_destroy(sem);
1132 * \ingroup simix_synchro_management
1135 void simcall_sem_release(smx_sem_t sem)
1137 simcall_BODY_sem_release(sem);
1141 * \ingroup simix_synchro_management
1144 int simcall_sem_would_block(smx_sem_t sem)
1146 return simcall_BODY_sem_would_block(sem);
1150 * \ingroup simix_synchro_management
1153 void simcall_sem_acquire(smx_sem_t sem)
1155 simcall_BODY_sem_acquire(sem);
1159 * \ingroup simix_synchro_management
1162 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1164 xbt_assert(isfinite(timeout), "timeout is not finite!");
1165 simcall_BODY_sem_acquire_timeout(sem, timeout);
1169 * \ingroup simix_synchro_management
1172 int simcall_sem_get_capacity(smx_sem_t sem)
1174 return simcall_BODY_sem_get_capacity(sem);
1178 * \ingroup simix_file_management
1179 * \brief Returns the user data associated to a file.
1181 * \param fd A simix file
1182 * \return the user data of this file
1184 void* simcall_file_get_data(smx_file_t fd)
1186 return simcall_BODY_file_get_data(fd);
1190 * \ingroup simix_file_management
1191 * \brief Sets the user data associated to a file.
1193 * \param fd A SIMIX file
1194 * \param data The user data to set
1196 void simcall_file_set_data(smx_file_t fd, void *data)
1198 simcall_file_set_data(fd, data);
1202 * \ingroup simix_file_management
1205 size_t simcall_file_read(size_t size, smx_file_t fd)
1207 return simcall_BODY_file_read(size, fd);
1211 * \ingroup simix_file_management
1214 size_t simcall_file_write(size_t size, smx_file_t fd)
1216 return simcall_BODY_file_write(size, fd);
1220 * \ingroup simix_file_management
1223 smx_file_t simcall_file_open(const char* mount, const char* path)
1225 return simcall_BODY_file_open(mount, path);
1229 * \ingroup simix_file_management
1232 int simcall_file_close(smx_file_t fd)
1234 return simcall_BODY_file_close(fd);
1238 * \ingroup simix_file_management
1241 int simcall_file_unlink(smx_file_t fd)
1243 return simcall_BODY_file_unlink(fd);
1247 * \ingroup simix_file_management
1250 xbt_dict_t simcall_file_ls(const char* mount, const char* path)
1252 return simcall_BODY_file_ls(mount, path);
1255 * \ingroup simix_file_management
1258 size_t simcall_file_get_size (smx_file_t fd){
1259 return simcall_BODY_file_get_size(fd);
1263 * \ingroup simix_file_management
1266 xbt_dynar_t simcall_file_get_info(smx_file_t fd)
1268 return simcall_BODY_file_get_info(fd);
1272 * \ingroup simix_storage_management
1273 * \brief Returns the free space size on a given storage element.
1274 * \param storage name
1275 * \return Return the free space size on a given storage element (as size_t)
1277 size_t simcall_storage_get_free_size (const char* name){
1278 return simcall_BODY_storage_get_free_size(name);
1282 * \ingroup simix_storage_management
1283 * \brief Returns the used space size on a given storage element.
1284 * \param storage name
1285 * \return Return the used space size on a given storage element (as size_t)
1287 size_t simcall_storage_get_used_size (const char* name){
1288 return simcall_BODY_storage_get_used_size(name);
1292 * \ingroup simix_storage_management
1293 * \brief Returns the list of storages mounted on an host.
1294 * \param host A SIMIX host
1295 * \return a dynar containing all storages mounted on the host
1297 xbt_dynar_t simcall_host_get_storage_list(smx_host_t host)
1299 return simcall_BODY_host_get_storage_list(host);
1303 * \ingroup simix_storage_management
1304 * \brief Returns a dict of the properties assigned to a storage element.
1306 * \param storage A storage element
1307 * \return The properties of this storage element
1309 xbt_dict_t simcall_storage_get_properties(smx_storage_t storage)
1311 return simcall_BODY_storage_get_properties(storage);
1317 void *simcall_mc_snapshot(void)
1319 return simcall_BODY_mc_snapshot();
1322 int simcall_mc_compare_snapshots(void *s1, void *s2){
1323 return simcall_BODY_mc_compare_snapshots(s1, s2);
1326 int simcall_mc_random(int min, int max)
1328 return simcall_BODY_mc_random(min, max);
1332 #endif /* HAVE_MC */
1334 /* ****************************************************************************************** */
1335 /* TUTORIAL: New API */
1336 /* All functions for simcall */
1337 /* ****************************************************************************************** */
1338 int simcall_new_api_fct(const char* param1, double param2){
1339 smx_simcall_t simcall = SIMIX_simcall_mine();
1340 simcall->call = SIMCALL_NEW_API_INIT;
1341 simcall->new_api.param1 = param1;
1342 simcall->new_api.param2 = param2;
1344 SIMIX_simcall_push(simcall->issuer);
1345 return simcall->new_api.result;
1348 /* ************************************************************************** */
1350 /** @brief returns a printable string representing a simcall */
1351 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1352 return simcall_names[kind];