Logo AND Algorithmique Numérique Distribuée

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