Logo AND Algorithmique Numérique Distribuée

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