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_TYPE, SIMCALL_SEP_COMMA)
18 [SIMCALL_NONE] = "NONE"
22 * \ingroup simix_host_management
23 * \brief Returns a host given its name.
25 * \param name The name of the host to get
26 * \return The corresponding host
28 smx_host_t simcall_host_get_by_name(const char *name)
30 return simcall_BODY_host_get_by_name(name);
34 * \ingroup simix_host_management
35 * \brief Returns the name of a host.
37 * \param host A SIMIX host
38 * \return The name of this host
40 const char* simcall_host_get_name(smx_host_t host)
42 return simcall_BODY_host_get_name(host);
46 * \ingroup simix_host_management
47 * \brief Returns a dict of the properties assigned to a host.
50 * \return The properties of this host
52 xbt_dict_t simcall_host_get_properties(smx_host_t host)
54 return simcall_BODY_host_get_properties(host);
58 * \ingroup simix_host_management
59 * \brief Returns a dict of the properties assigned to a router or AS.
61 * \param name The name of the router or AS
62 * \return The properties
64 xbt_dict_t simcall_asr_get_properties(const char *name)
66 return simcall_BODY_asr_get_properties(name);
71 * \ingroup simix_host_management
72 * \brief Returns the speed of the processor.
74 * The speed returned does not take into account the current load on the machine.
75 * \param host A SIMIX host
76 * \return The speed of this host (in Mflop/s)
78 double simcall_host_get_speed(smx_host_t host)
80 return simcall_BODY_host_get_speed(host);
84 * \ingroup simix_host_management
85 * \brief Returns the available speed of the processor.
87 * \return Speed currently available (in Mflop/s)
89 double simcall_host_get_available_speed(smx_host_t host)
91 return simcall_BODY_host_get_available_speed(host);
95 * \ingroup simix_host_management
96 * \brief Returns the state of a host.
98 * Two states are possible: 1 if the host is active or 0 if it has crashed.
99 * \param host A SIMIX host
100 * \return 1 if the host is available, 0 otherwise
102 int simcall_host_get_state(smx_host_t host)
104 return simcall_BODY_host_get_state(host);
108 * \ingroup simix_host_management
109 * \brief Returns the user data associated to a host.
111 * \param host SIMIX host
112 * \return the user data of this host
114 void* simcall_host_get_data(smx_host_t host)
116 return simcall_BODY_host_get_data(host);
120 * \ingroup simix_host_management
121 * \brief Sets the user data associated to a host.
123 * The host must not have previous user data associated to it.
124 * \param host A SIMIX host
125 * \param data The user data to set
127 void simcall_host_set_data(smx_host_t host, void *data)
129 simcall_host_set_data(host, data);
133 * \ingroup simix_host_management
134 * \brief Creates an action that executes some computation of an host.
136 * This function creates a SURF action and allocates the data necessary
137 * to create the SIMIX action. It can raise a host_error exception if the host crashed.
139 * \param name Name of the execution action to create
140 * \param host SIMIX host where the action will be executed
141 * \param computation_amount amount Computation amount (in bytes)
142 * \param priority computation priority
143 * \return A new SIMIX execution action
146 smx_action_t simcall_host_execute(const char *name, smx_host_t host,
147 double computation_amount,
150 /* checking for infinite values */
151 xbt_assert(isfinite(computation_amount), "computation_amount is not finite!");
152 xbt_assert(isfinite(priority), "priority is not finite!");
154 return simcall_BODY_host_execute(name, host, computation_amount, priority);
158 * \ingroup simix_host_management
159 * \brief Creates an action that may involve parallel computation on
160 * several hosts and communication between them.
162 * \param name Name of the execution action to create
163 * \param host_nb Number of hosts where the action will be executed
164 * \param host_list Array (of size host_nb) of hosts where the action will be executed
165 * \param computation_amount Array (of size host_nb) of computation amount of hosts (in bytes)
166 * \param communication_amount Array (of size host_nb * host_nb) representing the communication
167 * amount between each pair of hosts
168 * \param amount the SURF action amount
169 * \param rate the SURF action rate
170 * \return A new SIMIX execution action
172 smx_action_t simcall_host_parallel_execute(const char *name,
174 smx_host_t *host_list,
175 double *computation_amount,
176 double *communication_amount,
181 /* checking for infinite values */
182 for (i = 0 ; i < host_nb ; ++i) {
183 xbt_assert(isfinite(computation_amount[i]), "computation_amount[%d] is not finite!", i);
184 for (j = 0 ; j < host_nb ; ++j) {
185 xbt_assert(isfinite(communication_amount[i + host_nb * j]),
186 "communication_amount[%d+%d*%d] is not finite!", i, host_nb, j);
190 xbt_assert(isfinite(amount), "amount is not finite!");
191 xbt_assert(isfinite(rate), "rate is not finite!");
193 return simcall_BODY_host_parallel_execute(name, host_nb, host_list,
195 communication_amount,
201 * \ingroup simix_host_management
202 * \brief Destroys an execution action.
204 * Destroys an action, freing its memory. This function cannot be called if there are a conditional waiting for it.
205 * \param execution The execution action to destroy
207 void simcall_host_execution_destroy(smx_action_t execution)
209 simcall_BODY_host_execution_destroy(execution);
213 * \ingroup simix_host_management
214 * \brief Cancels an execution action.
216 * This functions stops the execution. It calls a surf function.
217 * \param execution The execution action to cancel
219 void simcall_host_execution_cancel(smx_action_t execution)
221 simcall_BODY_host_execution_cancel(execution);
225 * \ingroup simix_host_management
226 * \brief Returns how much of an execution action remains to be done.
228 * \param execution The execution action
229 * \return The remaining amount
231 double simcall_host_execution_get_remains(smx_action_t execution)
233 return simcall_BODY_host_execution_get_remains(execution);
237 * \ingroup simix_host_management
238 * \brief Returns the state of an execution action.
240 * \param execution The execution action
243 e_smx_state_t simcall_host_execution_get_state(smx_action_t execution)
245 return simcall_BODY_host_execution_get_state(execution);
249 * \ingroup simix_host_management
250 * \brief Changes the priority of an execution action.
252 * This functions changes the priority only. It calls a surf function.
253 * \param execution The execution action
254 * \param priority The new priority
256 void simcall_host_execution_set_priority(smx_action_t execution, double priority)
258 /* checking for infinite values */
259 xbt_assert(isfinite(priority), "priority is not finite!");
261 simcall_BODY_host_execution_set_priority(execution, priority);
265 * \ingroup simix_host_management
266 * \brief Waits for the completion of an execution action and destroy it.
268 * \param execution The execution action
270 e_smx_state_t simcall_host_execution_wait(smx_action_t execution)
272 return simcall_BODY_host_execution_wait(execution);
276 * \ingroup simix_process_management
277 * \brief Creates and runs a new SIMIX process.
279 * The structure and the corresponding thread are created and put in the list of ready processes.
281 * \param process the process created will be stored in this pointer
282 * \param name a name for the process. It is for user-level information and can be NULL.
283 * \param code the main function of the process
284 * \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.
285 * It can be retrieved with the function \ref simcall_process_get_data.
286 * \param hostname name of the host where the new agent is executed.
287 * \param kill_time time when the process is killed
288 * \param argc first argument passed to \a code
289 * \param argv second argument passed to \a code
290 * \param properties the properties of the process
291 * \param auto_restart either it is autorestarting or not.
293 void simcall_process_create(smx_process_t *process, const char *name,
294 xbt_main_func_t code,
296 const char *hostname,
298 int argc, char **argv,
299 xbt_dict_t properties,
302 simcall_BODY_process_create(process, name, code, data, hostname,
303 kill_time, argc, argv, properties,
308 * \ingroup simix_process_management
309 * \brief Kills a SIMIX process.
311 * This function simply kills a process.
313 * \param process poor victim
315 void simcall_process_kill(smx_process_t process)
317 simcall_BODY_process_kill(process);
321 * \ingroup simix_process_management
322 * \brief Kills all SIMIX processes.
324 void simcall_process_killall(void)
326 simcall_BODY_process_killall();
330 * \ingroup simix_process_management
331 * \brief Cleans up a SIMIX process.
332 * \param process poor victim (must have already been killed)
334 void simcall_process_cleanup(smx_process_t process)
336 simcall_BODY_process_cleanup(process);
340 * \ingroup simix_process_management
341 * \brief Migrates an agent to another location.
343 * This function changes the value of the host on which \a process is running.
345 * \param process the process to migrate
346 * \param dest name of the new host
348 void simcall_process_change_host(smx_process_t process, smx_host_t dest)
350 simcall_BODY_process_change_host(process, dest);
354 * \ingroup simix_process_management
355 * \brief Suspends a process.
357 * This function suspends the process by suspending the action
358 * it was waiting for completion.
360 * \param process a SIMIX process
362 void simcall_process_suspend(smx_process_t process)
364 xbt_assert(process, "Invalid parameters");
366 simcall_BODY_process_suspend(process);
370 * \ingroup simix_process_management
371 * \brief Resumes a suspended process.
373 * This function resumes a suspended process by resuming the action
374 * it was waiting for completion.
376 * \param process a SIMIX process
378 void simcall_process_resume(smx_process_t process)
380 simcall_BODY_process_resume(process);
384 * \ingroup simix_process_management
385 * \brief Returns the amount of SIMIX processes in the system
387 * Maestro internal process is not counted, only user code processes are
389 int simcall_process_count(void)
391 return simcall_BODY_process_count();
395 * \ingroup simix_process_management
396 * \brief Return the user data of a #smx_process_t.
397 * \param process a SIMIX process
398 * \return the user data of this process
400 void* simcall_process_get_data(smx_process_t process)
402 if (process == SIMIX_process_self()) {
403 /* avoid a simcall if this function is called by the process itself */
404 return SIMIX_process_get_data(process);
407 return simcall_BODY_process_get_data(process);
411 * \ingroup simix_process_management
412 * \brief Set the user data of a #smx_process_t.
414 * This functions sets the user data associated to \a process.
415 * \param process SIMIX process
416 * \param data User data
418 void simcall_process_set_data(smx_process_t process, void *data)
420 if (process == SIMIX_process_self()) {
421 /* avoid a simcall if this function is called by the process itself */
422 SIMIX_process_self_set_data(process, data);
425 simcall_BODY_process_set_data(process, data);
430 * \ingroup simix_process_management
431 * \brief Set the kill time of a process.
432 * \param process a process
433 * \param kill_time a double
435 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
438 if (kill_time > SIMIX_get_clock()) {
439 if (simix_global->kill_process_function) {
440 XBT_DEBUG("Set kill time %f for process %s(%s)",kill_time, process->name,
441 process->smx_host->name);
442 SIMIX_timer_set(kill_time, simix_global->kill_process_function, process);
448 * \ingroup simix_process_management
449 * \brief Return the location on which an agent is running.
451 * This functions returns the smx_host_t corresponding to the location on which
452 * \a process is running.
453 * \param process SIMIX process
456 smx_host_t simcall_process_get_host(smx_process_t process)
458 return simcall_BODY_process_get_host(process);
462 * \ingroup simix_process_management
463 * \brief Return the name of an agent.
465 * This functions checks whether \a process is a valid pointer or not and return its name.
466 * \param process SIMIX process
467 * \return The process name
469 const char* simcall_process_get_name(smx_process_t process)
471 if (process == SIMIX_process_self()) {
472 /* avoid a simcall if this function is called by the process itself */
473 return process->name;
475 return simcall_BODY_process_get_name(process);
479 * \ingroup simix_process_management
480 * \brief Returns true if the process is suspended .
482 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
483 * \param process SIMIX process
484 * \return 1, if the process is suspended, else 0.
486 int simcall_process_is_suspended(smx_process_t process)
488 return simcall_BODY_process_is_suspended(process);
492 * \ingroup simix_process_management
493 * \brief Return the properties
495 * This functions returns the properties associated with this process
497 xbt_dict_t simcall_process_get_properties(smx_process_t process)
499 return simcall_BODY_process_get_properties(process);
502 * \ingroup simix_process_management
503 * \brief Add an on_exit function
504 * Add an on_exit function which will be executed when the process exits/is killed.
506 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data)
508 simcall_BODY_process_on_exit(process, fun, data);
511 * \ingroup simix_process_management
512 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
513 * Will restart the process when the host comes back up if auto_restart is set to 1.
516 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
518 simcall_BODY_process_auto_restart_set(process, auto_restart);
522 * \ingroup simix_process_management
523 * \brief Restarts the process, killing it and starting it again from scratch.
525 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
527 return simcall_BODY_process_restart(process);
530 * \ingroup simix_process_management
531 * \brief Creates a new sleep SIMIX action.
533 * This function creates a SURF action and allocates the data necessary
534 * to create the SIMIX action. It can raise a host_error exception if the
535 * host crashed. The default SIMIX name of the action is "sleep".
537 * \param duration Time duration of the sleep.
538 * \return A result telling whether the sleep was successful
540 e_smx_state_t simcall_process_sleep(double duration)
542 /* checking for infinite values */
543 xbt_assert(isfinite(duration), "duration is not finite!");
544 return simcall_BODY_process_sleep(duration);
548 * \ingroup simix_rdv_management
549 * \brief Creates a new rendez-vous point
550 * \param name The name of the rendez-vous point
551 * \return The created rendez-vous point
553 smx_rdv_t simcall_rdv_create(const char *name)
555 return simcall_BODY_rdv_create(name);
560 * \ingroup simix_rdv_management
561 * \brief Destroy a rendez-vous point
562 * \param rdv The rendez-vous point to destroy
564 void simcall_rdv_destroy(smx_rdv_t rdv)
566 simcall_BODY_rdv_destroy(rdv);
569 * \ingroup simix_rdv_management
570 * \brief Returns a rendez-vous point knowing its name
572 smx_rdv_t simcall_rdv_get_by_name(const char *name)
574 xbt_assert(name != NULL, "Invalid parameter for simcall_rdv_get_by_name (name is NULL)");
576 /* FIXME: this is a horrible lost of performance, so we hack it out by
577 * skipping the simcall (for now). It works in parallel, it won't work on
578 * distributed but probably we will change MSG for that. */
581 smx_simcall_t simcall = simcall_mine();
582 simcall->call = SIMCALL_RDV_GEY_BY_NAME;
583 simcall->rdv_get_by_name.name = name;
584 SIMIX_simcall_push(simcall->issuer);
585 return simcall->rdv_get_by_name.result;*/
587 return SIMIX_rdv_get_by_name(name);
591 * \ingroup simix_rdv_management
592 * \brief Counts the number of communication actions of a given host pending
593 * on a rendez-vous point.
594 * \param rdv The rendez-vous point
595 * \param host The host to be counted
596 * \return The number of comm actions pending in the rdv
598 int simcall_rdv_comm_count_by_host(smx_rdv_t rdv, smx_host_t host)
600 return simcall_BODY_rdv_comm_count_by_host(rdv, host);
604 * \ingroup simix_rdv_management
605 * \brief returns the communication at the head of the rendez-vous
606 * \param rdv The rendez-vous point
607 * \return The communication or NULL if empty
609 smx_action_t simcall_rdv_get_head(smx_rdv_t rdv)
611 return simcall_BODY_rdv_get_head(rdv);
614 void simcall_rdv_set_receiver(smx_rdv_t rdv, smx_process_t process)
616 simcall_BODY_rdv_set_receiver(rdv, process);
619 smx_process_t simcall_rdv_get_receiver(smx_rdv_t rdv)
621 return simcall_BODY_rdv_get_receiver(rdv);
625 * \ingroup simix_comm_management
627 void simcall_comm_send(smx_rdv_t rdv, double task_size, double rate,
628 void *src_buff, size_t src_buff_size,
629 int (*match_fun)(void *, void *, smx_action_t), void *data,
632 /* checking for infinite values */
633 xbt_assert(isfinite(task_size), "task_size is not finite!");
634 xbt_assert(isfinite(rate), "rate is not finite!");
635 xbt_assert(isfinite(timeout), "timeout is not finite!");
637 xbt_assert(rdv, "No rendez-vous point defined for send");
639 if (MC_is_active()) {
640 /* the model-checker wants two separate simcalls */
641 smx_action_t comm = simcall_comm_isend(rdv, task_size, rate,
642 src_buff, src_buff_size, match_fun, NULL, data, 0);
643 simcall_comm_wait(comm, timeout);
646 simcall_BODY_comm_send(rdv, task_size, rate, src_buff, src_buff_size,
647 match_fun, data, timeout);
652 * \ingroup simix_comm_management
654 smx_action_t simcall_comm_isend(smx_rdv_t rdv, double task_size, double rate,
655 void *src_buff, size_t src_buff_size,
656 int (*match_fun)(void *, void *, smx_action_t),
657 void (*clean_fun)(void *),
661 /* checking for infinite values */
662 xbt_assert(isfinite(task_size), "task_size is not finite!");
663 xbt_assert(isfinite(rate), "rate is not finite!");
665 xbt_assert(rdv, "No rendez-vous point defined for isend");
667 return simcall_BODY_comm_isend(rdv, task_size, rate, src_buff,
668 src_buff_size, match_fun,
669 clean_fun, data, detached);
672 * \ingroup simix_comm_management
674 void simcall_comm_recv(smx_rdv_t rdv, void *dst_buff, size_t * dst_buff_size,
675 int (*match_fun)(void *, void *, smx_action_t), void *data, double timeout)
677 xbt_assert(isfinite(timeout), "timeout is not finite!");
678 xbt_assert(rdv, "No rendez-vous point defined for recv");
680 if (MC_is_active()) {
681 /* the model-checker wants two separate simcalls */
682 smx_action_t comm = simcall_comm_irecv(rdv, dst_buff, dst_buff_size,
684 simcall_comm_wait(comm, timeout);
687 simcall_BODY_comm_recv(rdv, dst_buff, dst_buff_size,
688 match_fun, data, timeout);
692 * \ingroup simix_comm_management
694 smx_action_t simcall_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t *dst_buff_size,
695 int (*match_fun)(void *, void *, smx_action_t), void *data)
697 xbt_assert(rdv, "No rendez-vous point defined for irecv");
699 return simcall_BODY_comm_irecv(rdv, dst_buff, dst_buff_size,
705 * \ingroup simix_comm_management
707 smx_action_t simcall_comm_iprobe(smx_rdv_t rdv, int src, int tag,
708 int (*match_fun)(void *, void *, smx_action_t), void *data)
710 xbt_assert(rdv, "No rendez-vous point defined for iprobe");
712 return simcall_BODY_comm_iprobe(rdv, src, tag, match_fun, data);
715 void simcall_comm_destroy(smx_action_t comm)
717 xbt_assert(comm, "Invalid parameter");
719 /* FIXME remove this simcall type: comms are auto-destroyed now */
722 smx_simcall_t simcall = simcall_mine();
724 simcall->call = SIMCALL_COMM_DESTROY;
725 simcall->comm_destroy.comm = comm;
727 SIMIX_simcall_push(simcall->issuer);
732 * \ingroup simix_comm_management
734 void simcall_comm_cancel(smx_action_t comm)
736 simcall_BODY_comm_cancel(comm);
740 * \ingroup simix_comm_management
742 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
744 return simcall_BODY_comm_waitany(comms);
748 * \ingroup simix_comm_management
750 int simcall_comm_testany(xbt_dynar_t comms)
752 if (xbt_dynar_is_empty(comms))
754 return simcall_BODY_comm_testany(comms);
758 * \ingroup simix_comm_management
760 void simcall_comm_wait(smx_action_t comm, double timeout)
762 xbt_assert(isfinite(timeout), "timeout is not finite!");
763 simcall_comm_wait(comm, timeout);
768 * \brief Set the category of an action.
770 * This functions changes the category only. It calls a surf function.
771 * \param execution The execution action
772 * \param category The tracing category
774 void simcall_set_category(smx_action_t action, const char *category)
776 if (category == NULL) {
779 simcall_BODY_set_category(action, category);
784 * \ingroup simix_comm_management
787 int simcall_comm_test(smx_action_t comm)
789 return simcall_BODY_comm_test(comm);
793 * \ingroup simix_comm_management
796 double simcall_comm_get_remains(smx_action_t comm)
798 return simcall_BODY_comm_get_remains(comm);
802 * \ingroup simix_comm_management
805 e_smx_state_t simcall_comm_get_state(smx_action_t comm)
807 return simcall_BODY_comm_get_state(comm);
811 * \ingroup simix_comm_management
814 void *simcall_comm_get_src_data(smx_action_t comm)
816 return simcall_BODY_comm_get_src_data(comm);
820 * \ingroup simix_comm_management
823 void *simcall_comm_get_dst_data(smx_action_t comm)
825 return simcall_BODY_comm_get_dst_data(comm);
829 * \ingroup simix_comm_management
832 smx_process_t simcall_comm_get_src_proc(smx_action_t comm)
834 return simcall_BODY_comm_get_src_proc(comm);
838 * \ingroup simix_comm_management
841 smx_process_t simcall_comm_get_dst_proc(smx_action_t comm)
843 return simcall_BODY_comm_get_dst_proc(comm);
846 #ifdef HAVE_LATENCY_BOUND_TRACKING
847 int simcall_comm_is_latency_bounded(smx_action_t comm)
849 return simcall_BODY_comm_is_latency_bounded(comm);
854 * \ingroup simix_synchro_management
857 smx_mutex_t simcall_mutex_init(void)
860 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
863 return simcall_BODY_mutex_init();
867 * \ingroup simix_synchro_management
870 void simcall_mutex_destroy(smx_mutex_t mutex)
872 simcall_BODY_mutex_destroy(mutex);
876 * \ingroup simix_synchro_management
879 void simcall_mutex_lock(smx_mutex_t mutex)
881 simcall_BODY_mutex_lock(mutex);
885 * \ingroup simix_synchro_management
888 int simcall_mutex_trylock(smx_mutex_t mutex)
890 return simcall_BODY_mutex_trylock(mutex);
894 * \ingroup simix_synchro_management
897 void simcall_mutex_unlock(smx_mutex_t mutex)
899 simcall_BODY_mutex_unlock(mutex);
903 * \ingroup simix_synchro_management
906 smx_cond_t simcall_cond_init(void)
908 return simcall_BODY_cond_init();
912 * \ingroup simix_synchro_management
915 void simcall_cond_destroy(smx_cond_t cond)
917 simcall_BODY_cond_destroy(cond);
921 * \ingroup simix_synchro_management
924 void simcall_cond_signal(smx_cond_t cond)
926 simcall_BODY_cond_signal(cond);
930 * \ingroup simix_synchro_management
933 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
935 simcall_BODY_cond_wait(cond, mutex);
939 * \ingroup simix_synchro_management
942 void simcall_cond_wait_timeout(smx_cond_t cond,
946 xbt_assert(isfinite(timeout), "timeout is not finite!");
947 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
951 * \ingroup simix_synchro_management
954 void simcall_cond_broadcast(smx_cond_t cond)
956 simcall_BODY_cond_broadcast(cond);
960 * \ingroup simix_synchro_management
963 smx_sem_t simcall_sem_init(int capacity)
965 return simcall_BODY_sem_init(capacity);
969 * \ingroup simix_synchro_management
972 void simcall_sem_destroy(smx_sem_t sem)
974 simcall_sem_destroy(sem);
978 * \ingroup simix_synchro_management
981 void simcall_sem_release(smx_sem_t sem)
983 simcall_BODY_sem_release(sem);
987 * \ingroup simix_synchro_management
990 int simcall_sem_would_block(smx_sem_t sem)
992 return simcall_BODY_sem_would_block(sem);
996 * \ingroup simix_synchro_management
999 void simcall_sem_acquire(smx_sem_t sem)
1001 simcall_BODY_sem_acquire(sem);
1005 * \ingroup simix_synchro_management
1008 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
1010 xbt_assert(isfinite(timeout), "timeout is not finite!");
1011 simcall_BODY_sem_acquire_timeout(sem, timeout);
1015 * \ingroup simix_synchro_management
1018 int simcall_sem_get_capacity(smx_sem_t sem)
1020 return simcall_BODY_sem_get_capacity(sem);
1024 * \ingroup simix_file_management
1027 double simcall_file_read(void* ptr, size_t size, size_t nmemb, smx_file_t stream)
1029 return simcall_BODY_file_read(ptr, size, nmemb, stream);
1033 * \ingroup simix_file_management
1036 size_t simcall_file_write(const void* ptr, size_t size, size_t nmemb, smx_file_t stream)
1038 return simcall_BODY_file_write(ptr, size, nmemb, stream);
1042 * \ingroup simix_file_management
1045 smx_file_t simcall_file_open(const char* mount, const char* path, const char* mode)
1047 return simcall_BODY_file_open(mount, path, mode);
1051 * \ingroup simix_file_management
1054 int simcall_file_close(smx_file_t fp)
1056 return simcall_BODY_file_close(fp);
1060 * \ingroup simix_file_management
1063 int simcall_file_stat(smx_file_t fd, s_file_stat_t *buf)
1065 //*buf = simcall->file_stat.buf;
1066 return simcall_BODY_file_stat(fd, *buf);
1070 * \ingroup simix_file_management
1073 int simcall_file_unlink(smx_file_t fd)
1075 return simcall_BODY_file_unlink(fd);
1079 * \ingroup simix_file_management
1082 xbt_dict_t simcall_file_ls(const char* mount, const char* path)
1084 return simcall_BODY_file_ls(mount, path);
1089 void *simcall_mc_snapshot(void)
1091 return simcall_BODY_mc_snapshot();
1094 int simcall_mc_compare_snapshots(void *s1, void *s2){
1095 return simcall_BODY_mc_compare_snapshots(s1, s2);
1098 #endif /* HAVE_MC */
1100 /* ****************************************************************************************** */
1101 /* TUTORIAL: New API */
1102 /* All functions for simcall */
1103 /* ****************************************************************************************** */
1104 int simcall_new_api_fct(const char* param1, double param2){
1105 smx_simcall_t simcall = SIMIX_simcall_mine();
1106 simcall->call = SIMCALL_NEW_API_INIT;
1107 simcall->new_api.param1 = param1;
1108 simcall->new_api.param2 = param2;
1110 SIMIX_simcall_push(simcall->issuer);
1111 return simcall->new_api.result;
1114 /* ************************************************************************** */
1116 /** @brief returns a printable string representing a simcall */
1117 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1118 return simcall_names[kind];