Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e1de85955cff891889c03dd51605d08009a136ec
[simgrid.git] / src / simix / libsmx.cpp
1 /* libsmx.c - public interface to simix                                       */
2 /* --------                                                                   */
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) */
5 /*                                                                            */
6 /* This is somehow the "libc" of SimGrid                                      */
7
8 /* Copyright (c) 2010-2015. The SimGrid Team.
9  * All rights reserved.                                                     */
10
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. */
13
14 #include <cmath>         /* std::isfinite() */
15
16 #include <functional>
17
18 #include <xbt/functional.hpp>
19
20 #include <simgrid/s4u/VirtualMachine.hpp>
21 #include <simgrid/simix/blocking_simcall.hpp>
22
23 #include "mc/mc.h"
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"
30 #include "xbt/ex.h"
31
32 #include <simgrid/simix.hpp>
33
34 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
35
36 #include "popping_bodies.cpp"
37
38 void simcall_call(smx_actor_t process)
39 {
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);
44   } else {
45     SIMIX_simcall_handle(&process->simcall, 0);
46   }
47 }
48
49 /**
50  * \ingroup simix_process_management
51  * \brief Creates a synchro that executes some computation of an host.
52  *
53  * This function creates a SURF action and allocates the data necessary
54  * to create the SIMIX synchro. It can raise a host_error exception if the host crashed.
55  *
56  * \param name Name of the execution synchro to create
57  * \param flops_amount amount Computation amount (in flops)
58  * \param priority computation priority
59  * \param bound
60  * \return A new SIMIX execution synchronization
61  */
62 smx_activity_t simcall_execution_start(const char *name,
63                                     double flops_amount,
64                                     double priority, double bound)
65 {
66   /* checking for infinite values */
67   xbt_assert(std::isfinite(flops_amount), "flops_amount is not finite!");
68   xbt_assert(std::isfinite(priority), "priority is not finite!");
69
70   return simcall_BODY_execution_start(name, flops_amount, priority, bound);
71 }
72
73 /**
74  * \ingroup simix_process_management
75  * \brief Creates a synchro that may involve parallel computation on
76  * several hosts and communication between them.
77  *
78  * \param name Name of the execution synchro to create
79  * \param host_nb Number of hosts where the synchro will be executed
80  * \param host_list Array (of size host_nb) of hosts where the synchro will be executed
81  * \param flops_amount Array (of size host_nb) of computation amount of hosts (in bytes)
82  * \param bytes_amount Array (of size host_nb * host_nb) representing the communication
83  * amount between each pair of hosts
84  * \param amount the SURF action amount
85  * \param rate the SURF action rate
86  * \param timeout timeout
87  * \return A new SIMIX execution synchronization
88  */
89 smx_activity_t simcall_execution_parallel_start(const char* name, int host_nb, sg_host_t* host_list,
90                                                 double* flops_amount, double* bytes_amount, double amount, double rate,
91                                                 double timeout)
92 {
93   int i,j;
94   /* checking for infinite values */
95   for (i = 0 ; i < host_nb ; ++i) {
96     xbt_assert(std::isfinite(flops_amount[i]), "flops_amount[%d] is not finite!", i);
97     if (bytes_amount != nullptr) {
98       for (j = 0 ; j < host_nb ; ++j) {
99         xbt_assert(std::isfinite(bytes_amount[i + host_nb * j]),
100                    "bytes_amount[%d+%d*%d] is not finite!", i, host_nb, j);
101       }
102     }
103   }
104
105   xbt_assert(std::isfinite(amount), "amount is not finite!");
106   xbt_assert(std::isfinite(rate), "rate is not finite!");
107
108   return simcall_BODY_execution_parallel_start(name, host_nb, host_list, flops_amount, bytes_amount, amount, rate,
109                                                timeout);
110 }
111
112 /**
113  * \ingroup simix_process_management
114  * \brief Cancels an execution synchro.
115  *
116  * This functions stops the execution. It calls a surf function.
117  * \param execution The execution synchro to cancel
118  */
119 void simcall_execution_cancel(smx_activity_t execution)
120 {
121   simcall_BODY_execution_cancel(execution);
122 }
123
124 /**
125  * \ingroup simix_process_management
126  * \brief Changes the priority of an execution synchro.
127  *
128  * This functions changes the priority only. It calls a surf function.
129  * \param execution The execution synchro
130  * \param priority The new priority
131  */
132 void simcall_execution_set_priority(smx_activity_t execution, double priority)
133 {
134   /* checking for infinite values */
135   xbt_assert(std::isfinite(priority), "priority is not finite!");
136
137   simcall_BODY_execution_set_priority(execution, priority);
138 }
139
140 /**
141  * \ingroup simix_process_management
142  * \brief Changes the capping (the maximum CPU utilization) of an execution synchro.
143  *
144  * This functions changes the capping only. It calls a surf function.
145  * \param execution The execution synchro
146  * \param bound The new bound
147  */
148 void simcall_execution_set_bound(smx_activity_t execution, double bound)
149 {
150   simcall_BODY_execution_set_bound(execution, bound);
151 }
152
153 /**
154  * \ingroup simix_host_management
155  * \brief Waits for the completion of an execution synchro and destroy it.
156  *
157  * \param execution The execution synchro
158  */
159 e_smx_state_t simcall_execution_wait(smx_activity_t execution)
160 {
161   return (e_smx_state_t) simcall_BODY_execution_wait(execution);
162 }
163
164 /**
165  * \ingroup simix_vm_management
166  * \brief Suspend the given VM
167  *
168  * \param vm VM
169  */
170 void simcall_vm_suspend(sg_host_t vm)
171 {
172   simcall_BODY_vm_suspend(vm);
173 }
174
175 /**
176  * \ingroup simix_vm_management
177  * \brief Resume the given VM
178  *
179  * \param vm VM
180  */
181 void simcall_vm_resume(sg_host_t vm)
182 {
183   simcall_BODY_vm_resume(vm);
184 }
185
186 /**
187  * \ingroup simix_vm_management
188  * \brief Save the given VM
189  *
190  * \param vm VM
191  */
192 void simcall_vm_save(sg_host_t vm)
193 {
194   simcall_BODY_vm_save(vm);
195 }
196
197 /**
198  * \ingroup simix_vm_management
199  * \brief Shutdown the given VM
200  *
201  * \param vm VM
202  */
203 void simcall_vm_shutdown(sg_host_t vm)
204 {
205   simcall_BODY_vm_shutdown(vm);
206 }
207
208 /**
209  * \ingroup simix_process_management
210  * \brief Kills a SIMIX process.
211  *
212  * This function simply kills a  process.
213  *
214  * \param process poor victim
215  */
216 void simcall_process_kill(smx_actor_t process)
217 {
218   simcall_BODY_process_kill(process);
219 }
220
221 /**
222  * \ingroup simix_process_management
223  * \brief Kills all SIMIX processes.
224  */
225 void simcall_process_killall(int reset_pid)
226 {
227   simcall_BODY_process_killall(reset_pid);
228 }
229
230 /**
231  * \ingroup simix_process_management
232  * \brief Cleans up a SIMIX process.
233  * \param process poor victim (must have already been killed)
234  */
235 void simcall_process_cleanup(smx_actor_t process)
236 {
237   simcall_BODY_process_cleanup(process);
238 }
239
240 /**
241  * \ingroup simix_process_management
242  * \brief Migrates an agent to another location.
243  *
244  * This function changes the value of the host on which \a process is running.
245  *
246  * \param process the process to migrate
247  * \param dest name of the new host
248  */
249 void simcall_process_set_host(smx_actor_t process, sg_host_t dest)
250 {
251   simcall_BODY_process_set_host(process, dest);
252 }
253
254 void simcall_process_join(smx_actor_t process, double timeout)
255 {
256   simcall_BODY_process_join(process, timeout);
257 }
258
259 /**
260  * \ingroup simix_process_management
261  * \brief Suspends a process.
262  *
263  * This function suspends the process by suspending the synchro
264  * it was waiting for completion.
265  *
266  * \param process a SIMIX process
267  */
268 void simcall_process_suspend(smx_actor_t process)
269 {
270   simcall_BODY_process_suspend(process);
271 }
272
273 /**
274  * \ingroup simix_process_management
275  * \brief Resumes a suspended process.
276  *
277  * This function resumes a suspended process by resuming the synchro
278  * it was waiting for completion.
279  *
280  * \param process a SIMIX process
281  */
282 void simcall_process_resume(smx_actor_t process)
283 {
284   simcall_BODY_process_resume(process);
285 }
286
287 /**
288  * \ingroup simix_process_management
289  * \brief Returns the amount of SIMIX processes in the system
290  *
291  * Maestro internal process is not counted, only user code processes are
292  */
293 int simcall_process_count()
294 {
295   return simgrid::simix::kernelImmediate(SIMIX_process_count);
296 }
297
298 /**
299  * \ingroup simix_process_management
300  * \brief Return the user data of a #smx_actor_t.
301  * \param process a SIMIX process
302  * \return the user data of this process
303  */
304 void* simcall_process_get_data(smx_actor_t process)
305 {
306   return SIMIX_process_get_data(process);
307 }
308
309 /**
310  * \ingroup simix_process_management
311  * \brief Set the user data of a #smx_actor_t.
312  *
313  * This functions sets the user data associated to \a process.
314  * \param process SIMIX process
315  * \param data User data
316  */
317 void simcall_process_set_data(smx_actor_t process, void *data)
318 {
319   simgrid::simix::kernelImmediate(std::bind(SIMIX_process_set_data, process, data));
320 }
321
322 /**
323  * \ingroup simix_process_management
324  * \brief Set the kill time of a process.
325  */
326 void simcall_process_set_kill_time(smx_actor_t process, double kill_time)
327 {
328
329   if (kill_time <= SIMIX_get_clock() || simix_global->kill_process_function == nullptr)
330     return;
331   XBT_DEBUG("Set kill time %f for process %s@%s", kill_time, process->cname(), process->host->cname());
332   process->kill_timer = SIMIX_timer_set(kill_time, [=] {
333     simix_global->kill_process_function(process);
334     process->kill_timer=nullptr;
335   });
336 }
337 /**
338  * \ingroup simix_process_management
339  * \brief Get the kill time of a process (or 0 if unset).
340  */
341 double simcall_process_get_kill_time(smx_actor_t process) {
342   return SIMIX_timer_get_date(process->kill_timer);
343 }
344
345 /**
346  * \ingroup simix_process_management
347  * \brief Returns true if the process is suspended .
348  *
349  * This checks whether a process is suspended or not by inspecting the task on which it was waiting for the completion.
350  * \param process SIMIX process
351  * \return 1, if the process is suspended, else 0.
352  */
353 int simcall_process_is_suspended(smx_actor_t process)
354 {
355   return simcall_BODY_process_is_suspended(process);
356 }
357
358 /**
359  * \ingroup simix_process_management
360  * \brief Return the properties
361  *
362  * This functions returns the properties associated with this process
363  */
364 xbt_dict_t simcall_process_get_properties(smx_actor_t process)
365 {
366   return SIMIX_process_get_properties(process);
367 }
368 /**
369  * \ingroup simix_process_management
370  * \brief Add an on_exit function
371  * Add an on_exit function which will be executed when the process exits/is killed.
372  */
373 XBT_PUBLIC(void) simcall_process_on_exit(smx_actor_t process, int_f_pvoid_pvoid_t fun, void *data)
374 {
375   simcall_BODY_process_on_exit(process, fun, data);
376 }
377 /**
378  * \ingroup simix_process_management
379  * \brief Sets the process to be auto-restarted or not by SIMIX when its host comes back up.
380  * Will restart the process when the host comes back up if auto_restart is set to 1.
381  */
382
383 XBT_PUBLIC(void) simcall_process_auto_restart_set(smx_actor_t process, int auto_restart)
384 {
385   simcall_BODY_process_auto_restart_set(process, auto_restart);
386 }
387
388 /**
389  * \ingroup simix_process_management
390  * \brief Restarts the process, killing it and starting it again from scratch.
391  */
392 XBT_PUBLIC(smx_actor_t) simcall_process_restart(smx_actor_t process)
393 {
394   return (smx_actor_t) simcall_BODY_process_restart(process);
395 }
396 /**
397  * \ingroup simix_process_management
398  * \brief Creates a new sleep SIMIX synchro.
399  *
400  * This function creates a SURF action and allocates the data necessary
401  * to create the SIMIX synchro. It can raise a host_error exception if the
402  * host crashed. The default SIMIX name of the synchro is "sleep".
403  *
404  *   \param duration Time duration of the sleep.
405  *   \return A result telling whether the sleep was successful
406  */
407 e_smx_state_t simcall_process_sleep(double duration)
408 {
409   /* checking for infinite values */
410   xbt_assert(std::isfinite(duration), "duration is not finite!");
411   return (e_smx_state_t) simcall_BODY_process_sleep(duration);
412 }
413
414 /**
415  *  \ingroup simix_mbox_management
416  *  \brief Creates a new rendez-vous point
417  *  \param name The name of the rendez-vous point
418  *  \return The created rendez-vous point
419  */
420 smx_mailbox_t simcall_mbox_create(const char *name)
421 {
422   return simcall_BODY_mbox_create(name);
423 }
424
425 void simcall_mbox_set_receiver(smx_mailbox_t mbox, smx_actor_t process)
426 {
427   simcall_BODY_mbox_set_receiver(mbox, process);
428 }
429
430 /**
431  * \ingroup simix_comm_management
432  */
433 void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate,
434                          void *src_buff, size_t src_buff_size,
435                          int (*match_fun)(void *, void *, smx_activity_t),
436                          void (*copy_data_fun)(smx_activity_t, void*, size_t), void *data,
437                          double timeout)
438 {
439   /* checking for infinite values */
440   xbt_assert(std::isfinite(task_size), "task_size is not finite!");
441   xbt_assert(std::isfinite(rate), "rate is not finite!");
442   xbt_assert(std::isfinite(timeout), "timeout is not finite!");
443
444   xbt_assert(mbox, "No rendez-vous point defined for send");
445
446   if (MC_is_active() || MC_record_replay_is_active()) {
447     /* the model-checker wants two separate simcalls */
448     smx_activity_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
449     comm = simcall_comm_isend(sender, mbox, task_size, rate,
450         src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0);
451     simcall_comm_wait(comm, timeout);
452     comm = nullptr;
453   }
454   else {
455     simcall_BODY_comm_send(sender, mbox, task_size, rate, src_buff, src_buff_size,
456                          match_fun, copy_data_fun, data, timeout);
457   }
458 }
459
460 /**
461  * \ingroup simix_comm_management
462  */
463 smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate,
464                               void *src_buff, size_t src_buff_size,
465                               int (*match_fun)(void *, void *, smx_activity_t),
466                               void (*clean_fun)(void *),
467                               void (*copy_data_fun)(smx_activity_t, void*, size_t),
468                               void *data,
469                               int detached)
470 {
471   /* checking for infinite values */
472   xbt_assert(std::isfinite(task_size), "task_size is not finite!");
473   xbt_assert(std::isfinite(rate), "rate is not finite!");
474
475   xbt_assert(mbox, "No rendez-vous point defined for isend");
476
477   return simcall_BODY_comm_isend(sender, mbox, task_size, rate, src_buff,
478                                  src_buff_size, match_fun,
479                                  clean_fun, copy_data_fun, data, detached);
480 }
481
482 /**
483  * \ingroup simix_comm_management
484  */
485 void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t * dst_buff_size,
486                        int (*match_fun)(void *, void *, smx_activity_t),
487                        void (*copy_data_fun)(smx_activity_t, void*, size_t),
488                        void *data, double timeout, double rate)
489 {
490   xbt_assert(std::isfinite(timeout), "timeout is not finite!");
491   xbt_assert(mbox, "No rendez-vous point defined for recv");
492
493   if (MC_is_active() || MC_record_replay_is_active()) {
494     /* the model-checker wants two separate simcalls */
495     smx_activity_t comm = nullptr; /* MC needs the comm to be set to nullptr during the simcall */
496     comm = simcall_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
497                               match_fun, copy_data_fun, data, rate);
498     simcall_comm_wait(comm, timeout);
499     comm = nullptr;
500   }
501   else {
502     simcall_BODY_comm_recv(receiver, mbox, dst_buff, dst_buff_size,
503                            match_fun, copy_data_fun, data, timeout, rate);
504   }
505 }
506 /**
507  * \ingroup simix_comm_management
508  */
509 smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size,
510                                 int (*match_fun)(void *, void *, smx_activity_t),
511                                 void (*copy_data_fun)(smx_activity_t, void*, size_t),
512                                 void *data, double rate)
513 {
514   xbt_assert(mbox, "No rendez-vous point defined for irecv");
515
516   return simcall_BODY_comm_irecv(receiver, mbox, dst_buff, dst_buff_size,
517                                  match_fun, copy_data_fun, data, rate);
518 }
519
520 /**
521  * \ingroup simix_comm_management
522  */
523 smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag,
524                                 int (*match_fun)(void *, void *, smx_activity_t), void *data)
525 {
526   xbt_assert(mbox, "No rendez-vous point defined for iprobe");
527
528   return simcall_BODY_comm_iprobe(mbox, type, src, tag, match_fun, data);
529 }
530
531 /**
532  * \ingroup simix_comm_management
533  */
534 void simcall_comm_cancel(smx_activity_t synchro)
535 {
536   simgrid::simix::kernelImmediate([synchro]{
537     simgrid::kernel::activity::Comm *comm = static_cast<simgrid::kernel::activity::Comm*>(synchro);
538     comm->cancel();
539   });
540 }
541
542 /**
543  * \ingroup simix_comm_management
544  */
545 unsigned int simcall_comm_waitany(xbt_dynar_t comms, double timeout)
546 {
547   return simcall_BODY_comm_waitany(comms, timeout);
548 }
549
550 /**
551  * \ingroup simix_comm_management
552  */
553 int simcall_comm_testany(smx_activity_t* comms, size_t count)
554 {
555   if (count == 0)
556     return -1;
557   return simcall_BODY_comm_testany(comms, count);
558 }
559
560 /**
561  * \ingroup simix_comm_management
562  */
563 void simcall_comm_wait(smx_activity_t comm, double timeout)
564 {
565   xbt_assert(std::isfinite(timeout), "timeout is not finite!");
566   simcall_BODY_comm_wait(comm, timeout);
567 }
568
569 /**
570  * \brief Set the category of an synchro.
571  *
572  * This functions changes the category only. It calls a surf function.
573  * \param execution The execution synchro
574  * \param category The tracing category
575  */
576 void simcall_set_category(smx_activity_t synchro, const char *category)
577 {
578   if (category == nullptr) {
579     return;
580   }
581   simcall_BODY_set_category(synchro, category);
582 }
583
584 /**
585  * \ingroup simix_comm_management
586  *
587  */
588 int simcall_comm_test(smx_activity_t comm)
589 {
590   return simcall_BODY_comm_test(comm);
591 }
592
593 /**
594  * \ingroup simix_synchro_management
595  *
596  */
597 smx_mutex_t simcall_mutex_init()
598 {
599   if(!simix_global) {
600     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
601     xbt_abort();
602   }
603   return simcall_BODY_mutex_init();
604 }
605
606 /**
607  * \ingroup simix_synchro_management
608  *
609  */
610 void simcall_mutex_lock(smx_mutex_t mutex)
611 {
612   simcall_BODY_mutex_lock(mutex);
613 }
614
615 /**
616  * \ingroup simix_synchro_management
617  *
618  */
619 int simcall_mutex_trylock(smx_mutex_t mutex)
620 {
621   return simcall_BODY_mutex_trylock(mutex);
622 }
623
624 /**
625  * \ingroup simix_synchro_management
626  *
627  */
628 void simcall_mutex_unlock(smx_mutex_t mutex)
629 {
630   simcall_BODY_mutex_unlock(mutex);
631 }
632
633 /**
634  * \ingroup simix_synchro_management
635  *
636  */
637 smx_cond_t simcall_cond_init()
638 {
639   return simcall_BODY_cond_init();
640 }
641
642 /**
643  * \ingroup simix_synchro_management
644  *
645  */
646 void simcall_cond_signal(smx_cond_t cond)
647 {
648   simcall_BODY_cond_signal(cond);
649 }
650
651 /**
652  * \ingroup simix_synchro_management
653  *
654  */
655 void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex)
656 {
657   simcall_BODY_cond_wait(cond, mutex);
658 }
659
660 /**
661  * \ingroup simix_synchro_management
662  *
663  */
664 void simcall_cond_wait_timeout(smx_cond_t cond,
665                                  smx_mutex_t mutex,
666                                  double timeout)
667 {
668   xbt_assert(std::isfinite(timeout), "timeout is not finite!");
669   simcall_BODY_cond_wait_timeout(cond, mutex, timeout);
670 }
671
672 /**
673  * \ingroup simix_synchro_management
674  *
675  */
676 void simcall_cond_broadcast(smx_cond_t cond)
677 {
678   simcall_BODY_cond_broadcast(cond);
679 }
680
681 /**
682  * \ingroup simix_synchro_management
683  *
684  */
685 smx_sem_t simcall_sem_init(int capacity)
686 {
687   return simcall_BODY_sem_init(capacity);
688 }
689
690 /**
691  * \ingroup simix_synchro_management
692  *
693  */
694 void simcall_sem_release(smx_sem_t sem)
695 {
696   simcall_BODY_sem_release(sem);
697 }
698
699 /**
700  * \ingroup simix_synchro_management
701  *
702  */
703 int simcall_sem_would_block(smx_sem_t sem)
704 {
705   return simcall_BODY_sem_would_block(sem);
706 }
707
708 /**
709  * \ingroup simix_synchro_management
710  *
711  */
712 void simcall_sem_acquire(smx_sem_t sem)
713 {
714   simcall_BODY_sem_acquire(sem);
715 }
716
717 /**
718  * \ingroup simix_synchro_management
719  *
720  */
721 void simcall_sem_acquire_timeout(smx_sem_t sem, double timeout)
722 {
723   xbt_assert(std::isfinite(timeout), "timeout is not finite!");
724   simcall_BODY_sem_acquire_timeout(sem, timeout);
725 }
726
727 /**
728  * \ingroup simix_synchro_management
729  *
730  */
731 int simcall_sem_get_capacity(smx_sem_t sem)
732 {
733   return simcall_BODY_sem_get_capacity(sem);
734 }
735
736 /**
737  * \ingroup simix_file_management
738  *
739  */
740 sg_size_t simcall_file_read(smx_file_t fd, sg_size_t size, sg_host_t host)
741 {
742   return simcall_BODY_file_read(fd, size, host);
743 }
744
745 /**
746  * \ingroup simix_file_management
747  *
748  */
749 sg_size_t simcall_file_write(smx_file_t fd, sg_size_t size, sg_host_t host)
750 {
751   return simcall_BODY_file_write(fd, size, host);
752 }
753
754 /**
755  * \ingroup simix_file_management
756  * \brief
757  */
758 smx_file_t simcall_file_open(const char* fullpath, sg_host_t host)
759 {
760   return simcall_BODY_file_open(fullpath, host);
761 }
762
763 /**
764  * \ingroup simix_file_management
765  *
766  */
767 int simcall_file_close(smx_file_t fd, sg_host_t host)
768 {
769   return simcall_BODY_file_close(fd, host);
770 }
771
772 /**
773  * \ingroup simix_file_management
774  *
775  */
776 int simcall_file_unlink(smx_file_t fd, sg_host_t host)
777 {
778   return simcall_BODY_file_unlink(fd, host);
779 }
780
781 /**
782  * \ingroup simix_file_management
783  *
784  */
785 sg_size_t simcall_file_get_size(smx_file_t fd){
786   return simcall_BODY_file_get_size(fd);
787 }
788
789 /**
790  * \ingroup simix_file_management
791  *
792  */
793 sg_size_t simcall_file_tell(smx_file_t fd){
794   return simcall_BODY_file_tell(fd);
795 }
796
797 /**
798  * \ingroup simix_file_management
799  *
800  */
801 xbt_dynar_t simcall_file_get_info(smx_file_t fd)
802 {
803   return simcall_BODY_file_get_info(fd);
804 }
805
806 /**
807  * \ingroup simix_file_management
808  *
809  */
810 int simcall_file_seek(smx_file_t fd, sg_offset_t offset, int origin){
811   return simcall_BODY_file_seek(fd, offset, origin);
812 }
813
814 /**
815  * \ingroup simix_file_management
816  * \brief Move a file to another location on the *same mount point*.
817  *
818  */
819 int simcall_file_move(smx_file_t fd, const char* fullpath)
820 {
821   return simcall_BODY_file_move(fd, fullpath);
822 }
823
824 /**
825  * \ingroup simix_storage_management
826  * \brief Returns the free space size on a given storage element.
827  * \param storage a storage
828  * \return Return the free space size on a given storage element (as sg_size_t)
829  */
830 sg_size_t simcall_storage_get_free_size (smx_storage_t storage){
831   return simcall_BODY_storage_get_free_size(storage);
832 }
833
834 /**
835  * \ingroup simix_storage_management
836  * \brief Returns the used space size on a given storage element.
837  * \param storage a storage
838  * \return Return the used space size on a given storage element (as sg_size_t)
839  */
840 sg_size_t simcall_storage_get_used_size (smx_storage_t storage){
841   return simcall_BODY_storage_get_used_size(storage);
842 }
843
844 /**
845  * \ingroup simix_storage_management
846  * \brief Returns a dict of the properties assigned to a storage element.
847  *
848  * \param storage A storage element
849  * \return The properties of this storage element
850  */
851 xbt_dict_t simcall_storage_get_properties(smx_storage_t storage)
852 {
853   return simcall_BODY_storage_get_properties(storage);
854 }
855
856 /**
857  * \ingroup simix_storage_management
858  * \brief Returns a dict containing the content of a storage element.
859  *
860  * \param storage A storage element
861  * \return The content of this storage element as a dict (full path file => size)
862  */
863 xbt_dict_t simcall_storage_get_content(smx_storage_t storage)
864 {
865   return simcall_BODY_storage_get_content(storage);
866 }
867
868 void simcall_run_kernel(std::function<void()> const& code)
869 {
870   simcall_BODY_run_kernel(&code);
871 }
872
873 void simcall_run_blocking(std::function<void()> const& code)
874 {
875   simcall_BODY_run_blocking(&code);
876 }
877
878 int simcall_mc_random(int min, int max) {
879   return simcall_BODY_mc_random(min, max);
880 }
881
882 /* ************************************************************************** */
883
884 /** @brief returns a printable string representing a simcall */
885 const char *SIMIX_simcall_name(e_smx_simcall_t kind) {
886   return simcall_names[kind];
887 }
888
889 namespace simgrid {
890 namespace simix {
891
892 void unblock(smx_actor_t process)
893 {
894   xbt_assert(SIMIX_is_maestro());
895   SIMIX_simcall_answer(&process->simcall);
896 }
897
898 }
899 }