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/simix/blocking_simcall.hpp>
22 #include "src/mc/mc_replay.h"
23 #include "smx_private.h"
24 #include "src/mc/mc_forward.hpp"
27 #include "src/simix/smx_host_private.h"
28 #include "src/kernel/activity/SynchroComm.hpp"
30 #include <simgrid/simix.hpp>
32 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
34 #include "popping_bodies.cpp"
36 void simcall_call(smx_process_t process)
38 if (process != simix_global->maestro_process) {
39 XBT_DEBUG("Yield process '%s' on simcall %s (%d)", process->name.c_str(),
40 SIMIX_simcall_name(process->simcall.call), (int)process->simcall.call);
41 SIMIX_process_yield(process);
43 SIMIX_simcall_handle(&process->simcall, 0);
50 * \ingroup simix_host_management
51 * \brief Returns a dict of the properties assigned to a router or AS.
53 * \param name The name of the router or AS
54 * \return The properties
56 xbt_dict_t simcall_asr_get_properties(const char *name)
58 return simcall_BODY_asr_get_properties(name);
62 * \ingroup simix_process_management
63 * \brief Creates a synchro that executes some computation of an host.
65 * This function creates a SURF action and allocates the data necessary
66 * to create the SIMIX synchro. It can raise a host_error exception if the host crashed.
68 * \param name Name of the execution synchro to create
69 * \param flops_amount amount Computation amount (in flops)
70 * \param priority computation priority
72 * \param affinity_mask
73 * \return A new SIMIX execution synchronization
75 smx_synchro_t simcall_execution_start(const char *name,
77 double priority, double bound, unsigned long affinity_mask)
79 /* checking for infinite values */
80 xbt_assert(std::isfinite(flops_amount), "flops_amount is not finite!");
81 xbt_assert(std::isfinite(priority), "priority is not finite!");
83 return simcall_BODY_execution_start(name, flops_amount, priority, bound, affinity_mask);
87 * \ingroup simix_process_management
88 * \brief Creates a synchro that may involve parallel computation on
89 * several hosts and communication between them.
91 * \param name Name of the execution synchro to create
92 * \param host_nb Number of hosts where the synchro will be executed
93 * \param host_list Array (of size host_nb) of hosts where the synchro will be executed
94 * \param flops_amount Array (of size host_nb) of computation amount of hosts (in bytes)
95 * \param bytes_amount Array (of size host_nb * host_nb) representing the communication
96 * amount between each pair of hosts
97 * \param amount the SURF action amount
98 * \param rate the SURF action rate
99 * \return A new SIMIX execution synchronization
101 smx_synchro_t simcall_execution_parallel_start(const char *name,
103 sg_host_t *host_list,
104 double *flops_amount,
105 double *bytes_amount,
110 /* checking for infinite values */
111 for (i = 0 ; i < host_nb ; ++i) {
112 xbt_assert(std::isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i);
113 if (bytes_amount != nullptr) {
114 for (j = 0 ; j < host_nb ; ++j) {
115 xbt_assert(std::isfinite(bytes_amount[i + host_nb * j]),
116 "bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j);
121 xbt_assert(std::isfinite(amount), "amount is not finite!");
122 xbt_assert(std::isfinite(rate), "rate is not finite!");
124 return simcall_BODY_execution_parallel_start(name, host_nb, host_list,
132 * \ingroup simix_process_management
133 * \brief Cancels an execution synchro.
135 * This functions stops the execution. It calls a surf function.
136 * \param execution The execution synchro to cancel
138 void simcall_execution_cancel(smx_synchro_t execution)
140 simcall_BODY_execution_cancel(execution);
144 * \ingroup simix_process_management
145 * \brief Changes the priority of an execution synchro.
147 * This functions changes the priority only. It calls a surf function.
148 * \param execution The execution synchro
149 * \param priority The new priority
151 void simcall_execution_set_priority(smx_synchro_t execution, double priority)
153 /* checking for infinite values */
154 xbt_assert(std::isfinite(priority), "priority is not finite!");
156 simcall_BODY_execution_set_priority(execution, priority);
160 * \ingroup simix_process_management
161 * \brief Changes the capping (the maximum CPU utilization) of an execution synchro.
163 * This functions changes the capping only. It calls a surf function.
164 * \param execution The execution synchro
165 * \param bound The new bound
167 void simcall_execution_set_bound(smx_synchro_t execution, double bound)
169 simcall_BODY_execution_set_bound(execution, bound);
173 * \ingroup simix_process_management
174 * \brief Changes the CPU affinity of an execution synchro.
176 * This functions changes the CPU affinity of an execution synchro. See taskset(1) on Linux.
177 * \param execution The execution synchro
179 * \param mask Affinity mask
181 void simcall_execution_set_affinity(smx_synchro_t execution, sg_host_t host, unsigned long mask)
183 simcall_BODY_execution_set_affinity(execution, host, mask);
187 * \ingroup simix_host_management
188 * \brief Waits for the completion of an execution synchro and destroy it.
190 * \param execution The execution synchro
192 e_smx_state_t simcall_execution_wait(smx_synchro_t execution)
194 return (e_smx_state_t) simcall_BODY_execution_wait(execution);
199 * \ingroup simix_vm_management
200 * \brief Create a VM on the given physical host.
202 * \param name VM name
203 * \param host Physical host
205 * \return The host object of the VM
207 void* simcall_vm_create(const char *name, sg_host_t phys_host)
209 return simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_create, name, phys_host));
213 * \ingroup simix_vm_management
214 * \brief Start the given VM to the given physical host
218 void simcall_vm_start(sg_host_t vm)
220 simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_start, vm));
224 * \ingroup simix_vm_management
225 * \brief Get the state of the given VM
228 * \return The state of the VM
230 int simcall_vm_get_state(sg_host_t vm)
232 return simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_get_state, vm));
236 * \ingroup simix_vm_management
237 * \brief Get the name of the physical host on which the given VM runs.
240 * \return The name of the physical host
242 void *simcall_vm_get_pm(sg_host_t vm)
244 return simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_get_pm, vm));
247 void simcall_vm_set_bound(sg_host_t vm, double bound)
249 simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_set_bound, vm, bound));
252 void simcall_vm_set_affinity(sg_host_t vm, sg_host_t pm, unsigned long mask)
254 simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_set_affinity, vm, pm, mask));
258 * \ingroup simix_vm_management
259 * \brief Migrate the given VM to the given physical host
262 * \param host Destination physical host
264 void simcall_vm_migrate(sg_host_t vm, sg_host_t host)
266 simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_migrate, vm, host));
270 * \ingroup simix_vm_management
271 * \brief Suspend the given VM
275 void simcall_vm_suspend(sg_host_t vm)
277 simcall_BODY_vm_suspend(vm);
281 * \ingroup simix_vm_management
282 * \brief Resume the given VM
286 void simcall_vm_resume(sg_host_t vm)
288 simcall_BODY_vm_resume(vm);
292 * \ingroup simix_vm_management
293 * \brief Save the given VM
297 void simcall_vm_save(sg_host_t vm)
299 simcall_BODY_vm_save(vm);
303 * \ingroup simix_vm_management
304 * \brief Restore the given VM
308 void simcall_vm_restore(sg_host_t vm)
310 simcall_BODY_vm_restore(vm);
314 * \ingroup simix_vm_management
315 * \brief Shutdown the given VM
319 void simcall_vm_shutdown(sg_host_t vm)
321 simcall_BODY_vm_shutdown(vm);
325 * \ingroup simix_vm_management
326 * \brief Destroy the given VM
330 void simcall_vm_destroy(sg_host_t vm)
332 simgrid::simix::kernelImmediate(std::bind(SIMIX_vm_destroy, vm));
336 * \ingroup simix_vm_management
337 * \brief Encompassing simcall to prevent the removal of the src or the dst node at the end of a VM migration
338 * The simcall actually invokes the following calls:
339 * simcall_vm_set_affinity(vm, src_pm, 0);
340 * simcall_vm_migrate(vm, dst_pm);
341 * simcall_vm_resume(vm);
343 * It is called at the end of the migration_rx_fun function from msg/msg_vm.c
345 * \param vm VM to migrate
346 * \param src_pm Source physical host
347 * \param dst_pmt Destination physical host
349 void simcall_vm_migratefrom_resumeto(sg_host_t vm, sg_host_t src_pm, sg_host_t dst_pm)
351 simgrid::simix::kernelImmediate(std::bind(
352 SIMIX_vm_migratefrom_resumeto, vm, src_pm, dst_pm));
356 * \ingroup simix_process_management
357 * \brief Kills a SIMIX process.
359 * This function simply kills a process.
361 * \param process poor victim
363 void simcall_process_kill(smx_process_t process)
365 simcall_BODY_process_kill(process);
369 * \ingroup simix_process_management
370 * \brief Kills all SIMIX processes.
372 void simcall_process_killall(int reset_pid)
374 simcall_BODY_process_killall(reset_pid);
378 * \ingroup simix_process_management
379 * \brief Cleans up a SIMIX process.
380 * \param process poor victim (must have already been killed)
382 void simcall_process_cleanup(smx_process_t process)
384 simcall_BODY_process_cleanup(process);
388 * \ingroup simix_process_management
389 * \brief Migrates an agent to another location.
391 * This function changes the value of the host on which \a process is running.
393 * \param process the process to migrate
394 * \param dest name of the new host
396 void simcall_process_set_host(smx_process_t process, sg_host_t dest)
398 simcall_BODY_process_set_host(process, dest);
401 void simcall_process_join(smx_process_t process, double timeout)
403 simcall_BODY_process_join(process, timeout);
407 * \ingroup simix_process_management
408 * \brief Suspends a process.
410 * This function suspends the process by suspending the synchro
411 * it was waiting for completion.
413 * \param process a SIMIX process
415 void simcall_process_suspend(smx_process_t process)
417 xbt_assert(process, "Invalid parameters");
419 simcall_BODY_process_suspend(process);
423 * \ingroup simix_process_management
424 * \brief Resumes a suspended process.
426 * This function resumes a suspended process by resuming the synchro
427 * it was waiting for completion.
429 * \param process a SIMIX process
431 void simcall_process_resume(smx_process_t process)
433 simcall_BODY_process_resume(process);
437 * \ingroup simix_process_management
438 * \brief Returns the amount of SIMIX processes in the system
440 * Maestro internal process is not counted, only user code processes are
442 int simcall_process_count()
444 return simgrid::simix::kernelImmediate(SIMIX_process_count);
448 * \ingroup simix_process_management
449 * \brief Return the user data of a #smx_process_t.
450 * \param process a SIMIX process
451 * \return the user data of this process
453 void* simcall_process_get_data(smx_process_t process)
455 return SIMIX_process_get_data(process);
459 * \ingroup simix_process_management
460 * \brief Set the user data of a #smx_process_t.
462 * This functions sets the user data associated to \a process.
463 * \param process SIMIX process
464 * \param data User data
466 void simcall_process_set_data(smx_process_t process, void *data)
468 simgrid::simix::kernelImmediate(std::bind(SIMIX_process_set_data, process, data));
472 * \ingroup simix_process_management
473 * \brief Set the kill time of a process.
475 void simcall_process_set_kill_time(smx_process_t process, double kill_time)
478 if (kill_time <= SIMIX_get_clock() || simix_global->kill_process_function == nullptr)
480 XBT_DEBUG("Set kill time %f for process %s(%s)",
481 kill_time, process->name.c_str(), sg_host_get_name(process->host));
482 process->kill_timer = SIMIX_timer_set(kill_time, [=] {
483 simix_global->kill_process_function(process);
484 process->kill_timer=nullptr;
488 * \ingroup simix_process_management
489 * \brief Get the kill time of a process (or 0 if unset).
491 double simcall_process_get_kill_time(smx_process_t process) {
492 return SIMIX_timer_get_date(process->kill_timer);
496 * \ingroup simix_process_management
497 * \brief Returns true if the process is suspended .
499 * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
500 * \param process SIMIX process
501 * \return 1, if the process is suspended, else 0.
503 int simcall_process_is_suspended(smx_process_t process)
505 return simcall_BODY_process_is_suspended(process);
509 * \ingroup simix_process_management
510 * \brief Return the properties
512 * This functions returns the properties associated with this process
514 xbt_dict_t simcall_process_get_properties(smx_process_t process)
516 return SIMIX_process_get_properties(process);
519 * \ingroup simix_process_management
520 * \brief Add an on_exit function
521 * Add an on_exit function which will be executed when the process exits/is killed.
523 XBT_PUBLIC(void) simcall_process_on_exit(smx_process_t process, int_f_pvoid_pvoid_t fun, void *data)
525 simcall_BODY_process_on_exit(process, fun, data);
528 * \ingroup simix_process_management
529 * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
530 * Will restart the process when the host comes back up if auto_restart is set to 1.
533 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_process_t process, int auto_restart)
535 simcall_BODY_process_auto_restart_set(process, auto_restart);
539 * \ingroup simix_process_management
540 * \brief Restarts the process, killing it and starting it again from scratch.
542 XBT_PUBLIC(smx_process_t) simcall_process_restart(smx_process_t process)
544 return (smx_process_t) simcall_BODY_process_restart(process);
547 * \ingroup simix_process_management
548 * \brief Creates a new sleep SIMIX synchro.
550 * This function creates a SURF action and allocates the data necessary
551 * to create the SIMIX synchro. It can raise a host_error exception if the
552 * host crashed. The default SIMIX name of the synchro is "sleep".
554 * \param duration Time duration of the sleep.
555 * \return A result telling whether the sleep was successful
557 e_smx_state_t simcall_process_sleep(double duration)
559 /* checking for infinite values */
560 xbt_assert(std::isfinite(duration), "duration is not finite!");
561 return (e_smx_state_t) simcall_BODY_process_sleep(duration);
565 * \ingroup simix_mbox_management
566 * \brief Creates a new rendez-vous point
567 * \param name The name of the rendez-vous point
568 * \return The created rendez-vous point
570 smx_mailbox_t simcall_mbox_create(const char *name)
572 return simcall_BODY_mbox_create(name);
575 void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_process_t process)
577 simcall_BODY_mbox_set_receiver(mbox, process);
581 * \ingroup simix_comm_management
583 void simcall_comm_send(smx_process_t sender, smx_mailbox_t mbox, double task_size, double rate,
584 void *src_buff, size_t src_buff_size,
585 int (*match_fun)(void *, void *, smx_synchro_t),
586 void (*copy_data_fun)(smx_synchro_t, void*, size_t), void *data,
589 /* checking for infinite values */
590 xbt_assert(std::isfinite(task_size), "task_size is not finite!");
591 xbt_assert(std::isfinite(rate), "rate is not finite!");
592 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
594 xbt_assert(mbox, "No rendez-vous point defined for send");
596 if (MC_is_active() || MC_record_replay_is_active()) {
597 /* the model-checker wants two separate simcalls */
598 smx_synchro_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
599 comm = simcall_comm_isend(sender, mbox, task_size, rate,
600 src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0);
601 simcall_comm_wait(comm, timeout);
605 simcall_BODY_comm_send(sender, mbox, task_size, rate, src_buff, src_buff_size,
606 match_fun, copy_data_fun, data, timeout);
611 * \ingroup simix_comm_management
613 smx_synchro_t simcall_comm_isend(smx_process_t sender, smx_mailbox_t mbox, double task_size, double rate,
614 void *src_buff, size_t src_buff_size,
615 int (*match_fun)(void *, void *, smx_synchro_t),
616 void (*clean_fun)(void *),
617 void (*copy_data_fun)(smx_synchro_t, void*, size_t),
621 /* checking for infinite values */
622 xbt_assert(std::isfinite(task_size), "task_size is not finite!");
623 xbt_assert(std::isfinite(rate), "rate is not finite!");
625 xbt_assert(mbox, "No rendez-vous point defined for isend");
627 return simcall_BODY_comm_isend(sender, mbox, task_size, rate, src_buff,
628 src_buff_size, match_fun,
629 clean_fun, copy_data_fun, data, detached);
633 * \ingroup simix_comm_management
635 void simcall_comm_recv(smx_process_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t * dst_buff_size,
636 int (*match_fun)(void *, void *, smx_synchro_t),
637 void (*copy_data_fun)(smx_synchro_t, void*, size_t),
638 void *data, double timeout, double rate)
640 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
641 xbt_assert(mbox, "No rendez-vous point defined for recv");
643 if (MC_is_active() || MC_record_replay_is_active()) {
644 /* the model-checker wants two separate simcalls */
645 smx_synchro_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
646 comm = simcall_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
647 match_fun, copy_data_fun, data, rate);
648 simcall_comm_wait(comm, timeout);
652 simcall_BODY_comm_recv(receiver, mbox, dst_buff, dst_buff_size,
653 match_fun, copy_data_fun, data, timeout, rate);
657 * \ingroup simix_comm_management
659 smx_synchro_t simcall_comm_irecv(smx_process_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size,
660 int (*match_fun)(void *, void *, smx_synchro_t),
661 void (*copy_data_fun)(smx_synchro_t, void*, size_t),
662 void *data, double rate)
664 xbt_assert(mbox, "No rendez-vous point defined for irecv");
666 return simcall_BODY_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
667 match_fun, copy_data_fun, data, rate);
671 * \ingroup simix_comm_management
673 smx_synchro_t simcall_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag,
674 int (*match_fun)(void *, void *, smx_synchro_t), void *data)
676 xbt_assert(mbox, "No rendez-vous point defined for iprobe");
678 return simcall_BODY_comm_iprobe(mbox, type, src, tag, match_fun, data);
682 * \ingroup simix_comm_management
684 void simcall_comm_cancel(smx_synchro_t synchro)
686 simgrid::simix::kernelImmediate([synchro]{
687 simgrid::kernel::activity::Comm *comm = static_cast<simgrid::kernel::activity::Comm*>(synchro);
693 * \ingroup simix_comm_management
695 unsigned int simcall_comm_waitany(xbt_dynar_t comms, double timeout)
697 return simcall_BODY_comm_waitany(comms, timeout);
701 * \ingroup simix_comm_management
703 int simcall_comm_testany(smx_synchro_t* comms, size_t count)
707 return simcall_BODY_comm_testany(comms, count);
711 * \ingroup simix_comm_management
713 void simcall_comm_wait(smx_synchro_t comm, double timeout)
715 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
716 simcall_BODY_comm_wait(comm, timeout);
720 * \brief Set the category of an synchro.
722 * This functions changes the category only. It calls a surf function.
723 * \param execution The execution synchro
724 * \param category The tracing category
726 void simcall_set_category(smx_synchro_t synchro, const char *category)
728 if (category == nullptr) {
731 simcall_BODY_set_category(synchro, category);
735 * \ingroup simix_comm_management
738 int simcall_comm_test(smx_synchro_t comm)
740 return simcall_BODY_comm_test(comm);
744 * \ingroup simix_synchro_management
747 smx_mutex_t simcall_mutex_init()
750 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
753 return simcall_BODY_mutex_init();
757 * \ingroup simix_synchro_management
760 void simcall_mutex_lock(smx_mutex_t mutex)
762 simcall_BODY_mutex_lock(mutex);
766 * \ingroup simix_synchro_management
769 int simcall_mutex_trylock(smx_mutex_t mutex)
771 return simcall_BODY_mutex_trylock(mutex);
775 * \ingroup simix_synchro_management
778 void simcall_mutex_unlock(smx_mutex_t mutex)
780 simcall_BODY_mutex_unlock(mutex);
784 * \ingroup simix_synchro_management
787 smx_cond_t simcall_cond_init()
789 return simcall_BODY_cond_init();
793 * \ingroup simix_synchro_management
796 void simcall_cond_signal(smx_cond_t cond)
798 simcall_BODY_cond_signal(cond);
802 * \ingroup simix_synchro_management
805 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
807 simcall_BODY_cond_wait(cond, mutex);
811 * \ingroup simix_synchro_management
814 void simcall_cond_wait_timeout(smx_cond_t cond,
818 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
819 simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
823 * \ingroup simix_synchro_management
826 void simcall_cond_broadcast(smx_cond_t cond)
828 simcall_BODY_cond_broadcast(cond);
832 * \ingroup simix_synchro_management
835 smx_sem_t simcall_sem_init(int capacity)
837 return simcall_BODY_sem_init(capacity);
841 * \ingroup simix_synchro_management
844 void simcall_sem_release(smx_sem_t sem)
846 simcall_BODY_sem_release(sem);
850 * \ingroup simix_synchro_management
853 int simcall_sem_would_block(smx_sem_t sem)
855 return simcall_BODY_sem_would_block(sem);
859 * \ingroup simix_synchro_management
862 void simcall_sem_acquire(smx_sem_t sem)
864 simcall_BODY_sem_acquire(sem);
868 * \ingroup simix_synchro_management
871 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
873 xbt_assert(std::isfinite(timeout), "timeout is not finite!");
874 simcall_BODY_sem_acquire_timeout(sem, timeout);
878 * \ingroup simix_synchro_management
881 int simcall_sem_get_capacity(smx_sem_t sem)
883 return simcall_BODY_sem_get_capacity(sem);
887 * \ingroup simix_file_management
890 sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
892 return simcall_BODY_file_read(fd, size, host);
896 * \ingroup simix_file_management
899 sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
901 return simcall_BODY_file_write(fd, size, host);
905 * \ingroup simix_file_management
908 smx_file_t simcall_file_open(const char* fullpath, sg_host_t host)
910 return simcall_BODY_file_open(fullpath, host);
914 * \ingroup simix_file_management
917 int simcall_file_close(smx_file_t fd, sg_host_t host)
919 return simcall_BODY_file_close(fd, host);
923 * \ingroup simix_file_management
926 int simcall_file_unlink(smx_file_t fd, sg_host_t host)
928 return simcall_BODY_file_unlink(fd, host);
932 * \ingroup simix_file_management
935 sg_size_t simcall_file_get_size(smx_file_t fd){
936 return simcall_BODY_file_get_size(fd);
940 * \ingroup simix_file_management
943 sg_size_t simcall_file_tell(smx_file_t fd){
944 return simcall_BODY_file_tell(fd);
948 * \ingroup simix_file_management
951 xbt_dynar_t simcall_file_get_info(smx_file_t fd)
953 return simcall_BODY_file_get_info(fd);
957 * \ingroup simix_file_management
960 int simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin){
961 return simcall_BODY_file_seek(fd, offset, origin);
965 * \ingroup simix_file_management
966 * \brief Move a file to another location on the *same mount point*.
969 int simcall_file_move(smx_file_t fd, const char* fullpath)
971 return simcall_BODY_file_move(fd, fullpath);
975 * \ingroup simix_storage_management
976 * \brief Returns the free space size on a given storage element.
977 * \param storage a storage
978 * \return Return the free space size on a given storage element (as sg_size_t)
980 sg_size_t simcall_storage_get_free_size (smx_storage_t storage){
981 return simcall_BODY_storage_get_free_size(storage);
985 * \ingroup simix_storage_management
986 * \brief Returns the used space size on a given storage element.
987 * \param storage a storage
988 * \return Return the used space size on a given storage element (as sg_size_t)
990 sg_size_t simcall_storage_get_used_size (smx_storage_t storage){
991 return simcall_BODY_storage_get_used_size(storage);
995 * \ingroup simix_storage_management
996 * \brief Returns a dict of the properties assigned to a storage element.
998 * \param storage A storage element
999 * \return The properties of this storage element
1001 xbt_dict_t simcall_storage_get_properties(smx_storage_t storage)
1003 return simcall_BODY_storage_get_properties(storage);
1007 * \ingroup simix_storage_management
1008 * \brief Returns a dict containing the content of a storage element.
1010 * \param storage A storage element
1011 * \return The content of this storage element as a dict (full path file => size)
1013 xbt_dict_t simcall_storage_get_content(smx_storage_t storage)
1015 return simcall_BODY_storage_get_content(storage);
1018 void simcall_run_kernel(std::function<void()> const& code)
1020 simcall_BODY_run_kernel(&code);
1023 void simcall_run_blocking(std::function<void()> const& code)
1025 simcall_BODY_run_blocking(&code);
1028 int simcall_mc_random(int min, int max) {
1029 return simcall_BODY_mc_random(min, max);
1032 /* ************************************************************************** */
1034 /** @brief returns a printable string representing a simcall */
1035 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
1036 return simcall_names[kind];
1042 void unblock(smx_process_t process)
1044 xbt_assert(SIMIX_is_maestro());
1045 SIMIX_simcall_answer(&process->simcall);