Logo AND Algorithmique Numérique Distribuée

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