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 <simgrid/s4u/VirtualMachine.hpp>
21 #include <simgrid/simix/blocking_simcall.hpp>
24 #include "smx_private.h"
25 #include "src/kernel/activity/SynchroComm.hpp"
26 #include "src/mc/mc_forward.hpp"
27 #include "src/mc/mc_replay.h"
28 #include "src/plugins/vm/VirtualMachineImpl.hpp"
29 #include "src/simix/smx_host_private.h"
32 #include <simgrid/simix.hpp>
34 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
36 #include "popping_bodies.cpp"
38 void simcall_call(smx_actor_t process)
40 if (process != simix_global->maestro_process) {
41 XBT_DEBUG("Yield process '%s' on simcall %s (%d)", process->name.c_str(),
42 SIMIX_simcall_name(process->simcall.call), (int)process->simcall.call);
43 SIMIX_process_yield(process);
45 SIMIX_simcall_handle(&process->simcall, 0);
52 * \ingroup simix_host_management
53 * \brief Returns a dict of the properties assigned to a router or AS.
55 * \param name The name of the router or AS
56 * \return The properties
58 xbt_dict_t simcall_asr_get_properties(const char *name)
60 return simcall_BODY_asr_get_properties(name);
64 * \ingroup simix_process_management
65 * \brief Creates a synchro that executes some computation of an host.
67 * This function creates a SURF action and allocates the data necessary
68 * to create the SIMIX synchro. It can raise a host_error exception if the host crashed.
70 * \param name Name of the execution synchro to create
71 * \param flops_amount amount Computation amount (in flops)
72 * \param priority computation priority
74 * \return A new SIMIX execution synchronization
76 smx_activity_t simcall_execution_start(const char *name,
78 double priority, double bound)
80 /* checking for infinite values */
81 xbt_assert(std::isfinite(flops_amount), "flops_amount is not finite!");
82 xbt_assert(std::isfinite(priority), "priority is not finite!");
84 return simcall_BODY_execution_start(name, flops_amount, priority, bound);
88 * \ingroup simix_process_management
89 * \brief Creates a synchro that may involve parallel computation on
90 * several hosts and communication between them.
92 * \param name Name of the execution synchro to create
93 * \param host_nb Number of hosts where the synchro will be executed
94 * \param host_list Array (of size host_nb) of hosts where the synchro will be executed
95 * \param flops_amount Array (of size host_nb) of computation amount of hosts (in bytes)
96 * \param bytes_amount Array (of size host_nb * host_nb) representing the communication
97 * amount between each pair of hosts
98 * \param amount the SURF action amount
99 * \param rate the SURF action rate
100 * \param timeout timeout
101 * \return A new SIMIX execution synchronization
103 smx_activity_t simcall_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list,
104 double* flops_amount, double* bytes_amount, double amount, double rate,
108 /* checking for infinite values */
109 for (i = 0 ; i < host_nb ; ++i) {
110 xbt_assert(std::isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i);
111 if (bytes_amount != nullptr) {
112 for (j = 0 ; j < host_nb ; ++j) {
113 xbt_assert(std::isfinite(bytes_amount[i + host_nb * j]),
114 "bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j);
119 xbt_assert(std::isfinite(amount), "amount is not finite!");
120 xbt_assert(std::isfinite(rate), "rate is not finite!");
122 return simcall_BODY_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate,
127 * \ingroup simix_process_management
128 * \brief Cancels an execution synchro.
130 * This functions stops the execution. It calls a surf function.
131 * \param execution The execution synchro to cancel
133 void simcall_execution_cancel(smx_activity_t execution)
135 simcall_BODY_execution_cancel(execution);
139 * \ingroup simix_process_management
140 * \brief Changes the priority of an execution synchro.
142 * This functions changes the priority only. It calls a surf function.
143 * \param execution The execution synchro
144 * \param priority The new priority
146 void simcall_execution_set_priority(smx_activity_t execution, double priority)
148 /* checking for infinite values */
149 xbt_assert(std::isfinite(priority), "priority is not finite!");
151 simcall_BODY_execution_set_priority(execution, priority);
155 * \ingroup simix_process_management
156 * \brief Changes the capping (the maximum CPU utilization) of an execution synchro.
158 * This functions changes the capping only. It calls a surf function.
159 * \param execution The execution synchro
160 * \param bound The new bound
162 void simcall_execution_set_bound(smx_activity_t execution, double bound)
164 simcall_BODY_execution_set_bound(execution, bound);
168 * \ingroup simix_host_management
169 * \brief Waits for the completion of an execution synchro and destroy it.
171 * \param execution The execution synchro
173 e_smx_state_t simcall_execution_wait(smx_activity_t execution)
175 return (e_smx_state_t) simcall_BODY_execution_wait(execution);
179 * \ingroup simix_vm_management
180 * \brief Create a VM on the given physical host.
182 * \param name VM name
183 * \param dest Physical host on which to create the VM
185 * \return The host object of the VM
187 sg_host_t simcall_vm_create(const char* name, sg_host_t dest)
189 return simgrid::simix::kernelImmediate([&name, &dest] {
190 sg_host_t host = new simgrid::s4u::VirtualMachine(name, dest);
191 host->extension_set<simgrid::simix::Host>(new simgrid::simix::Host());
198 * \ingroup simix_vm_management
199 * \brief Start the given VM to the given physical host
203 void simcall_vm_start(sg_host_t vm)
205 simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_start, vm));
209 * \ingroup simix_vm_management
210 * \brief Get the state of the given VM
213 * \return The state of the VM
215 int simcall_vm_get_state(sg_host_t vm)
217 return simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_get_state, vm));
221 * \ingroup simix_vm_management
222 * \brief Get the physical host on which the given VM runs.
225 * \return The physical host
227 void *simcall_vm_get_pm(sg_host_t vm)
229 return simgrid::simix::kernelImmediate(
230 [vm]() { return static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getPm(); });
234 * @brief Function to set the CPU bound of the given SIMIX VM host.
236 * @param host the vm host (a sg_host_t)
237 * @param bound bound (a double)
239 void simcall_vm_set_bound(sg_host_t vm, double bound)
241 simgrid::simix::kernelImmediate(
242 [vm, bound]() { static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->setBound(bound); });
246 * \ingroup simix_vm_management
247 * \brief Migrate the given VM to the given physical host
250 * \param host Destination physical host
252 void simcall_vm_migrate(sg_host_t vm, sg_host_t host)
254 simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_migrate, vm, host));
258 * \ingroup simix_vm_management
259 * \brief Suspend the given VM
263 void simcall_vm_suspend(sg_host_t vm)
265 simcall_BODY_vm_suspend(vm);
269 * \ingroup simix_vm_management
270 * \brief Resume the given VM
274 void simcall_vm_resume(sg_host_t vm)
276 simcall_BODY_vm_resume(vm);
280 * \ingroup simix_vm_management
281 * \brief Save the given VM
285 void simcall_vm_save(sg_host_t vm)
287 simcall_BODY_vm_save(vm);
291 * \ingroup simix_vm_management
292 * \brief Restore the given VM
296 void simcall_vm_restore(sg_host_t vm)
298 simgrid::simix::kernelImmediate([vm]() {
299 if (SIMIX_vm_get_state(vm) != SURF_VM_STATE_SAVED)
300 THROWF(vm_error, 0, "VM(%s) was not saved", vm->name().c_str());
302 XBT_DEBUG("restore VM(%s), where %d processes exist", vm->name().c_str(),
303 xbt_swag_size(sg_host_simix(vm)->process_list));
305 /* jump to vm_ws_restore() */
306 static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->restore();
308 smx_actor_t smx_process, smx_process_safe;
309 xbt_swag_foreach_safe(smx_process, smx_process_safe, sg_host_simix(vm)->process_list)
311 XBT_DEBUG("resume %s", smx_process->name.c_str());
312 SIMIX_process_resume(smx_process);
318 * \ingroup simix_vm_management
319 * \brief Shutdown the given VM
323 void simcall_vm_shutdown(sg_host_t vm)
325 simcall_BODY_vm_shutdown(vm);
329 * \ingroup simix_vm_management
330 * \brief Destroy the given VM
334 void simcall_vm_destroy(sg_host_t vm)
336 simgrid::simix::kernelImmediate([vm]() {
337 /* this code basically performs a similar thing like SIMIX_host_destroy() */
338 XBT_DEBUG("destroy %s", vm->name().c_str());
340 /* FIXME: this is really strange that everything fails if the next line is removed.
341 * This is as if we shared these data with the PM, which definitely should not be the case...
343 * We need to test that suspending a VM does not suspends the processes running on its PM, for example.
344 * Or we need to simplify this code enough to make it actually readable (but this sounds harder than testing)
346 vm->extension_set<simgrid::simix::Host>(nullptr);
348 /* Don't free these things twice: they are the ones of my physical host */
349 vm->pimpl_cpu = nullptr;
350 vm->pimpl_netcard = nullptr;
357 * \ingroup simix_process_management
358 * \brief Kills a SIMIX process.
360 * This function simply kills a process.
362 * \param process poor victim
364 void simcall_process_kill(smx_actor_t process)
366 simcall_BODY_process_kill(process);
370 * \ingroup simix_process_management
371 * \brief Kills all SIMIX processes.
373 void simcall_process_killall(int reset_pid)
375 simcall_BODY_process_killall(reset_pid);
379 * \ingroup simix_process_management
380 * \brief Cleans up a SIMIX process.
381 * \param process poor victim (must have already been killed)
383 void simcall_process_cleanup(smx_actor_t process)
385 simcall_BODY_process_cleanup(process);
389 * \ingroup simix_process_management
390 * \brief Migrates an agent to another location.
392 * This function changes the value of the host on which \a process is running.
394 * \param process the process to migrate
395 * \param dest name of the new host
397 void simcall_process_set_host(smx_actor_t process, sg_host_t dest)
399 simcall_BODY_process_set_host(process, dest);
402 void simcall_process_join(smx_actor_t process, double timeout)
404 simcall_BODY_process_join(process, timeout);
408 * \ingroup simix_process_management
409 * \brief Suspends a process.
411 * This function suspends the process by suspending the synchro
412 * it was waiting for completion.
414 * \param process a SIMIX process
416 void simcall_process_suspend(smx_actor_t process)
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_actor_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()
443 return simgrid::simix::kernelImmediate(SIMIX_process_count);
447 * \ingroup simix_process_management
448 * \brief Return the user data of a #smx_actor_t.
449 * \param process a SIMIX process
450 * \return the user data of this process
452 void* simcall_process_get_data(smx_actor_t process)
454 return SIMIX_process_get_data(process);
458 * \ingroup simix_process_management
459 * \brief Set the user data of a #smx_actor_t.
461 * This functions sets the user data associated to \a process.
462 * \param process SIMIX process
463 * \param data User data
465 void simcall_process_set_data(smx_actor_t process, void *data)
467 simgrid::simix::kernelImmediate(std::bind(SIMIX_process_set_data, process, data));
471 * \ingroup simix_process_management
472 * \brief Set the kill time of a process.
474 void simcall_process_set_kill_time(smx_actor_t process, double kill_time)
477 if (kill_time <= SIMIX_get_clock() || simix_global->kill_process_function == nullptr)
479 XBT_DEBUG("Set kill time %f for process %s(%s)",
480 kill_time, process->name.c_str(), sg_host_get_name(process->host));
481 process->kill_timer = SIMIX_timer_set(kill_time, [=] {
482 simix_global->kill_process_function(process);
483 process->kill_timer=nullptr;
487 * \ingroup simix_process_management
488 * \brief Get the kill time of a process (or 0 if unset).
490 double simcall_process_get_kill_time(smx_actor_t process) {
491 return SIMIX_timer_get_date(process->kill_timer);
495 * \ingroup simix_process_management
496 * \brief Returns true if the process is suspended .
498 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
499 * \param process SIMIX process
500 * \return 1, if the process is suspended, else 0.
502 int simcall_process_is_suspended(smx_actor_t process)
504 return simcall_BODY_process_is_suspended(process);
508 * \ingroup simix_process_management
509 * \brief Return the properties
511 * This functions returns the properties associated with this process
513 xbt_dict_t simcall_process_get_properties(smx_actor_t process)
515 return SIMIX_process_get_properties(process);
518 * \ingroup simix_process_management
519 * \brief Add an on_exit function
520 * Add an on_exit function which will be executed when the process exits/is killed.
522 XBT_PUBLIC(void) simcall_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data)
524 simcall_BODY_process_on_exit(process, fun, data);
527 * \ingroup simix_process_management
528 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
529 * Will restart the process when the host comes back up if auto_restart is set to 1.
532 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_actor_t process, int auto_restart)
534 simcall_BODY_process_auto_restart_set(process, auto_restart);
538 * \ingroup simix_process_management
539 * \brief Restarts the process, killing it and starting it again from scratch.
541 XBT_PUBLIC(smx_actor_t) simcall_process_restart(smx_actor_t process)
543 return (smx_actor_t) simcall_BODY_process_restart(process);
546 * \ingroup simix_process_management
547 * \brief Creates a new sleep SIMIX synchro.
549 * This function creates a SURF action and allocates the data necessary
550 * to create the SIMIX synchro. It can raise a host_error exception if the
551 * host crashed. The default SIMIX name of the synchro is "sleep".
553 * \param duration Time duration of the sleep.
554 * \return A result telling whether the sleep was successful
556 e_smx_state_t simcall_process_sleep(double duration)
558 /* checking for infinite values */
559 xbt_assert(std::isfinite(duration), "duration is not finite!");
560 return (e_smx_state_t) simcall_BODY_process_sleep(duration);
564 * \ingroup simix_mbox_management
565 * \brief Creates a new rendez-vous point
566 * \param name The name of the rendez-vous point
567 * \return The created rendez-vous point
569 smx_mailbox_t simcall_mbox_create(const char *name)
571 return simcall_BODY_mbox_create(name);
574 void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t process)
576 simcall_BODY_mbox_set_receiver(mbox, process);
580 * \ingroup simix_comm_management
582 void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate,
583 void *src_buff, size_t src_buff_size,
584 int (*match_fun)(void *, void *, smx_activity_t),
585 void (*copy_data_fun)(smx_activity_t, void*, size_t), void *data,
588 /* checking for infinite values */
589 xbt_assert(std::isfinite(task_size), "task_size is not finite!");
590 xbt_assert(std::isfinite(rate), "rate is not finite!");
591 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
593 xbt_assert(mbox, "No rendez-vous point defined for send");
595 if (MC_is_active() || MC_record_replay_is_active()) {
596 /* the model-checker wants two separate simcalls */
597 smx_activity_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
598 comm = simcall_comm_isend(sender, mbox, task_size, rate,
599 src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0);
600 simcall_comm_wait(comm, timeout);
604 simcall_BODY_comm_send(sender, mbox, task_size, rate, src_buff, src_buff_size,
605 match_fun, copy_data_fun, data, timeout);
610 * \ingroup simix_comm_management
612 smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate,
613 void *src_buff, size_t src_buff_size,
614 int (*match_fun)(void *, void *, smx_activity_t),
615 void (*clean_fun)(void *),
616 void (*copy_data_fun)(smx_activity_t, void*, size_t),
620 /* checking for infinite values */
621 xbt_assert(std::isfinite(task_size), "task_size is not finite!");
622 xbt_assert(std::isfinite(rate), "rate is not finite!");
624 xbt_assert(mbox, "No rendez-vous point defined for isend");
626 return simcall_BODY_comm_isend(sender, mbox, task_size, rate, src_buff,
627 src_buff_size, match_fun,
628 clean_fun, copy_data_fun, data, detached);
632 * \ingroup simix_comm_management
634 void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t * dst_buff_size,
635 int (*match_fun)(void *, void *, smx_activity_t),
636 void (*copy_data_fun)(smx_activity_t, void*, size_t),
637 void *data, double timeout, double rate)
639 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
640 xbt_assert(mbox, "No rendez-vous point defined for recv");
642 if (MC_is_active() || MC_record_replay_is_active()) {
643 /* the model-checker wants two separate simcalls */
644 smx_activity_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
645 comm = simcall_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
646 match_fun, copy_data_fun, data, rate);
647 simcall_comm_wait(comm, timeout);
651 simcall_BODY_comm_recv(receiver, mbox, dst_buff, dst_buff_size,
652 match_fun, copy_data_fun, data, timeout, rate);
656 * \ingroup simix_comm_management
658 smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size,
659 int (*match_fun)(void *, void *, smx_activity_t),
660 void (*copy_data_fun)(smx_activity_t, void*, size_t),
661 void *data, double rate)
663 xbt_assert(mbox, "No rendez-vous point defined for irecv");
665 return simcall_BODY_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
666 match_fun, copy_data_fun, data, rate);
670 * \ingroup simix_comm_management
672 smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag,
673 int (*match_fun)(void *, void *, smx_activity_t), void *data)
675 xbt_assert(mbox, "No rendez-vous point defined for iprobe");
677 return simcall_BODY_comm_iprobe(mbox, type, src, tag, match_fun, data);
681 * \ingroup simix_comm_management
683 void simcall_comm_cancel(smx_activity_t synchro)
685 simgrid::simix::kernelImmediate([synchro]{
686 simgrid::kernel::activity::Comm *comm = static_cast<simgrid::kernel::activity::Comm*>(synchro);
692 * \ingroup simix_comm_management
694 unsigned int simcall_comm_waitany(xbt_dynar_t comms, double timeout)
696 return simcall_BODY_comm_waitany(comms, timeout);
700 * \ingroup simix_comm_management
702 int simcall_comm_testany(smx_activity_t* comms, size_t count)
706 return simcall_BODY_comm_testany(comms, count);
710 * \ingroup simix_comm_management
712 void simcall_comm_wait(smx_activity_t comm, double timeout)
714 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
715 simcall_BODY_comm_wait(comm, timeout);
719 * \brief Set the category of an synchro.
721 * This functions changes the category only. It calls a surf function.
722 * \param execution The execution synchro
723 * \param category The tracing category
725 void simcall_set_category(smx_activity_t synchro, const char *category)
727 if (category == nullptr) {
730 simcall_BODY_set_category(synchro, category);
734 * \ingroup simix_comm_management
737 int simcall_comm_test(smx_activity_t comm)
739 return simcall_BODY_comm_test(comm);
743 * \ingroup simix_synchro_management
746 smx_mutex_t simcall_mutex_init()
749 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
752 return simcall_BODY_mutex_init();
756 * \ingroup simix_synchro_management
759 void simcall_mutex_lock(smx_mutex_t mutex)
761 simcall_BODY_mutex_lock(mutex);
765 * \ingroup simix_synchro_management
768 int simcall_mutex_trylock(smx_mutex_t mutex)
770 return simcall_BODY_mutex_trylock(mutex);
774 * \ingroup simix_synchro_management
777 void simcall_mutex_unlock(smx_mutex_t mutex)
779 simcall_BODY_mutex_unlock(mutex);
783 * \ingroup simix_synchro_management
786 smx_cond_t simcall_cond_init()
788 return simcall_BODY_cond_init();
792 * \ingroup simix_synchro_management
795 void simcall_cond_signal(smx_cond_t cond)
797 simcall_BODY_cond_signal(cond);
801 * \ingroup simix_synchro_management
804 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
806 simcall_BODY_cond_wait(cond, mutex);
810 * \ingroup simix_synchro_management
813 void simcall_cond_wait_timeout(smx_cond_t cond,
817 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
818 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
822 * \ingroup simix_synchro_management
825 void simcall_cond_broadcast(smx_cond_t cond)
827 simcall_BODY_cond_broadcast(cond);
831 * \ingroup simix_synchro_management
834 smx_sem_t simcall_sem_init(int capacity)
836 return simcall_BODY_sem_init(capacity);
840 * \ingroup simix_synchro_management
843 void simcall_sem_release(smx_sem_t sem)
845 simcall_BODY_sem_release(sem);
849 * \ingroup simix_synchro_management
852 int simcall_sem_would_block(smx_sem_t sem)
854 return simcall_BODY_sem_would_block(sem);
858 * \ingroup simix_synchro_management
861 void simcall_sem_acquire(smx_sem_t sem)
863 simcall_BODY_sem_acquire(sem);
867 * \ingroup simix_synchro_management
870 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
872 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
873 simcall_BODY_sem_acquire_timeout(sem, timeout);
877 * \ingroup simix_synchro_management
880 int simcall_sem_get_capacity(smx_sem_t sem)
882 return simcall_BODY_sem_get_capacity(sem);
886 * \ingroup simix_file_management
889 sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
891 return simcall_BODY_file_read(fd, size, host);
895 * \ingroup simix_file_management
898 sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
900 return simcall_BODY_file_write(fd, size, host);
904 * \ingroup simix_file_management
907 smx_file_t simcall_file_open(const char* fullpath, sg_host_t host)
909 return simcall_BODY_file_open(fullpath, host);
913 * \ingroup simix_file_management
916 int simcall_file_close(smx_file_t fd, sg_host_t host)
918 return simcall_BODY_file_close(fd, host);
922 * \ingroup simix_file_management
925 int simcall_file_unlink(smx_file_t fd, sg_host_t host)
927 return simcall_BODY_file_unlink(fd, host);
931 * \ingroup simix_file_management
934 sg_size_t simcall_file_get_size(smx_file_t fd){
935 return simcall_BODY_file_get_size(fd);
939 * \ingroup simix_file_management
942 sg_size_t simcall_file_tell(smx_file_t fd){
943 return simcall_BODY_file_tell(fd);
947 * \ingroup simix_file_management
950 xbt_dynar_t simcall_file_get_info(smx_file_t fd)
952 return simcall_BODY_file_get_info(fd);
956 * \ingroup simix_file_management
959 int simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin){
960 return simcall_BODY_file_seek(fd, offset, origin);
964 * \ingroup simix_file_management
965 * \brief Move a file to another location on the *same mount point*.
968 int simcall_file_move(smx_file_t fd, const char* fullpath)
970 return simcall_BODY_file_move(fd, fullpath);
974 * \ingroup simix_storage_management
975 * \brief Returns the free space size on a given storage element.
976 * \param storage a storage
977 * \return Return the free space size on a given storage element (as sg_size_t)
979 sg_size_t simcall_storage_get_free_size (smx_storage_t storage){
980 return simcall_BODY_storage_get_free_size(storage);
984 * \ingroup simix_storage_management
985 * \brief Returns the used space size on a given storage element.
986 * \param storage a storage
987 * \return Return the used space size on a given storage element (as sg_size_t)
989 sg_size_t simcall_storage_get_used_size (smx_storage_t storage){
990 return simcall_BODY_storage_get_used_size(storage);
994 * \ingroup simix_storage_management
995 * \brief Returns a dict of the properties assigned to a storage element.
997 * \param storage A storage element
998 * \return The properties of this storage element
1000 xbt_dict_t simcall_storage_get_properties(smx_storage_t storage)
1002 return simcall_BODY_storage_get_properties(storage);
1006 * \ingroup simix_storage_management
1007 * \brief Returns a dict containing the content of a storage element.
1009 * \param storage A storage element
1010 * \return The content of this storage element as a dict (full path file => size)
1012 xbt_dict_t simcall_storage_get_content(smx_storage_t storage)
1014 return simcall_BODY_storage_get_content(storage);
1017 void simcall_run_kernel(std::function<void()> const& code)
1019 simcall_BODY_run_kernel(&code);
1022 void simcall_run_blocking(std::function<void()> const& code)
1024 simcall_BODY_run_blocking(&code);
1027 int simcall_mc_random(int min, int max) {
1028 return simcall_BODY_mc_random(min, max);
1031 /* ************************************************************************** */
1033 /** @brief returns a printable string representing a simcall */
1034 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1035 return simcall_names[kind];
1041 void unblock(smx_actor_t process)
1043 xbt_assert(SIMIX_is_maestro());
1044 SIMIX_simcall_answer(&process->simcall);