Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1df82a2f52b3ab19029cec6d37d6f29d6e19152f
[simgrid.git] / include / simgrid / msg.h
1
2 /* Copyright (c) 2004-2018. The SimGrid Team. 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 SIMGRID_MSG_H
8 #define SIMGRID_MSG_H
9
10 #include <simgrid/actor.h>
11 #include <simgrid/barrier.h>
12 #include <simgrid/engine.h>
13 #include <simgrid/forward.h>
14 #include <simgrid/host.h>
15 #include <simgrid/instr.h>
16 #include <simgrid/mailbox.h>
17 #include <simgrid/plugins/live_migration.h>
18 #include <simgrid/storage.h>
19 #include <simgrid/vm.h>
20 #include <simgrid/zone.h>
21 #include <xbt.h>
22
23 #ifndef MIN
24 #define MIN(a, b) ((a) < (b) ? (a) : (b))
25 #endif
26 #ifndef MAX
27 #define MAX(a, b) ((a) > (b) ? (a) : (b))
28 #endif
29
30 #ifdef __cplusplus
31 #include <map>
32 #include <simgrid/simix.h>
33 namespace simgrid {
34 namespace msg {
35 class Comm;
36 }
37 }
38 typedef simgrid::msg::Comm sg_msg_Comm;
39 #else
40 typedef struct msg_Comm sg_msg_Comm;
41 #endif
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 /* *************************** Network Zones ******************************** */
48 #define msg_as_t msg_netzone_t /* portability macro */
49
50 typedef sg_netzone_t msg_netzone_t;
51
52 XBT_PUBLIC msg_netzone_t MSG_zone_get_root();
53 XBT_PUBLIC const char* MSG_zone_get_name(msg_netzone_t zone);
54 XBT_PUBLIC msg_netzone_t MSG_zone_get_by_name(const char* name);
55 XBT_PUBLIC void MSG_zone_get_sons(msg_netzone_t zone, xbt_dict_t whereto);
56 XBT_PUBLIC const char* MSG_zone_get_property_value(msg_netzone_t zone, const char* name);
57 XBT_PUBLIC void MSG_zone_set_property_value(msg_netzone_t zone, const char* name, char* value);
58 XBT_PUBLIC void MSG_zone_get_hosts(msg_netzone_t zone, xbt_dynar_t whereto);
59
60 /* ******************************** Hosts ************************************ */
61 /** @brief Host datatype.
62  *
63  * A <em>location</em> (or <em>host</em>) is any possible place where a process may run. Thus it is represented as a
64  * <em>physical resource with computing capabilities</em>, some <em>mailboxes</em> to enable running process to
65  * communicate with remote ones, and some <em>private data</em> that can be only accessed by local process.
66  */
67 typedef sg_host_t msg_host_t;
68
69 /** @brief Finds a msg_host_t using its name. */
70 XBT_PUBLIC sg_host_t MSG_get_host_by_name(const char* name);
71 /** @brief Finds a msg_host_t using its name. */
72 XBT_PUBLIC sg_host_t MSG_host_by_name(const char* name);
73
74 /** @brief Returns the amount of host found in the platform */
75 XBT_PUBLIC size_t MSG_get_host_number();
76 /** @brief Returns a dynar with all existing hosts
77  *
78  * The host order in the returned array is generally different from the host creation/declaration order in the XML
79  * platform (we use a hash table internally).
80  */
81 XBT_PUBLIC xbt_dynar_t MSG_hosts_as_dynar();
82
83 /** @brief Returns the name of this host */
84 XBT_PUBLIC const char* MSG_host_get_name(sg_host_t host);
85 /** @brief Returns the user data of this host */
86 XBT_PUBLIC void* MSG_host_get_data(sg_host_t host);
87 /** @brief Sets the user data of this host */
88 XBT_PUBLIC void MSG_host_set_data(sg_host_t host, void* data);
89 XBT_PUBLIC xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host);
90 XBT_PUBLIC xbt_dynar_t MSG_host_get_attached_storage_lists(sg_host_t host);
91 XBT_PUBLIC double MSG_host_get_speed(sg_host_t host);
92 XBT_PUBLIC double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index);
93 XBT_PUBLIC int MSG_host_get_core_number(sg_host_t host);
94 XBT_PUBLIC int MSG_host_get_nb_pstates(sg_host_t host);
95 XBT_PUBLIC int MSG_host_get_pstate(sg_host_t host);
96 XBT_PUBLIC void MSG_host_set_pstate(sg_host_t host, int pstate);
97 /** @brief Start the host if it is off
98  *
99  * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref SURF_plugin_energy
100  * for more info on DVFS.
101  */
102 XBT_PUBLIC void MSG_host_on(sg_host_t h);
103 /** @brief Stop the host if it is on
104  *
105  * See also #MSG_host_is_on() and #MSG_host_is_off() to test the current state of the host and @ref SURF_plugin_energy
106  * for more info on DVFS.
107  */
108 XBT_PUBLIC void MSG_host_off(sg_host_t h);
109 XBT_PUBLIC int MSG_host_is_on(sg_host_t h);
110 XBT_PUBLIC int MSG_host_is_off(sg_host_t h);
111 XBT_PUBLIC xbt_dict_t MSG_host_get_properties(sg_host_t host);
112 XBT_PUBLIC const char* MSG_host_get_property_value(sg_host_t host, const char* name);
113 XBT_PUBLIC void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value);
114 XBT_PUBLIC void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto);
115
116 /** @brief Return the location on which the current process is executed */
117 XBT_PUBLIC sg_host_t MSG_host_self();
118
119 /* ******************************** VMs ************************************* */
120 typedef sg_vm_t msg_vm_t;
121
122 XBT_ATTRIB_DEPRECATED_v322("Use sg_vm_create_migratable() from the live migration plugin: "
123                            "v3.22 will drop MSG_vm_create() completely.") XBT_PUBLIC sg_vm_t
124     MSG_vm_create(sg_host_t ind_pm, const char* name, int coreAmount, int ramsize, int mig_netspeed, int dp_intensity);
125
126 XBT_PUBLIC msg_vm_t MSG_vm_create_core(msg_host_t pm, const char* name);
127 XBT_PUBLIC msg_vm_t MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount);
128
129 XBT_PUBLIC int MSG_vm_is_created(msg_vm_t vm);
130 XBT_PUBLIC int MSG_vm_is_running(msg_vm_t vm);
131 XBT_PUBLIC int MSG_vm_is_suspended(msg_vm_t vm);
132
133 XBT_PUBLIC const char* MSG_vm_get_name(msg_vm_t vm);
134 XBT_PUBLIC void MSG_vm_set_ramsize(msg_vm_t vm, size_t size);
135 XBT_PUBLIC size_t MSG_vm_get_ramsize(msg_vm_t vm);
136 XBT_PUBLIC msg_host_t MSG_vm_get_pm(msg_vm_t vm);
137 XBT_PUBLIC void MSG_vm_set_bound(msg_vm_t vm, double bound);
138
139 XBT_PUBLIC void MSG_vm_start(msg_vm_t vm);
140 XBT_PUBLIC void MSG_vm_suspend(msg_vm_t vm);
141 XBT_PUBLIC void MSG_vm_resume(msg_vm_t vm);
142 XBT_PUBLIC void MSG_vm_shutdown(msg_vm_t vm);
143 XBT_PUBLIC void MSG_vm_destroy(msg_vm_t vm);
144
145 /* ******************************** Storage ********************************* */
146 typedef sg_storage_t msg_storage_t;
147
148 XBT_PUBLIC const char* MSG_storage_get_name(msg_storage_t storage);
149 XBT_PUBLIC msg_storage_t MSG_storage_get_by_name(const char* name);
150 XBT_PUBLIC xbt_dict_t MSG_storage_get_properties(msg_storage_t storage);
151 XBT_PUBLIC void MSG_storage_set_property_value(msg_storage_t storage, const char* name, const char* value);
152 XBT_PUBLIC const char* MSG_storage_get_property_value(msg_storage_t storage, const char* name);
153 XBT_PUBLIC xbt_dynar_t MSG_storages_as_dynar();
154 XBT_PUBLIC void MSG_storage_set_data(msg_storage_t storage, void* data);
155 XBT_PUBLIC void* MSG_storage_get_data(msg_storage_t storage);
156 XBT_PUBLIC const char* MSG_storage_get_host(msg_storage_t storage);
157 XBT_PUBLIC sg_size_t MSG_storage_read(msg_storage_t storage, sg_size_t size);
158 XBT_PUBLIC sg_size_t MSG_storage_write(msg_storage_t storage, sg_size_t size);
159
160 /* ******************************** Actor/process *************************** */
161 typedef sg_actor_t msg_process_t;
162
163 XBT_PUBLIC int MSG_process_get_PID(msg_process_t process);
164 XBT_PUBLIC int MSG_process_get_PPID(msg_process_t process);
165 /** @brief Return a #msg_process_t from its PID.
166  *
167  * Note that the PID are uniq in the whole simulation, not only on a given host.
168  *
169  * @returns NULL if no host is found
170  */
171 XBT_PUBLIC sg_actor_t MSG_process_from_PID(int pid);
172 XBT_PUBLIC const char* MSG_process_get_name(msg_process_t process);
173 XBT_PUBLIC sg_host_t MSG_process_get_host(msg_process_t process);
174
175 /*property handlers*/
176 XBT_PUBLIC xbt_dict_t MSG_process_get_properties(msg_process_t process);
177 XBT_PUBLIC const char* MSG_process_get_property_value(msg_process_t process, const char* name);
178
179 XBT_PUBLIC void MSG_process_suspend(msg_process_t process);
180 XBT_PUBLIC void MSG_process_resume(msg_process_t process);
181 XBT_PUBLIC int MSG_process_is_suspended(msg_process_t process);
182 XBT_PUBLIC void MSG_process_restart(msg_process_t process);
183 /** @brief Sets the "auto-restart" flag of the process.
184  *
185  * If the flag is set, the process will be automatically restarted when its host comes back up.
186  */
187 XBT_PUBLIC void MSG_process_auto_restart_set(msg_process_t process, int auto_restart);
188 /** @brief Indicates that this process should not prevent the simulation from ending
189  *
190  * SimGrid simulations run until all non-daemon processes are stopped.
191  */
192 XBT_PUBLIC void MSG_process_daemonize(msg_process_t process);
193 /** @brief Imediately changes the host on which this process runs */
194 XBT_PUBLIC void MSG_process_migrate(msg_process_t process, msg_host_t host);
195 /** @brief Wait for the completion of a #msg_process_t.
196  *
197  * @param process the process to wait for
198  * @param timeout wait until the process is over, or the timeout occurs
199  */
200 XBT_PUBLIC void MSG_process_join(msg_process_t process, double timeout);
201 /** @brief Kills a process */
202 XBT_PUBLIC void MSG_process_kill(msg_process_t process);
203 /** @brief Kill all running process */
204 XBT_PUBLIC void MSG_process_killall();
205 /** @breif Specifies the time at which the process should be automatically killed */
206 XBT_PUBLIC void MSG_process_set_kill_time(msg_process_t process, double kill_time);
207 /** @brief Yield the current actor; let the other actors execute first */
208 XBT_PUBLIC void MSG_process_yield();
209
210 /** @brief Object representing an ongoing communication between processes.
211  *
212  * \rst
213  * Such beast is usually obtained by using :cpp:func:`MSG_task_isend`, :cpp:func:`MSG_task_irecv` or friends.
214  * \endrst
215  */
216 typedef sg_msg_Comm* msg_comm_t;
217
218 /* ******************************** Task ************************************ */
219
220 typedef struct s_simdata_task_t* simdata_task_t;
221
222 typedef struct msg_task {
223   char* name;             /**< @brief task name if any */
224   simdata_task_t simdata; /**< @brief simulator data */
225   void* data;             /**< @brief user data */
226   long long int counter;  /* task unique identifier for instrumentation */
227   char* category;         /* task category for instrumentation */
228 } s_msg_task_t;
229
230 /** @brief Task datatype.
231  *
232  *  Since most scheduling algorithms rely on a concept of task  that can be either <em>computed</em> locally or
233  *  <em>transferred</em> on another processor, it seems to be the right level of abstraction for our purposes.
234  *  A <em>task</em> may then be defined by a <em>computing amount</em>, a <em>message size</em> and
235  *  some <em>private data</em>.
236  */
237
238 typedef struct msg_task* msg_task_t;
239
240 /** @brief Default value for an uninitialized #msg_task_t. */
241 #define MSG_TASK_UNINITIALIZED NULL
242
243 /** @brief Return code of most MSG functions
244     @ingroup msg_simulation
245     @{ */
246 /* Keep these code as binary values: java bindings manipulate | of these values */
247 typedef enum {
248   MSG_OK = 0,                 /**< @brief Everything is right. Keep on going this way ! */
249   MSG_TIMEOUT = 1,            /**< @brief nothing good happened before the timer you provided elapsed */
250   MSG_TRANSFER_FAILURE = 2,   /**< @brief There has been a problem during you task
251       transfer. Either the network is down or the remote host has been
252       shutdown. */
253   MSG_HOST_FAILURE = 4,       /**< @brief System shutdown. The host on which you are
254       running has just been rebooted. Free your datastructures and
255       return now !*/
256   MSG_TASK_CANCELED = 8      /**< @brief Canceled task. This task has been canceled by somebody!*/
257 } msg_error_t;
258 /** @} */
259
260 /************************** Global ******************************************/
261 /** @brief set a configuration variable
262  *
263  * Do --help on any simgrid binary to see the list of currently existing configuration variables, and see Section @ref
264  * options.
265  *
266  * Example:
267  * MSG_config("host/model","ptask_L07");
268  */
269 XBT_PUBLIC void MSG_config(const char* key, const char* value);
270 /** @ingroup msg_simulation
271  *  @brief Initialize the MSG internal data.
272  *  @hideinitializer
273  *
274  *  It also check that the link-time and compile-time versions of SimGrid do
275  *  match, so you should use this version instead of the #MSG_init_nocheck
276  *  function that does the same initializations, but without this check.
277  *
278  *  We allow to link against compiled versions that differ in the patch level.
279  */
280 #define MSG_init(argc, argv)                                                                                           \
281   do {                                                                                                                 \
282     sg_version_check(SIMGRID_VERSION_MAJOR, SIMGRID_VERSION_MINOR, SIMGRID_VERSION_PATCH);                             \
283     MSG_init_nocheck(argc, argv);                                                                                      \
284   } while (0)
285
286 XBT_PUBLIC void MSG_init_nocheck(int* argc, char** argv);
287 /** @brief Launch the MSG simulation */
288 XBT_PUBLIC msg_error_t MSG_main();
289 /** @brief Registers the main function of a process in a global table.
290  *
291  * This table is then used by #MSG_launch_application.
292  * @param name the reference name of the function.
293  * @param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char
294  * *argv[]))
295  */
296 XBT_PUBLIC void MSG_function_register(const char* name, xbt_main_func_t code);
297 /** @brief Registers a code function as being the default value.
298  *
299  * This function will get used by MSG_launch_application() when there is no registered function of the requested name
300  * in.
301  *
302  * @param code the function (must have the same prototype than the main function of any C program: int ..(int argc, char
303  * *argv[]))
304  */
305 XBT_PUBLIC void MSG_function_register_default(xbt_main_func_t code);
306 /** @brief Creates a new platform, including hosts, links and the routing_table */
307 XBT_PUBLIC void MSG_create_environment(const char* file);
308 /** @brief Creates the application described in the provided file */
309 XBT_PUBLIC void MSG_launch_application(const char* file);
310 /** @brief register functions bypassing the parser */
311 XBT_PUBLIC void MSG_set_function(const char* host_id, const char* function_name, xbt_dynar_t arguments);
312
313 /** @brief A clock (in second). */
314 XBT_PUBLIC double MSG_get_clock();
315 /** @brief Returns the amount of messages sent since the simulation start */
316 XBT_PUBLIC unsigned long int MSG_get_sent_msg();
317
318 /************************** Process handling *********************************/
319 XBT_PUBLIC msg_process_t MSG_process_create(const char* name, xbt_main_func_t code, void* data, msg_host_t host);
320 XBT_PUBLIC msg_process_t MSG_process_create_with_arguments(const char* name, xbt_main_func_t code, void* data,
321                                                            msg_host_t host, int argc, char** argv);
322 XBT_PUBLIC msg_process_t MSG_process_create_with_environment(const char* name, xbt_main_func_t code, void* data,
323                                                              msg_host_t host, int argc, char** argv,
324                                                              xbt_dict_t properties);
325
326 XBT_PUBLIC msg_process_t MSG_process_attach(const char* name, void* data, msg_host_t host, xbt_dict_t properties);
327 XBT_PUBLIC void MSG_process_detach();
328
329 XBT_PUBLIC void MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
330 XBT_PUBLIC int MSG_process_self_PID();
331 XBT_PUBLIC int MSG_process_self_PPID();
332 XBT_PUBLIC const char* MSG_process_self_name();
333 XBT_PUBLIC msg_process_t MSG_process_self();
334 XBT_PUBLIC xbt_dynar_t MSG_processes_as_dynar();
335 XBT_PUBLIC int MSG_process_get_number();
336
337 XBT_PUBLIC void* MSG_process_get_data(msg_process_t process);
338 XBT_PUBLIC msg_error_t MSG_process_set_data(msg_process_t process, void* data);
339
340 XBT_PUBLIC void MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void* data);
341
342 XBT_PUBLIC void MSG_process_ref(msg_process_t process);
343 XBT_PUBLIC void MSG_process_unref(msg_process_t process);
344
345 /************************** Task handling ************************************/
346 XBT_PUBLIC msg_task_t MSG_task_create(const char* name, double flops_amount, double bytes_amount, void* data);
347 XBT_PUBLIC msg_task_t MSG_parallel_task_create(const char* name, int host_nb, const msg_host_t* host_list,
348                                                double* flops_amount, double* bytes_amount, void* data);
349 XBT_PUBLIC void* MSG_task_get_data(msg_task_t task);
350 XBT_PUBLIC void MSG_task_set_data(msg_task_t task, void* data);
351 XBT_PUBLIC void MSG_task_set_copy_callback(void (*callback)(msg_task_t task, msg_process_t src, msg_process_t dst));
352 XBT_PUBLIC msg_process_t MSG_task_get_sender(msg_task_t task);
353 XBT_PUBLIC msg_host_t MSG_task_get_source(msg_task_t task);
354 XBT_PUBLIC const char* MSG_task_get_name(msg_task_t task);
355 XBT_PUBLIC void MSG_task_set_name(msg_task_t task, const char* name);
356 XBT_PUBLIC msg_error_t MSG_task_cancel(msg_task_t task);
357 XBT_PUBLIC msg_error_t MSG_task_destroy(msg_task_t task);
358
359 XBT_PUBLIC msg_error_t MSG_task_execute(msg_task_t task);
360 XBT_PUBLIC msg_error_t MSG_parallel_task_execute(msg_task_t task);
361 XBT_PUBLIC msg_error_t MSG_parallel_task_execute_with_timeout(msg_task_t task, double timeout);
362 XBT_PUBLIC void MSG_task_set_priority(msg_task_t task, double priority);
363 XBT_PUBLIC void MSG_task_set_bound(msg_task_t task, double bound);
364
365 XBT_PUBLIC msg_error_t MSG_process_sleep(double nb_sec);
366
367 XBT_PUBLIC void MSG_task_set_flops_amount(msg_task_t task, double flops_amount);
368 XBT_PUBLIC double MSG_task_get_flops_amount(msg_task_t task);
369 XBT_PUBLIC double MSG_task_get_remaining_work_ratio(msg_task_t task);
370 XBT_PUBLIC void MSG_task_set_bytes_amount(msg_task_t task, double bytes_amount);
371
372 XBT_PUBLIC double MSG_task_get_remaining_communication(msg_task_t task);
373 XBT_PUBLIC double MSG_task_get_bytes_amount(msg_task_t task);
374
375 XBT_PUBLIC msg_error_t MSG_task_receive_ext(msg_task_t* task, const char* alias, double timeout, msg_host_t host);
376
377 XBT_PUBLIC msg_error_t MSG_task_receive_with_timeout(msg_task_t* task, const char* alias, double timeout);
378
379 XBT_PUBLIC msg_error_t MSG_task_receive(msg_task_t* task, const char* alias);
380 #define MSG_task_recv(t,a) MSG_task_receive(t,a)
381
382 XBT_PUBLIC msg_error_t MSG_task_receive_ext_bounded(msg_task_t* task, const char* alias, double timeout,
383                                                     msg_host_t host, double rate);
384
385 XBT_PUBLIC msg_error_t MSG_task_receive_with_timeout_bounded(msg_task_t* task, const char* alias, double timeout,
386                                                              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
393 XBT_PUBLIC void MSG_task_dsend(msg_task_t task, const char* alias, void_f_pvoid_t cleanup);
394 XBT_PUBLIC void MSG_task_dsend_bounded(msg_task_t task, const char* alias, void_f_pvoid_t cleanup, double maxrate);
395 XBT_PUBLIC msg_comm_t MSG_task_irecv(msg_task_t* task, const char* alias);
396 XBT_PUBLIC msg_comm_t MSG_task_irecv_bounded(msg_task_t* task, const char* alias, double rate);
397 XBT_PUBLIC int MSG_comm_test(msg_comm_t comm);
398 XBT_PUBLIC int MSG_comm_testany(xbt_dynar_t comms);
399 XBT_PUBLIC void MSG_comm_destroy(msg_comm_t comm);
400 XBT_PUBLIC msg_error_t MSG_comm_wait(msg_comm_t comm, double timeout);
401 XBT_PUBLIC void MSG_comm_waitall(msg_comm_t* comm, int nb_elem, double timeout);
402 XBT_PUBLIC int MSG_comm_waitany(xbt_dynar_t comms);
403 XBT_PUBLIC msg_task_t MSG_comm_get_task(msg_comm_t comm);
404 XBT_PUBLIC msg_error_t MSG_comm_get_status(msg_comm_t comm);
405
406 /** @brief Check if there is a communication going on in a mailbox.
407  *
408  * @param alias the name of the mailbox to be considered
409  *
410  * @return Returns 1 if there is a communication, 0 otherwise
411  */
412 XBT_PUBLIC int MSG_task_listen(const char* alias);
413 XBT_PUBLIC msg_error_t MSG_task_send_with_timeout(msg_task_t task, const char* alias, double timeout);
414 XBT_PUBLIC msg_error_t MSG_task_send_with_timeout_bounded(msg_task_t task, const char* alias, double timeout,
415                                                           double maxrate);
416 XBT_PUBLIC msg_error_t MSG_task_send(msg_task_t task, const char* alias);
417 XBT_PUBLIC msg_error_t MSG_task_send_bounded(msg_task_t task, const char* alias, double rate);
418 XBT_PUBLIC int MSG_task_listen_from(const char* alias);
419 XBT_PUBLIC void MSG_task_set_category(msg_task_t task, const char* category);
420 XBT_PUBLIC const char* MSG_task_get_category(msg_task_t task);
421
422 /************************** Mailbox handling ************************************/
423
424 /* @brief set a mailbox in eager mode.
425  * All messages sent to this mailbox will be transferred to the receiver without waiting for the receive call.
426  * The receive call will still be necessary to use the received data.
427  * If there is a need to receive some messages asynchronously, and some not, two different mailboxes should be used.
428  *
429  * This call should be done before issuing any receive, and on the receiver's side only
430  */
431 XBT_PUBLIC void MSG_mailbox_set_async(const char* alias);
432
433 /** @brief Opaque type representing a semaphore
434  *  @ingroup msg_synchro
435  *  @hideinitializer
436  */
437 typedef struct s_smx_sem_t* msg_sem_t; // Yeah that's a rename of the smx_sem_t which doesnt require smx_sem_t to be
438                                        // declared here
439 XBT_PUBLIC msg_sem_t MSG_sem_init(int initial_value);
440 XBT_PUBLIC void MSG_sem_acquire(msg_sem_t sem);
441 XBT_PUBLIC msg_error_t MSG_sem_acquire_timeout(msg_sem_t sem, double timeout);
442 XBT_PUBLIC void MSG_sem_release(msg_sem_t sem);
443 XBT_PUBLIC int MSG_sem_get_capacity(msg_sem_t sem);
444 XBT_PUBLIC void MSG_sem_destroy(msg_sem_t sem);
445 XBT_PUBLIC int MSG_sem_would_block(msg_sem_t sem);
446
447 /** @brief Opaque type representing a barrier identifier */
448 typedef sg_bar_t msg_bar_t;
449 /** @brief Initializes a barier, with count elements */
450 XBT_PUBLIC msg_bar_t MSG_barrier_init(unsigned int count);
451 /** @brief Destroys barrier */
452 XBT_PUBLIC void MSG_barrier_destroy(msg_bar_t bar);
453 /** @brief Performs a barrier already initialized */
454 XBT_PUBLIC int MSG_barrier_wait(msg_bar_t bar);
455
456 /* ****************************************************************************************** */
457 /* DO NOT USE this nasty pimple (unless if you're writing a binding) */
458 XBT_PUBLIC smx_context_t
459 XBT_ATTRIB_DEPRECATED_v323("MSG_process_get_smx_ctx is deprecated. Please contact us if you need it.")
460 MSG_process_get_smx_ctx(msg_process_t process);
461
462 #ifdef __cplusplus
463 }
464 #endif
465
466 #ifdef __cplusplus
467 XBT_PUBLIC msg_process_t MSG_process_create_from_stdfunc(std::string name, std::function<void()> code, void* data,
468                                                          msg_host_t host,
469                                                          std::unordered_map<std::string, std::string>* properties);
470 #endif
471
472 #endif