Logo AND Algorithmique Numérique Distribuée

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