Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'toufic' of github.com:Takishipp/simgrid
[simgrid.git] / include / simgrid / msg.h
1 /* Copyright (c) 2004-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef MSG_H
8 #define MSG_H
9
10 #include "xbt.h"
11 #include "xbt/lib.h"
12 #include "simgrid/forward.h"
13 #include "simgrid/simix.h"
14
15 SG_BEGIN_DECL()
16
17 /* *************************** Network Zones ******************************** */
18 #define msg_as_t msg_netzone_t /* portability macro */
19 typedef s4u_NetZone* msg_netzone_t;
20
21 /* ******************************** Host ************************************ */
22
23 /** @brief Host datatype.
24     @ingroup m_host_management
25
26     A <em>location</em> (or <em>host</em>) is any possible place where
27     a process may run. Thus it is represented as a <em>physical
28     resource with computing capabilities</em>, some <em>mailboxes</em>
29     to enable running process to communicate with remote ones, and
30     some <em>private data</em> that can be only accessed by local
31     process.
32  */
33 typedef sg_host_t msg_host_t;
34
35
36 XBT_PUBLIC_DATA(int) sg_storage_max_file_descriptors;
37 /* ******************************** Task ************************************ */
38
39 typedef struct simdata_task *simdata_task_t;
40
41 typedef struct msg_task {
42   char *name;                   /**< @brief task name if any */
43   simdata_task_t simdata;       /**< @brief simulator data */
44   void *data;                   /**< @brief user data */
45   long long int counter;        /* task unique identifier for instrumentation */
46   char *category;               /* task category for instrumentation */
47 } s_msg_task_t;
48
49 /** @brief Task datatype.
50     @ingroup m_task_management
51
52     A <em>task</em> may then be defined by a <em>computing
53     amount</em>, a <em>message size</em> and some <em>private
54     data</em>.
55  */
56 typedef struct msg_task *msg_task_t;
57
58 /* ******************************** VM ************************************* */
59 typedef msg_host_t msg_vm_t;
60
61 /* ******************************** File ************************************ */
62
63 typedef struct simdata_file* simdata_file_t;
64
65 typedef struct msg_file_priv {
66   char *fullpath;
67   sg_size_t size;
68   char* mount_point;
69   char* storageId;
70   char* storage_type;
71   char* content_type;
72   int desc_id;
73   void *data;
74   simdata_file_t simdata;
75 } s_msg_file_priv_t;
76
77 typedef struct msg_file_priv* msg_file_t;
78
79 /* ******************************** Storage ************************************ */
80 /* TODO: PV: to comment */
81
82 extern int MSG_STORAGE_LEVEL;
83
84 /** @brief Storage datatype.
85  *  @ingroup msg_storage_management
86  *
87  *  You should consider this as an opaque object.
88  */
89 typedef xbt_dictelm_t msg_storage_t;
90
91 struct msg_storage_priv  {
92   const char* name;
93   const char* hostname;
94   sg_size_t size;
95   void* data;
96 };
97 typedef struct msg_storage_priv  s_msg_storage_priv_t;
98 typedef struct msg_storage_priv* msg_storage_priv_t;
99
100 static inline msg_storage_priv_t MSG_storage_priv(msg_storage_t storage){
101   return (msg_storage_priv_t )xbt_lib_get_level(storage, MSG_STORAGE_LEVEL);
102 }
103
104 /**
105  * \brief @brief Communication action.
106  * \ingroup msg_task_usage
107  *
108  * Object representing an ongoing communication between processes. Such beast is usually obtained by using #MSG_task_isend, #MSG_task_irecv or friends.
109  */
110 typedef struct msg_comm *msg_comm_t;
111
112 /** \brief Default value for an uninitialized #msg_task_t.
113     \ingroup m_task_management
114 */
115 #define MSG_TASK_UNINITIALIZED NULL
116
117 /* ****************************** Process *********************************** */
118
119 /** @brief Process datatype.
120     @ingroup m_process_management
121
122     A process may be defined as a <em>code</em>, with some
123     <em>private data</em>, executing in a <em>location</em>.
124
125     You should not access directly to the fields of the pointed
126     structure, but always use the provided API to interact with
127     processes.
128  */
129 typedef s4u_Actor* msg_process_t;
130
131 /** @brief Return code of most MSG functions
132     @ingroup msg_simulation
133     @{ */
134 /* Keep these code as binary values: java bindings manipulate | of these values */
135 typedef enum {
136   MSG_OK = 0,                 /**< @brief Everything is right. Keep on going this way ! */
137   MSG_TIMEOUT = 1,            /**< @brief nothing good happened before the timer you provided elapsed */
138   MSG_TRANSFER_FAILURE = 2,   /**< @brief There has been a problem during you task
139       transfer. Either the network is down or the remote host has been
140       shutdown. */
141   MSG_HOST_FAILURE = 4,       /**< @brief System shutdown. The host on which you are
142       running has just been rebooted. Free your datastructures and
143       return now !*/
144   MSG_TASK_CANCELED = 8      /**< @brief Canceled task. This task has been canceled by somebody!*/
145 } msg_error_t;
146 /** @} */
147
148 /************************** Global ******************************************/
149 XBT_PUBLIC(void) MSG_config(const char *key, const char *value);
150 /** \ingroup msg_simulation
151  *  \brief Initialize the MSG internal data.
152  *  \hideinitializer
153  *
154  *  It also check that the link-time and compile-time versions of SimGrid do
155  *  match, so you should use this version instead of the #MSG_init_nocheck
156  *  function that does the same initializations, but without this check.
157  *
158  *  We allow to link against compiled versions that differ in the patch level.
159  */
160 #define MSG_init(argc,argv)  do {                                                          \
161   sg_version_check(SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);\
162     MSG_init_nocheck(argc,argv);                                                        \
163   } while (0)
164
165 XBT_PUBLIC(void) MSG_init_nocheck(int *argc, char **argv);
166 XBT_PUBLIC(msg_error_t) MSG_main();;
167 XBT_PUBLIC(void) MSG_function_register(const char *name,
168                                        xbt_main_func_t code);
169 XBT_PUBLIC(void) MSG_function_register_default(xbt_main_func_t code);
170 XBT_PUBLIC(void) MSG_launch_application(const char *file);
171 /*Bypass the parser */
172 XBT_PUBLIC(void) MSG_set_function(const char *host_id,
173                                   const char *function_name,
174                                   xbt_dynar_t arguments);
175
176 XBT_PUBLIC(double) MSG_get_clock();
177 XBT_PUBLIC(unsigned long int) MSG_get_sent_msg();
178
179 /************************** Environment ***********************************/
180 XBT_PUBLIC(msg_netzone_t) MSG_environment_get_routing_root();
181 XBT_PUBLIC(const char*) MSG_environment_as_get_name(msg_netzone_t as);
182 XBT_PUBLIC(msg_netzone_t) MSG_environment_as_get_by_name(const char* name);
183 XBT_PUBLIC(xbt_dict_t) MSG_environment_as_get_routing_sons(msg_netzone_t as);
184 XBT_PUBLIC(const char*) MSG_environment_as_get_property_value(msg_netzone_t as, const char* name);
185 XBT_PUBLIC(void) MSG_environment_as_set_property_value(msg_netzone_t netzone, const char* name, char* value);
186 XBT_PUBLIC(xbt_dynar_t) MSG_environment_as_get_hosts(msg_netzone_t as);
187
188 /************************** File handling ***********************************/
189 XBT_PUBLIC(sg_size_t) MSG_file_read(msg_file_t fd, sg_size_t size);
190 XBT_PUBLIC(sg_size_t) MSG_file_write(msg_file_t fd, sg_size_t size);
191 XBT_PUBLIC(msg_file_t) MSG_file_open(const char* fullpath, void* data);
192 XBT_PUBLIC(void*) MSG_file_get_data(msg_file_t fd);
193 XBT_PUBLIC(msg_error_t) MSG_file_set_data(msg_file_t fd, void * data);
194 XBT_PUBLIC(int) MSG_file_close(msg_file_t fd);
195 XBT_PUBLIC(sg_size_t) MSG_file_get_size(msg_file_t fd);
196 XBT_PUBLIC(void) MSG_file_dump(msg_file_t fd);
197 XBT_PUBLIC(msg_error_t) MSG_file_unlink(msg_file_t fd);
198 XBT_PUBLIC(msg_error_t) MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin);
199 XBT_PUBLIC(sg_size_t) MSG_file_tell (msg_file_t fd);
200 XBT_PUBLIC(void) __MSG_file_get_info(msg_file_t fd);
201 XBT_PUBLIC(const char *) MSG_file_get_name(msg_file_t file);
202 XBT_PUBLIC(msg_error_t) MSG_file_move(msg_file_t fd, const char* fullpath);
203 XBT_PUBLIC(msg_error_t) MSG_file_rcopy(msg_file_t fd, msg_host_t host, const char* fullpath);
204 XBT_PUBLIC(msg_error_t) MSG_file_rmove(msg_file_t fd, msg_host_t host, const char* fullpath);
205 /************************** Storage handling ***********************************/
206 XBT_PUBLIC(const char *) MSG_storage_get_name(msg_storage_t storage);
207 XBT_PUBLIC(sg_size_t) MSG_storage_get_free_size(msg_storage_t storage);
208 XBT_PUBLIC(sg_size_t) MSG_storage_get_used_size(msg_storage_t storage);
209 XBT_PUBLIC(msg_storage_t) MSG_storage_get_by_name(const char *name);
210 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage);
211 XBT_PUBLIC(void) MSG_storage_set_property_value(msg_storage_t storage, const char* name, char* value);
212 XBT_PUBLIC(const char *)MSG_storage_get_property_value(msg_storage_t storage, const char *name);
213 XBT_PUBLIC(xbt_dynar_t) MSG_storages_as_dynar();
214 XBT_PUBLIC(msg_error_t) MSG_storage_set_data(msg_storage_t host, void *data);
215 XBT_PUBLIC(void *) MSG_storage_get_data(msg_storage_t storage);
216 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage);
217 XBT_PUBLIC(sg_size_t) MSG_storage_get_size(msg_storage_t storage);
218 XBT_PUBLIC(const char *) MSG_storage_get_host(msg_storage_t storage);
219
220 /************************** Host handling ***********************************/
221 XBT_PUBLIC(msg_host_t) MSG_host_by_name(const char *name);
222 #define MSG_get_host_by_name(n) MSG_host_by_name(n) /* Rewrite the old name into the new one transparently */
223 XBT_PUBLIC(msg_error_t) MSG_host_set_data(msg_host_t host, void *data);
224 XBT_PUBLIC(void *) MSG_host_get_data(msg_host_t host);
225 /** \ingroup m_host_management
226  *
227  * \brief Return the name of the #msg_host_t. */
228 #define MSG_host_get_name(host) sg_host_get_name(host)
229 XBT_PUBLIC(void) MSG_host_on(msg_host_t host);
230 XBT_PUBLIC(void) MSG_host_off(msg_host_t host);
231 XBT_PUBLIC(msg_host_t) MSG_host_self();
232 XBT_PUBLIC(double) MSG_host_get_speed(msg_host_t h);
233 XBT_PUBLIC(int) MSG_host_get_core_number(msg_host_t h);
234 XBT_PUBLIC(void) MSG_host_get_process_list(msg_host_t h, xbt_dynar_t whereto);
235 XBT_PUBLIC(int) MSG_host_is_on(msg_host_t h);
236 XBT_PUBLIC(int) MSG_host_is_off(msg_host_t h);
237
238 XBT_PUBLIC(double) MSG_get_host_speed(msg_host_t h); /* deprecated */
239
240 XBT_PUBLIC(double) MSG_host_get_power_peak_at(msg_host_t h, int pstate);
241 #define MSG_host_get_current_power_peak(h) MSG_host_get_speed(h) /* deprecated */
242 XBT_PUBLIC(int)    MSG_host_get_nb_pstates(msg_host_t h);
243 #define MSG_host_get_pstate(h)         sg_host_get_pstate(h)         /* deprecated */
244 #define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate) /* deprecated */
245 XBT_PUBLIC(xbt_dynar_t) MSG_hosts_as_dynar();
246 XBT_PUBLIC(int) MSG_get_host_number();
247 XBT_PUBLIC(xbt_dict_t) MSG_host_get_mounted_storage_list(msg_host_t host);
248 XBT_PUBLIC(xbt_dynar_t) MSG_host_get_attached_storage_list(msg_host_t host);
249 XBT_PUBLIC(xbt_dict_t) MSG_host_get_storage_content(msg_host_t host);
250
251 /*property handlers*/
252 XBT_PUBLIC(xbt_dict_t) MSG_host_get_properties(msg_host_t host);
253 XBT_PUBLIC(const char *) MSG_host_get_property_value(msg_host_t host,
254                                                      const char *name);
255 XBT_PUBLIC(void) MSG_host_set_property_value(msg_host_t host, const char* name, char* value);
256
257 XBT_PUBLIC(void) MSG_create_environment(const char *file);
258
259 /************************** Process handling *********************************/
260 XBT_PUBLIC(msg_process_t) MSG_process_create(const char *name,
261                                            xbt_main_func_t code,
262                                            void *data, msg_host_t host);
263 XBT_PUBLIC(msg_process_t)
264 MSG_process_create_with_arguments(const char* name, xbt_main_func_t code, void* data, msg_host_t host, int argc,
265                                   char** argv);
266 XBT_PUBLIC(msg_process_t)
267 MSG_process_create_with_environment(const char* name, xbt_main_func_t code, void* data, msg_host_t host, int argc,
268                                     char** argv, xbt_dict_t properties);
269
270 XBT_PUBLIC(msg_process_t) MSG_process_attach(const char* name, void* data, msg_host_t host, xbt_dict_t properties);
271 XBT_PUBLIC(void) MSG_process_detach();
272
273 XBT_PUBLIC(void) MSG_process_kill(msg_process_t process);
274 XBT_PUBLIC(int) MSG_process_killall(int reset_PIDs);
275 XBT_PUBLIC(msg_error_t) MSG_process_migrate(msg_process_t process, msg_host_t host);
276 XBT_PUBLIC(void) MSG_process_yield();
277
278 XBT_PUBLIC(void *) MSG_process_get_data(msg_process_t process);
279 XBT_PUBLIC(msg_error_t) MSG_process_set_data(msg_process_t process,
280                                              void *data);
281 XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
282 XBT_PUBLIC(msg_host_t) MSG_process_get_host(msg_process_t process);
283 XBT_PUBLIC(msg_process_t) MSG_process_from_PID(int PID);
284 XBT_PUBLIC(int) MSG_process_get_PID(msg_process_t process);
285 XBT_PUBLIC(int) MSG_process_get_PPID(msg_process_t process);
286 XBT_PUBLIC(const char *) MSG_process_get_name(msg_process_t process);
287 XBT_PUBLIC(int) MSG_process_self_PID();
288 XBT_PUBLIC(int) MSG_process_self_PPID();
289 XBT_PUBLIC(msg_process_t) MSG_process_self();
290 XBT_PUBLIC(xbt_dynar_t) MSG_processes_as_dynar();
291 XBT_PUBLIC(int) MSG_process_get_number();
292
293 XBT_PUBLIC(msg_error_t) MSG_process_set_kill_time(msg_process_t process, double kill_time);
294
295 /*property handlers*/
296 XBT_PUBLIC(xbt_dict_t) MSG_process_get_properties(msg_process_t process);
297 XBT_PUBLIC(const char *) MSG_process_get_property_value(msg_process_t
298                                                         process,
299                                                         const char *name);
300
301 XBT_PUBLIC(msg_error_t) MSG_process_suspend(msg_process_t process);
302 XBT_PUBLIC(msg_error_t) MSG_process_resume(msg_process_t process);
303 XBT_PUBLIC(int) MSG_process_is_suspended(msg_process_t process);
304 XBT_PUBLIC(void) MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void *data);
305 XBT_PUBLIC(void) MSG_process_auto_restart_set(msg_process_t process, int auto_restart);
306
307 XBT_PUBLIC(void) MSG_process_daemonize(msg_process_t process);
308 XBT_PUBLIC(msg_process_t) MSG_process_restart(msg_process_t process);
309 XBT_PUBLIC(void) MSG_process_ref(msg_process_t process);
310 XBT_PUBLIC(void) MSG_process_unref(msg_process_t process);
311
312 /************************** Task handling ************************************/
313 XBT_PUBLIC(msg_task_t) MSG_task_create(const char *name,
314                                      double flops_amount,
315                                      double bytes_amount, void *data);
316 XBT_PUBLIC(msg_task_t) MSG_parallel_task_create(const char *name,
317                                               int host_nb,
318                                               const msg_host_t * host_list,
319                                               double *flops_amount,
320                                               double *bytes_amount,
321                                               void *data);
322 XBT_PUBLIC(void *) MSG_task_get_data(msg_task_t task);
323 XBT_PUBLIC(void) MSG_task_set_data(msg_task_t task, void *data);
324 XBT_PUBLIC(void) MSG_task_set_copy_callback(void (*callback) (
325     msg_task_t task, msg_process_t src, msg_process_t dst));
326 XBT_PUBLIC(msg_process_t) MSG_task_get_sender(msg_task_t task);
327 XBT_PUBLIC(msg_host_t) MSG_task_get_source(msg_task_t task);
328 XBT_PUBLIC(const char *) MSG_task_get_name(msg_task_t task);
329 XBT_PUBLIC(void) MSG_task_set_name(msg_task_t task, const char *name);
330 XBT_PUBLIC(msg_error_t) MSG_task_cancel(msg_task_t task);
331 XBT_PUBLIC(msg_error_t) MSG_task_destroy(msg_task_t task);
332
333 XBT_PUBLIC(msg_error_t) MSG_task_execute(msg_task_t task);
334 XBT_PUBLIC(msg_error_t) MSG_parallel_task_execute(msg_task_t task);
335 XBT_PUBLIC(msg_error_t) MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeout);
336 XBT_PUBLIC(void) MSG_task_set_priority(msg_task_t task, double priority);
337 XBT_PUBLIC(void) MSG_task_set_bound(msg_task_t task, double bound);
338
339 XBT_PUBLIC(msg_error_t) MSG_process_join(msg_process_t process, double timeout);
340 XBT_PUBLIC(msg_error_t) MSG_process_sleep(double nb_sec);
341
342 XBT_PUBLIC(void) MSG_task_set_flops_amount(msg_task_t task,
343                                                double flops_amount);
344 XBT_PUBLIC(double) MSG_task_get_flops_amount(msg_task_t task);
345 XBT_PUBLIC(void) MSG_task_set_bytes_amount(msg_task_t task,
346                                         double bytes_amount);
347
348 XBT_PUBLIC(double) MSG_task_get_remaining_communication(msg_task_t task);
349 XBT_PUBLIC(int) MSG_task_is_latency_bounded(msg_task_t task);
350 XBT_PUBLIC(double) MSG_task_get_bytes_amount(msg_task_t task);
351
352
353 XBT_PUBLIC(msg_error_t)
354     MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout,
355                      msg_host_t host);
356
357 XBT_PUBLIC(msg_error_t)
358     MSG_task_receive_with_timeout(msg_task_t * task, const char *alias,
359                               double timeout);
360
361 XBT_PUBLIC(msg_error_t)
362     MSG_task_receive(msg_task_t * task, const char *alias);
363 #define MSG_task_recv(t,a) MSG_task_receive(t,a)
364
365
366
367 XBT_PUBLIC(msg_error_t)
368     MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout,
369                      msg_host_t host, double rate);
370
371 XBT_PUBLIC(msg_error_t) MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias,  double timeout, double rate);
372 XBT_PUBLIC(msg_error_t) MSG_task_receive_bounded(msg_task_t * task, const char *alias,double rate);
373 #define MSG_task_recv_bounded(t,a,r) MSG_task_receive_bounded(t,a,r)
374
375 XBT_PUBLIC(msg_comm_t) MSG_task_isend(msg_task_t task, const char *alias);
376 XBT_PUBLIC(msg_comm_t) MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate);
377 XBT_PUBLIC(msg_comm_t) MSG_task_isend_with_matching(msg_task_t task, const char *alias,
378     int (*match_fun)(void*,void*, smx_activity_t), void *match_data);
379
380 XBT_PUBLIC(void) MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup);
381 XBT_PUBLIC(void) MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate);
382 XBT_PUBLIC(msg_comm_t) MSG_task_irecv(msg_task_t * task, const char *alias);
383 XBT_PUBLIC(msg_comm_t) MSG_task_irecv_bounded(msg_task_t * task, const char *alias, double rate);
384 XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm);
385 XBT_PUBLIC(int) MSG_comm_testany(xbt_dynar_t comms);
386 XBT_PUBLIC(void) MSG_comm_destroy(msg_comm_t comm);
387 XBT_PUBLIC(msg_error_t) MSG_comm_wait(msg_comm_t comm, double timeout);
388 XBT_PUBLIC(void) MSG_comm_waitall(msg_comm_t * comm, int nb_elem, double timeout);
389 XBT_PUBLIC(int) MSG_comm_waitany(xbt_dynar_t comms);
390 XBT_PUBLIC(msg_task_t) MSG_comm_get_task(msg_comm_t comm);
391 XBT_PUBLIC(msg_error_t) MSG_comm_get_status(msg_comm_t comm);
392
393 XBT_PUBLIC(int) MSG_task_listen(const char *alias);
394 XBT_PUBLIC(msg_error_t) MSG_task_send_with_timeout(msg_task_t task, const char *alias, double timeout);
395 XBT_PUBLIC(msg_error_t) MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias, double timeout, double maxrate);
396 XBT_PUBLIC(msg_error_t) MSG_task_send(msg_task_t task, const char *alias);
397 XBT_PUBLIC(msg_error_t) MSG_task_send_bounded(msg_task_t task, const char *alias, double rate);
398 XBT_PUBLIC(int) MSG_task_listen_from(const char *alias);
399 XBT_PUBLIC(void) MSG_task_set_category (msg_task_t task, const char *category);
400 XBT_PUBLIC(const char *) MSG_task_get_category (msg_task_t task);
401
402 /************************** Mailbox handling ************************************/
403
404 /* @brief MSG_mailbox_set_async - set a mailbox as eager
405  * Sets the mailbox to a permanent receiver mode. Messages sent to this mailbox will then be sent just after the send
406  * is issued, without waiting for the corresponding receive.
407  * This call should be done before issuing any receive, and on the receiver's side only
408  * @param alias    The alias of the mailbox to modify.
409  */
410 XBT_PUBLIC(void) MSG_mailbox_set_async(const char *alias);
411
412 /************************** Action handling **********************************/
413 XBT_PUBLIC(msg_error_t) MSG_action_trace_run(char *path);
414 XBT_PUBLIC(void) MSG_action_init();
415 XBT_PUBLIC(void) MSG_action_exit();
416
417 /** @brief Opaque type representing a semaphore
418  *  @ingroup msg_synchro
419  *  @hideinitializer
420  */
421 typedef struct s_smx_sem *msg_sem_t; // Yeah that's a rename of the smx_sem_t which doesnt require smx_sem_t to be declared here
422 XBT_PUBLIC(msg_sem_t) MSG_sem_init(int initial_value);
423 XBT_PUBLIC(void) MSG_sem_acquire(msg_sem_t sem);
424 XBT_PUBLIC(msg_error_t) MSG_sem_acquire_timeout(msg_sem_t sem, double timeout);
425 XBT_PUBLIC(void) MSG_sem_release(msg_sem_t sem);
426 XBT_PUBLIC(int) MSG_sem_get_capacity(msg_sem_t sem);
427 XBT_PUBLIC(void) MSG_sem_destroy(msg_sem_t sem);
428 XBT_PUBLIC(int) MSG_sem_would_block(msg_sem_t sem);
429
430 /** @brief Opaque type representing a barrier identifier
431  *  @ingroup msg_synchro
432  *  @hideinitializer
433  */
434
435 #define MSG_BARRIER_SERIAL_PROCESS -1
436 typedef struct s_msg_bar* msg_bar_t;
437 XBT_PUBLIC(msg_bar_t) MSG_barrier_init( unsigned int count);
438 XBT_PUBLIC(void) MSG_barrier_destroy(msg_bar_t bar);
439 XBT_PUBLIC(int) MSG_barrier_wait(msg_bar_t bar);
440
441 /** @brief Opaque type describing a Virtual Machine.
442  *  @ingroup msg_VMs
443  *
444  * All this is highly experimental and the interface will probably change in the future.
445  * Please don't depend on this yet (although testing is welcomed if you feel so).
446  * Usual lack of guaranty of any kind applies here, and is even increased.
447  *
448  */
449
450 XBT_PUBLIC(int) MSG_vm_is_created(msg_vm_t vm);
451 XBT_PUBLIC(int) MSG_vm_is_running(msg_vm_t vm);
452 XBT_PUBLIC(int) MSG_vm_is_migrating(msg_vm_t vm);
453 XBT_PUBLIC(int) MSG_vm_is_suspended(msg_vm_t vm);
454
455 #define MSG_vm_get_name(vm) MSG_host_get_name(vm)
456
457 XBT_PUBLIC(void) MSG_vm_get_params(msg_vm_t vm, vm_params_t params);
458 XBT_PUBLIC(void) MSG_vm_set_params(msg_vm_t vm, vm_params_t params);
459
460 // TODO add VDI later
461 XBT_PUBLIC(msg_vm_t) MSG_vm_create_core(msg_host_t location, const char *name);
462 XBT_PUBLIC(msg_vm_t)
463 MSG_vm_create(msg_host_t ind_pm, const char* name, int ramsize, int mig_netspeed, int dp_intensity);
464
465 XBT_PUBLIC(void) MSG_vm_destroy(msg_vm_t vm);
466
467 XBT_PUBLIC(void) MSG_vm_start(msg_vm_t vm);
468
469 /* Shutdown the guest operating system. */
470 XBT_PUBLIC(void) MSG_vm_shutdown(msg_vm_t vm);
471
472 XBT_PUBLIC(void) MSG_vm_migrate(msg_vm_t vm, msg_host_t destination);
473
474 /* Suspend the execution of the VM, but keep its state on memory. */
475 XBT_PUBLIC(void) MSG_vm_suspend(msg_vm_t vm);
476 XBT_PUBLIC(void) MSG_vm_resume(msg_vm_t vm);
477
478 XBT_PUBLIC(msg_host_t) MSG_vm_get_pm(msg_vm_t vm);
479 XBT_PUBLIC(void) MSG_vm_set_bound(msg_vm_t vm, double bound);
480
481
482 #include "simgrid/instr.h"
483
484 /* ****************************************************************************************** */
485 /* Used only by the bindings -- unclean pimple, please ignore if you're not writing a binding */
486 XBT_PUBLIC(smx_context_t) MSG_process_get_smx_ctx(msg_process_t process);
487
488
489 /* Functions renamed in 3.14 */
490 #define MSG_mailbox_get_head(m) MSG_mailbox_front(m)
491
492
493 SG_END_DECL()
494
495 #ifdef __cplusplus
496 XBT_PUBLIC(msg_process_t)
497 MSG_process_create_from_stdfunc(const char* name, std::function<void()> code, void* data, msg_host_t host,
498                                 xbt_dict_t properties);
499 #endif
500
501 #endif