Logo AND Algorithmique Numérique Distribuée

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