1 /* libsmx.c - public interface to simix */
3 /* These functions are the only ones that are visible from the higher levels */
4 /* (most of them simply add some documentation to the generated simcall body) */
6 /* This is somehow the "libc" of SimGrid */
8 /* Copyright (c) 2010-2015. The SimGrid Team.
9 * All rights reserved. */
11 /* This program is free software; you can redistribute it and/or modify it
12 * under the terms of the license (GNU LGPL) which comes with this package. */
14 #include <cmath> /* std::isfinite() */
18 #include <xbt/functional.hpp>
20 #include "src/mc/mc_replay.h"
21 #include "smx_private.h"
22 #include "src/mc/mc_forward.hpp"
25 #include "src/simix/smx_host_private.h"
27 #include "src/simix/SynchroComm.hpp"
29 #include <simgrid/simix.hpp>
31 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
33 #include "popping_bodies.cpp"
35 void simcall_call(smx_process_t process)
37 if (process != simix_global->maestro_process) {
38 XBT_DEBUG("Yield process '%s' on simcall %s (%d)", process->name.c_str(),
39 SIMIX_simcall_name(process->simcall.call), (int)process->simcall.call);
40 SIMIX_process_yield(process);
42 SIMIX_simcall_handle(&process->simcall, 0);
49 * \ingroup simix_host_management
50 * \brief Returns a dict of the properties assigned to a router or AS.
52 * \param name The name of the router or AS
53 * \return The properties
55 xbt_dict_t simcall_asr_get_properties(const char *name)
57 return simcall_BODY_asr_get_properties(name);
61 * \ingroup simix_process_management
62 * \brief Creates a synchro that executes some computation of an host.
64 * This function creates a SURF action and allocates the data necessary
65 * to create the SIMIX synchro. It can raise a host_error exception if the host crashed.
67 * \param name Name of the execution synchro to create
68 * \param flops_amount amount Computation amount (in flops)
69 * \param priority computation priority
71 * \param affinity_mask
72 * \return A new SIMIX execution synchronization
74 smx_synchro_t simcall_execution_start(const char *name,
76 double priority, double bound, unsigned long affinity_mask)
78 /* checking for infinite values */
79 xbt_assert(std::isfinite(flops_amount), "flops_amount is not finite!");
80 xbt_assert(std::isfinite(priority), "priority is not finite!");
82 return simcall_BODY_execution_start(name, flops_amount, priority, bound, affinity_mask);
86 * \ingroup simix_process_management
87 * \brief Creates a synchro that may involve parallel computation on
88 * several hosts and communication between them.
90 * \param name Name of the execution synchro to create
91 * \param host_nb Number of hosts where the synchro will be executed
92 * \param host_list Array (of size host_nb) of hosts where the synchro will be executed
93 * \param flops_amount Array (of size host_nb) of computation amount of hosts (in bytes)
94 * \param bytes_amount Array (of size host_nb * host_nb) representing the communication
95 * amount between each pair of hosts
96 * \param amount the SURF action amount
97 * \param rate the SURF action rate
98 * \return A new SIMIX execution synchronization
100 smx_synchro_t simcall_execution_parallel_start(const char *name,
102 sg_host_t *host_list,
103 double *flops_amount,
104 double *bytes_amount,
109 /* checking for infinite values */
110 for (i = 0 ; i < host_nb ; ++i) {
111 xbt_assert(std::isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i);
112 if (bytes_amount != nullptr) {
113 for (j = 0 ; j < host_nb ; ++j) {
114 xbt_assert(std::isfinite(bytes_amount[i + host_nb * j]),
115 "bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j);
120 xbt_assert(std::isfinite(amount), "amount is not finite!");
121 xbt_assert(std::isfinite(rate), "rate is not finite!");
123 return simcall_BODY_execution_parallel_start(name, host_nb, host_list,
131 * \ingroup simix_process_management
132 * \brief Cancels an execution synchro.
134 * This functions stops the execution. It calls a surf function.
135 * \param execution The execution synchro to cancel
137 void simcall_execution_cancel(smx_synchro_t execution)
139 simcall_BODY_execution_cancel(execution);
143 * \ingroup simix_process_management
144 * \brief Changes the priority of an execution synchro.
146 * This functions changes the priority only. It calls a surf function.
147 * \param execution The execution synchro
148 * \param priority The new priority
150 void simcall_execution_set_priority(smx_synchro_t execution, double priority)
152 /* checking for infinite values */
153 xbt_assert(std::isfinite(priority), "priority is not finite!");
155 simcall_BODY_execution_set_priority(execution, priority);
159 * \ingroup simix_process_management
160 * \brief Changes the capping (the maximum CPU utilization) of an execution synchro.
162 * This functions changes the capping only. It calls a surf function.
163 * \param execution The execution synchro
164 * \param bound The new bound
166 void simcall_execution_set_bound(smx_synchro_t execution, double bound)
168 simcall_BODY_execution_set_bound(execution, bound);
172 * \ingroup simix_process_management
173 * \brief Changes the CPU affinity of an execution synchro.
175 * This functions changes the CPU affinity of an execution synchro. See taskset(1) on Linux.
176 * \param execution The execution synchro
178 * \param mask Affinity mask
180 void simcall_execution_set_affinity(smx_synchro_t execution, sg_host_t host, unsigned long mask)
182 simcall_BODY_execution_set_affinity(execution, host, mask);
186 * \ingroup simix_host_management
187 * \brief Waits for the completion of an execution synchro and destroy it.
189 * \param execution The execution synchro
191 e_smx_state_t simcall_execution_wait(smx_synchro_t execution)
193 return (e_smx_state_t) simcall_BODY_execution_wait(execution);
198 * \ingroup simix_vm_management
199 * \brief Create a VM on the given physical host.
201 * \param name VM name
202 * \param host Physical host
204 * \return The host object of the VM
206 void* simcall_vm_create(const char *name, sg_host_t phys_host)
208 return simgrid::simix::kernel(std::bind(SIMIX_vm_create, name, phys_host));
212 * \ingroup simix_vm_management
213 * \brief Start the given VM to the given physical host
217 void simcall_vm_start(sg_host_t vm)
219 return simgrid::simix::kernel(std::bind(SIMIX_vm_start, vm));
223 * \ingroup simix_vm_management
224 * \brief Get the state of the given VM
227 * \return The state of the VM
229 int simcall_vm_get_state(sg_host_t vm)
231 return simgrid::simix::kernel(std::bind(SIMIX_vm_get_state, vm));
235 * \ingroup simix_vm_management
236 * \brief Get the name of the physical host on which the given VM runs.
239 * \return The name of the physical host
241 void *simcall_vm_get_pm(sg_host_t vm)
243 return simgrid::simix::kernel(std::bind(SIMIX_vm_get_pm, vm));
246 void simcall_vm_set_bound(sg_host_t vm, double bound)
248 simgrid::simix::kernel(std::bind(SIMIX_vm_set_bound, vm, bound));
251 void simcall_vm_set_affinity(sg_host_t vm, sg_host_t pm, unsigned long mask)
253 simgrid::simix::kernel(std::bind(SIMIX_vm_set_affinity, vm, pm, mask));
257 * \ingroup simix_vm_management
258 * \brief Migrate the given VM to the given physical host
261 * \param host Destination physical host
263 void simcall_vm_migrate(sg_host_t vm, sg_host_t host)
265 return simgrid::simix::kernel(std::bind(SIMIX_vm_migrate, vm, host));
269 * \ingroup simix_vm_management
270 * \brief Suspend the given VM
274 void simcall_vm_suspend(sg_host_t vm)
276 simcall_BODY_vm_suspend(vm);
280 * \ingroup simix_vm_management
281 * \brief Resume the given VM
285 void simcall_vm_resume(sg_host_t vm)
287 simcall_BODY_vm_resume(vm);
291 * \ingroup simix_vm_management
292 * \brief Save the given VM
296 void simcall_vm_save(sg_host_t vm)
298 simcall_BODY_vm_save(vm);
302 * \ingroup simix_vm_management
303 * \brief Restore the given VM
307 void simcall_vm_restore(sg_host_t vm)
309 simcall_BODY_vm_restore(vm);
313 * \ingroup simix_vm_management
314 * \brief Shutdown the given VM
318 void simcall_vm_shutdown(sg_host_t vm)
320 simcall_BODY_vm_shutdown(vm);
324 * \ingroup simix_vm_management
325 * \brief Destroy the given VM
329 void simcall_vm_destroy(sg_host_t vm)
331 simgrid::simix::kernel(std::bind(SIMIX_vm_destroy, vm));
335 * \ingroup simix_vm_management
336 * \brief Encompassing simcall to prevent the removal of the src or the dst node at the end of a VM migration
337 * The simcall actually invokes the following calls:
338 * simcall_vm_set_affinity(vm, src_pm, 0);
339 * simcall_vm_migrate(vm, dst_pm);
340 * simcall_vm_resume(vm);
342 * It is called at the end of the migration_rx_fun function from msg/msg_vm.c
344 * \param vm VM to migrate
345 * \param src_pm Source physical host
346 * \param dst_pmt Destination physical host
348 void simcall_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t dst_pm)
350 simgrid::simix::kernel(std::bind(
351 SIMIX_vm_migratefrom_resumeto, vm, src_pm, dst_pm));
355 * \ingroup simix_process_management
356 * \brief Kills a SIMIX process.
358 * This function simply kills a process.
360 * \param process poor victim
362 void simcall_process_kill(smx_process_t process)
364 simcall_BODY_process_kill(process);
368 * \ingroup simix_process_management
369 * \brief Kills all SIMIX processes.
371 void simcall_process_killall(int reset_pid)
373 simcall_BODY_process_killall(reset_pid);
377 * \ingroup simix_process_management
378 * \brief Cleans up a SIMIX process.
379 * \param process poor victim (must have already been killed)
381 void simcall_process_cleanup(smx_process_t process)
383 simcall_BODY_process_cleanup(process);
387 * \ingroup simix_process_management
388 * \brief Migrates an agent to another location.
390 * This function changes the value of the host on which \a process is running.
392 * \param process the process to migrate
393 * \param dest name of the new host
395 void simcall_process_set_host(smx_process_t process, sg_host_t dest)
397 simcall_BODY_process_set_host(process, dest);
400 void simcall_process_join(smx_process_t process, double timeout)
402 simcall_BODY_process_join(process, timeout);
406 * \ingroup simix_process_management
407 * \brief Suspends a process.
409 * This function suspends the process by suspending the synchro
410 * it was waiting for completion.
412 * \param process a SIMIX process
414 void simcall_process_suspend(smx_process_t process)
416 xbt_assert(process, "Invalid parameters");
418 simcall_BODY_process_suspend(process);
422 * \ingroup simix_process_management
423 * \brief Resumes a suspended process.
425 * This function resumes a suspended process by resuming the synchro
426 * it was waiting for completion.
428 * \param process a SIMIX process
430 void simcall_process_resume(smx_process_t process)
432 simcall_BODY_process_resume(process);
436 * \ingroup simix_process_management
437 * \brief Returns the amount of SIMIX processes in the system
439 * Maestro internal process is not counted, only user code processes are
441 int simcall_process_count(void)
443 return simgrid::simix::kernel(SIMIX_process_count);
447 * \ingroup simix_process_management
448 * \brief Return the PID of a #smx_process_t.
449 * \param process a SIMIX process
450 * \return the PID of this process
452 int simcall_process_get_PID(smx_process_t process)
454 return SIMIX_process_get_PID(process);
458 * \ingroup simix_process_management
459 * \brief Return the parent PID of a #smx_process_t.
460 * \param process a SIMIX process
461 * \return the PID of this process parenrt
463 int simcall_process_get_PPID(smx_process_t process)
465 return SIMIX_process_get_PPID(process);
469 * \ingroup simix_process_management
470 * \brief Return the user data of a #smx_process_t.
471 * \param process a SIMIX process
472 * \return the user data of this process
474 void* simcall_process_get_data(smx_process_t process)
476 return SIMIX_process_get_data(process);
480 * \ingroup simix_process_management
481 * \brief Set the user data of a #smx_process_t.
483 * This functions sets the user data associated to \a process.
484 * \param process SIMIX process
485 * \param data User data
487 void simcall_process_set_data(smx_process_t process, void *data)
489 simgrid::simix::kernel(std::bind(SIMIX_process_set_data, process, data));
493 * \ingroup simix_process_management
494 * \brief Set the kill time of a process.
496 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
499 if (kill_time <= SIMIX_get_clock() || simix_global->kill_process_function == nullptr)
501 XBT_DEBUG("Set kill time %f for process %s(%s)",
502 kill_time, process->name.c_str(), sg_host_get_name(process->host));
503 process->kill_timer = SIMIX_timer_set(kill_time, [=] {
504 simix_global->kill_process_function(process);
505 process->kill_timer=nullptr;
509 * \ingroup simix_process_management
510 * \brief Get the kill time of a process (or 0 if unset).
512 double simcall_process_get_kill_time(smx_process_t process) {
513 return SIMIX_timer_get_date(process->kill_timer);
517 * \ingroup simix_process_management
518 * \brief Return the location on which an agent is running.
520 * This functions returns the sg_host_t corresponding to the location on which
521 * \a process is running.
522 * \param process SIMIX process
525 sg_host_t simcall_process_get_host(smx_process_t process)
527 return SIMIX_process_get_host(process);
531 * \ingroup simix_process_management
532 * \brief Return the name of an agent.
534 * This functions checks whether \a process is a valid pointer or not and return its name.
535 * \param process SIMIX process
536 * \return The process name
538 const char* simcall_process_get_name(smx_process_t process)
540 return SIMIX_process_get_name(process);
544 * \ingroup simix_process_management
545 * \brief Returns true if the process is suspended .
547 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
548 * \param process SIMIX process
549 * \return 1, if the process is suspended, else 0.
551 int simcall_process_is_suspended(smx_process_t process)
553 return simcall_BODY_process_is_suspended(process);
557 * \ingroup simix_process_management
558 * \brief Return the properties
560 * This functions returns the properties associated with this process
562 xbt_dict_t simcall_process_get_properties(smx_process_t process)
564 return SIMIX_process_get_properties(process);
567 * \ingroup simix_process_management
568 * \brief Add an on_exit function
569 * Add an on_exit function which will be executed when the process exits/is killed.
571 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_pvoid_t fun, void *data)
573 simcall_BODY_process_on_exit(process, fun, data);
576 * \ingroup simix_process_management
577 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
578 * Will restart the process when the host comes back up if auto_restart is set to 1.
581 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
583 simcall_BODY_process_auto_restart_set(process, auto_restart);
587 * \ingroup simix_process_management
588 * \brief Restarts the process, killing it and starting it again from scratch.
590 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
592 return (smx_process_t) simcall_BODY_process_restart(process);
595 * \ingroup simix_process_management
596 * \brief Creates a new sleep SIMIX synchro.
598 * This function creates a SURF action and allocates the data necessary
599 * to create the SIMIX synchro. It can raise a host_error exception if the
600 * host crashed. The default SIMIX name of the synchro is "sleep".
602 * \param duration Time duration of the sleep.
603 * \return A result telling whether the sleep was successful
605 e_smx_state_t simcall_process_sleep(double duration)
607 /* checking for infinite values */
608 xbt_assert(std::isfinite(duration), "duration is not finite!");
609 return (e_smx_state_t) simcall_BODY_process_sleep(duration);
613 * \ingroup simix_mbox_management
614 * \brief Creates a new rendez-vous point
615 * \param name The name of the rendez-vous point
616 * \return The created rendez-vous point
618 smx_mailbox_t simcall_mbox_create(const char *name)
620 return simcall_BODY_mbox_create(name);
624 * \ingroup simix_mbox_management
625 * \brief Returns a rendez-vous point knowing its name
627 smx_mailbox_t simcall_mbox_get_by_name(const char *name)
629 /* FIXME: this is a horrible loss of performance, so we hack it out by
630 * skipping the simcall (for now). It works in parallel, it won't work on
631 * distributed but probably we will change MSG for that. */
633 return SIMIX_mbox_get_by_name(name);
637 * \ingroup simix_mbox_management
638 * \brief returns the communication at the head of the rendez-vous
639 * \param mbox The rendez-vous point
640 * \return The communication or nullptr if empty
642 smx_synchro_t simcall_mbox_front(smx_mailbox_t mbox)
645 return mbox->comm_queue->empty()? nullptr:mbox->comm_queue->front();
648 void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process)
650 simcall_BODY_mbox_set_receiver(mbox, process);
654 * \ingroup simix_comm_management
656 void simcall_comm_send(smx_process_t sender, smx_mailbox_t mbox, double task_size, double rate,
657 void *src_buff, size_t src_buff_size,
658 int (*match_fun)(void *, void *, smx_synchro_t),
659 void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data,
662 /* checking for infinite values */
663 xbt_assert(std::isfinite(task_size), "task_size is not finite!");
664 xbt_assert(std::isfinite(rate), "rate is not finite!");
665 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
667 xbt_assert(mbox, "No rendez-vous point defined for send");
669 if (MC_is_active() || MC_record_replay_is_active()) {
670 /* the model-checker wants two separate simcalls */
671 smx_synchro_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
672 comm = simcall_comm_isend(sender, mbox, task_size, rate,
673 src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0);
674 simcall_comm_wait(comm, timeout);
678 simcall_BODY_comm_send(sender, mbox, task_size, rate, src_buff, src_buff_size,
679 match_fun, copy_data_fun, data, timeout);
684 * \ingroup simix_comm_management
686 smx_synchro_t simcall_comm_isend(smx_process_t sender, smx_mailbox_t mbox, double task_size, double rate,
687 void *src_buff, size_t src_buff_size,
688 int (*match_fun)(void *, void *, smx_synchro_t),
689 void (*clean_fun)(void *),
690 void (*copy_data_fun)(smx_synchro_t, void*, size_t),
694 /* checking for infinite values */
695 xbt_assert(std::isfinite(task_size), "task_size is not finite!");
696 xbt_assert(std::isfinite(rate), "rate is not finite!");
698 xbt_assert(mbox, "No rendez-vous point defined for isend");
700 return simcall_BODY_comm_isend(sender, mbox, task_size, rate, src_buff,
701 src_buff_size, match_fun,
702 clean_fun, copy_data_fun, data, detached);
706 * \ingroup simix_comm_management
708 void simcall_comm_recv(smx_process_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t * dst_buff_size,
709 int (*match_fun)(void *, void *, smx_synchro_t),
710 void (*copy_data_fun)(smx_synchro_t, void*, size_t),
711 void *data, double timeout, double rate)
713 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
714 xbt_assert(mbox, "No rendez-vous point defined for recv");
716 if (MC_is_active() || MC_record_replay_is_active()) {
717 /* the model-checker wants two separate simcalls */
718 smx_synchro_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
719 comm = simcall_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
720 match_fun, copy_data_fun, data, rate);
721 simcall_comm_wait(comm, timeout);
725 simcall_BODY_comm_recv(receiver, mbox, dst_buff, dst_buff_size,
726 match_fun, copy_data_fun, data, timeout, rate);
730 * \ingroup simix_comm_management
732 smx_synchro_t simcall_comm_irecv(smx_process_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size,
733 int (*match_fun)(void *, void *, smx_synchro_t),
734 void (*copy_data_fun)(smx_synchro_t, void*, size_t),
735 void *data, double rate)
737 xbt_assert(mbox, "No rendez-vous point defined for irecv");
739 return simcall_BODY_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
740 match_fun, copy_data_fun, data, rate);
744 * \ingroup simix_comm_management
746 smx_synchro_t simcall_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag,
747 int (*match_fun)(void *, void *, smx_synchro_t), void *data)
749 xbt_assert(mbox, "No rendez-vous point defined for iprobe");
751 return simcall_BODY_comm_iprobe(mbox, type, src, tag, match_fun, data);
755 * \ingroup simix_comm_management
757 void simcall_comm_cancel(smx_synchro_t synchro)
759 simgrid::simix::kernel([synchro]{
760 simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
766 * \ingroup simix_comm_management
768 unsigned int simcall_comm_waitany(xbt_dynar_t comms)
770 return simcall_BODY_comm_waitany(comms);
774 * \ingroup simix_comm_management
776 int simcall_comm_testany(xbt_dynar_t comms)
778 if (xbt_dynar_is_empty(comms))
780 return simcall_BODY_comm_testany(comms);
784 * \ingroup simix_comm_management
786 void simcall_comm_wait(smx_synchro_t comm, double timeout)
788 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
789 simcall_BODY_comm_wait(comm, timeout);
793 * \brief Set the category of an synchro.
795 * This functions changes the category only. It calls a surf function.
796 * \param execution The execution synchro
797 * \param category The tracing category
799 void simcall_set_category(smx_synchro_t synchro, const char *category)
801 if (category == nullptr) {
804 simcall_BODY_set_category(synchro, category);
808 * \ingroup simix_comm_management
811 int simcall_comm_test(smx_synchro_t comm)
813 return simcall_BODY_comm_test(comm);
817 * \ingroup simix_synchro_management
820 smx_mutex_t simcall_mutex_init(void)
823 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
826 return simcall_BODY_mutex_init();
830 * \ingroup simix_synchro_management
833 void simcall_mutex_lock(smx_mutex_t mutex)
835 simcall_BODY_mutex_lock(mutex);
839 * \ingroup simix_synchro_management
842 int simcall_mutex_trylock(smx_mutex_t mutex)
844 return simcall_BODY_mutex_trylock(mutex);
848 * \ingroup simix_synchro_management
851 void simcall_mutex_unlock(smx_mutex_t mutex)
853 simcall_BODY_mutex_unlock(mutex);
857 * \ingroup simix_synchro_management
860 smx_cond_t simcall_cond_init(void)
862 return simcall_BODY_cond_init();
866 * \ingroup simix_synchro_management
869 void simcall_cond_signal(smx_cond_t cond)
871 simcall_BODY_cond_signal(cond);
875 * \ingroup simix_synchro_management
878 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
880 simcall_BODY_cond_wait(cond, mutex);
884 * \ingroup simix_synchro_management
887 void simcall_cond_wait_timeout(smx_cond_t cond,
891 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
892 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
896 * \ingroup simix_synchro_management
899 void simcall_cond_broadcast(smx_cond_t cond)
901 simcall_BODY_cond_broadcast(cond);
905 * \ingroup simix_synchro_management
908 smx_sem_t simcall_sem_init(int capacity)
910 return simcall_BODY_sem_init(capacity);
914 * \ingroup simix_synchro_management
917 void simcall_sem_release(smx_sem_t sem)
919 simcall_BODY_sem_release(sem);
923 * \ingroup simix_synchro_management
926 int simcall_sem_would_block(smx_sem_t sem)
928 return simcall_BODY_sem_would_block(sem);
932 * \ingroup simix_synchro_management
935 void simcall_sem_acquire(smx_sem_t sem)
937 simcall_BODY_sem_acquire(sem);
941 * \ingroup simix_synchro_management
944 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
946 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
947 simcall_BODY_sem_acquire_timeout(sem, timeout);
951 * \ingroup simix_synchro_management
954 int simcall_sem_get_capacity(smx_sem_t sem)
956 return simcall_BODY_sem_get_capacity(sem);
960 * \ingroup simix_file_management
963 sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
965 return simcall_BODY_file_read(fd, size, host);
969 * \ingroup simix_file_management
972 sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
974 return simcall_BODY_file_write(fd, size, host);
978 * \ingroup simix_file_management
981 smx_file_t simcall_file_open(const char* fullpath, sg_host_t host)
983 return simcall_BODY_file_open(fullpath, host);
987 * \ingroup simix_file_management
990 int simcall_file_close(smx_file_t fd, sg_host_t host)
992 return simcall_BODY_file_close(fd, host);
996 * \ingroup simix_file_management
999 int simcall_file_unlink(smx_file_t fd, sg_host_t host)
1001 return simcall_BODY_file_unlink(fd, host);
1005 * \ingroup simix_file_management
1008 sg_size_t simcall_file_get_size(smx_file_t fd){
1009 return simcall_BODY_file_get_size(fd);
1013 * \ingroup simix_file_management
1016 sg_size_t simcall_file_tell(smx_file_t fd){
1017 return simcall_BODY_file_tell(fd);
1021 * \ingroup simix_file_management
1024 xbt_dynar_t simcall_file_get_info(smx_file_t fd)
1026 return simcall_BODY_file_get_info(fd);
1030 * \ingroup simix_file_management
1033 int simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin){
1034 return simcall_BODY_file_seek(fd, offset, origin);
1038 * \ingroup simix_file_management
1039 * \brief Move a file to another location on the *same mount point*.
1042 int simcall_file_move(smx_file_t fd, const char* fullpath)
1044 return simcall_BODY_file_move(fd, fullpath);
1048 * \ingroup simix_storage_management
1049 * \brief Returns the free space size on a given storage element.
1050 * \param storage a storage
1051 * \return Return the free space size on a given storage element (as sg_size_t)
1053 sg_size_t simcall_storage_get_free_size (smx_storage_t storage){
1054 return simcall_BODY_storage_get_free_size(storage);
1058 * \ingroup simix_storage_management
1059 * \brief Returns the used space size on a given storage element.
1060 * \param storage a storage
1061 * \return Return the used space size on a given storage element (as sg_size_t)
1063 sg_size_t simcall_storage_get_used_size (smx_storage_t storage){
1064 return simcall_BODY_storage_get_used_size(storage);
1068 * \ingroup simix_storage_management
1069 * \brief Returns a dict of the properties assigned to a storage element.
1071 * \param storage A storage element
1072 * \return The properties of this storage element
1074 xbt_dict_t simcall_storage_get_properties(smx_storage_t storage)
1076 return simcall_BODY_storage_get_properties(storage);
1080 * \ingroup simix_storage_management
1081 * \brief Returns a dict containing the content of a storage element.
1083 * \param storage A storage element
1084 * \return The content of this storage element as a dict (full path file => size)
1086 xbt_dict_t simcall_storage_get_content(smx_storage_t storage)
1088 return simcall_BODY_storage_get_content(storage);
1091 void simcall_run_kernel(std::function<void()> const& code)
1093 return simcall_BODY_run_kernel(&code);
1096 int simcall_mc_random(int min, int max) {
1097 return simcall_BODY_mc_random(min, max);
1100 /* ************************************************************************** */
1102 /** @brief returns a printable string representing a simcall */
1103 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1104 return simcall_names[kind];