Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make s_smx_process_t a C++ class (constructor, new, delete)
[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.h"
11 #include "xbt/lib.h"
12 #include "simgrid/forward.h"
13 #include "simgrid/simix.h"
14
15 SG_BEGIN_DECL()
16
17 /* ******************************** Mailbox ************************************ */
18
19 /** @brief Mailbox datatype
20  *  @ingroup msg_task_usage
21  *
22  * Object representing a communication rendez-vous point, on which
23  * the sender finds the receiver it wants to communicate with. As a
24  * MSG user, you will only rarely manipulate any of these objects
25  * directly, since most of the public interface (such as
26  * #MSG_task_send and friends) hide this object behind a string
27  * alias. That mean that you don't provide the mailbox on which you
28  * want to send your task, but only the name of this mailbox. */
29 typedef struct s_smx_mailbox *msg_mailbox_t;
30
31 /* ******************************** Environment ************************************ */
32 typedef simgrid_As *msg_as_t;
33
34 /* ******************************** Host ************************************ */
35
36 /** @brief Host datatype.
37     @ingroup m_host_management
38
39     A <em>location</em> (or <em>host</em>) is any possible place where
40     a process may run. Thus it is represented as a <em>physical
41     resource with computing capabilities</em>, some <em>mailboxes</em>
42     to enable running process to communicate with remote ones, and
43     some <em>private data</em> that can be only accessed by local
44     process.
45  */
46 typedef sg_host_t msg_host_t;
47
48 typedef struct s_msg_host_priv {
49   int        dp_enabled;
50   xbt_dict_t dp_objs;
51   double     dp_updated_by_deleted_tasks;
52   int        is_migrating;
53
54   xbt_dict_t affinity_mask_db;
55   xbt_dynar_t file_descriptor_table;
56 } s_msg_host_priv_t;
57
58 /* ******************************** Task ************************************ */
59
60 typedef struct simdata_task *simdata_task_t;
61
62 typedef struct msg_task {
63   char *name;                   /**< @brief task name if any */
64   simdata_task_t simdata;       /**< @brief simulator data */
65   void *data;                   /**< @brief user data */
66   long long int counter;        /* task unique identifier for instrumentation */
67   char *category;               /* task category for instrumentation */
68 } s_msg_task_t;
69
70 /** @brief Task datatype.
71     @ingroup m_task_management
72
73     A <em>task</em> may then be defined by a <em>computing
74     amount</em>, a <em>message size</em> and some <em>private
75     data</em>.
76  */
77 typedef struct msg_task *msg_task_t;
78
79 /* ******************************** VM ************************************* */
80 typedef msg_host_t msg_vm_t;
81
82 /* ******************************** File ************************************ */
83
84 /** @brief Opaque object describing a File in MSG.
85  *  @ingroup msg_file */
86 typedef xbt_dictelm_t msg_file_t;
87 typedef s_xbt_dictelm_t s_msg_file_t;
88
89 extern int MSG_FILE_LEVEL;
90 typedef struct simdata_file *simdata_file_t;
91
92 typedef struct msg_file_priv  {
93   char *fullpath;
94   sg_size_t size;
95   char* mount_point;
96   char* storageId;
97   char* storage_type;
98   char* content_type;
99   int desc_id;
100   void *data;
101   simdata_file_t simdata;
102 } s_msg_file_priv_t, *msg_file_priv_t;
103
104 static inline msg_file_priv_t MSG_file_priv(msg_file_t file){
105   return (msg_file_priv_t )xbt_lib_get_level(file, MSG_FILE_LEVEL);
106 }
107
108 /* ******************************** Storage ************************************ */
109 /* TODO: PV: to comment */
110
111 extern int MSG_STORAGE_LEVEL;
112
113 /** @brief Storage datatype.
114  *  @ingroup msg_storage_management
115  *
116  *  You should consider this as an opaque object.
117  */
118 typedef xbt_dictelm_t msg_storage_t;
119 typedef s_xbt_dictelm_t s_msg_storage_t;
120
121 typedef struct msg_storage_priv  {
122   const char *hostname;
123   void *data;
124 } s_msg_storage_priv_t, *msg_storage_priv_t;
125
126 static inline msg_storage_priv_t MSG_storage_priv(msg_storage_t storage){
127   return (msg_storage_priv_t )xbt_lib_get_level(storage, MSG_STORAGE_LEVEL);
128 }
129
130 /**
131  * \brief @brief Communication action.
132  * \ingroup msg_task_usage
133  *
134  * Object representing an ongoing communication between processes. Such beast is usually obtained by using #MSG_task_isend, #MSG_task_irecv or friends.
135  */
136 typedef struct msg_comm *msg_comm_t;
137
138 /** \brief Default value for an uninitialized #msg_task_t.
139     \ingroup m_task_management
140 */
141 #define MSG_TASK_UNINITIALIZED NULL
142
143 /* ****************************** Process *********************************** */
144
145 /** @brief Process datatype.
146     @ingroup m_process_management
147
148     A process may be defined as a <em>code</em>, with some
149     <em>private data</em>, executing in a <em>location</em>.
150
151     You should not access directly to the fields of the pointed
152     structure, but always use the provided API to interact with
153     processes.
154  */
155 typedef smx_process_t msg_process_t;
156
157 /** @brief Return code of most MSG functions
158     @ingroup msg_simulation
159     @{ */
160 /* Keep these code as binary values: java bindings manipulate | of these values */
161 typedef enum {
162   MSG_OK = 0,                 /**< @brief Everything is right. Keep on going this way ! */
163   MSG_TIMEOUT = 1,            /**< @brief nothing good happened before the timer you provided elapsed */
164   MSG_TRANSFER_FAILURE = 2,   /**< @brief There has been a problem during you task
165       transfer. Either the network is down or the remote host has been
166       shutdown. */
167   MSG_HOST_FAILURE = 4,       /**< @brief System shutdown. The host on which you are
168       running has just been rebooted. Free your datastructures and
169       return now !*/
170   MSG_TASK_CANCELED = 8      /**< @brief Canceled task. This task has been canceled by somebody!*/
171 } msg_error_t;
172 /** @} */
173
174 /************************** Global ******************************************/
175 XBT_PUBLIC(void) MSG_config(const char *key, const char *value);
176 /** \ingroup msg_simulation
177  *  \brief Initialize the MSG internal data.
178  *  \hideinitializer
179  *
180  *  It also check that the link-time and compile-time versions of SimGrid do
181  *  match, so you should use this version instead of the #MSG_init_nocheck
182  *  function that does the same initializations, but without this check.
183  *
184  *  We allow to link against compiled versions that differ in the patch level.
185  */
186 #define MSG_init(argc,argv)  do {                                                          \
187   sg_version_check(SIMGRID_VERSION_MAJOR,SIMGRID_VERSION_MINOR,SIMGRID_VERSION_PATCH);\
188     MSG_init_nocheck(argc,argv);                                                        \
189   } while (0)
190
191 XBT_PUBLIC(void) MSG_init_nocheck(int *argc, char **argv);
192 XBT_PUBLIC(msg_error_t) MSG_main(void);
193 XBT_PUBLIC(void) MSG_function_register(const char *name,
194                                        xbt_main_func_t code);
195 XBT_PUBLIC(void) MSG_function_register_default(xbt_main_func_t code);
196 XBT_PUBLIC(xbt_main_func_t) MSG_get_registered_function(const char *name);
197 XBT_PUBLIC(void) MSG_launch_application(const char *file);
198 /*Bypass the parser */
199 XBT_PUBLIC(void) MSG_set_function(const char *host_id,
200                                   const char *function_name,
201                                   xbt_dynar_t arguments);
202
203 XBT_PUBLIC(double) MSG_get_clock(void);
204 XBT_PUBLIC(unsigned long int) MSG_get_sent_msg(void);
205
206 /************************** Environment ***********************************/
207 XBT_PUBLIC(msg_as_t) MSG_environment_get_routing_root(void);
208 XBT_PUBLIC(const char *) MSG_environment_as_get_name(msg_as_t as);
209 XBT_PUBLIC(msg_as_t) MSG_environment_as_get_by_name(const char * name);
210 XBT_PUBLIC(xbt_dict_t) MSG_environment_as_get_routing_sons(msg_as_t as);
211 XBT_PUBLIC(const char *) MSG_environment_as_get_property_value(msg_as_t as, const char *name);
212 XBT_PUBLIC(xbt_dynar_t) MSG_environment_as_get_hosts(msg_as_t as);
213
214 /************************** File handling ***********************************/
215 XBT_PUBLIC(sg_size_t) MSG_file_read(msg_file_t fd, sg_size_t size);
216 XBT_PUBLIC(sg_size_t) MSG_file_write(msg_file_t fd, sg_size_t size);
217 XBT_PUBLIC(msg_file_t) MSG_file_open(const char* fullpath, void* data);
218 XBT_PUBLIC(void*) MSG_file_get_data(msg_file_t fd);
219 XBT_PUBLIC(msg_error_t) MSG_file_set_data(msg_file_t fd, void * data);
220 XBT_PUBLIC(int) MSG_file_close(msg_file_t fd);
221 XBT_PUBLIC(sg_size_t) MSG_file_get_size(msg_file_t fd);
222 XBT_PUBLIC(void) MSG_file_dump(msg_file_t fd);
223 XBT_PUBLIC(msg_error_t) MSG_file_unlink(msg_file_t fd);
224 XBT_PUBLIC(msg_error_t) MSG_file_seek(msg_file_t fd, sg_offset_t offset, int origin);
225 XBT_PUBLIC(sg_size_t) MSG_file_tell (msg_file_t fd);
226 XBT_PUBLIC(void) __MSG_file_get_info(msg_file_t fd);
227 XBT_PUBLIC(void) __MSG_file_priv_free(msg_file_priv_t priv);
228 XBT_PUBLIC(const char *) MSG_file_get_name(msg_file_t file);
229 XBT_PUBLIC(msg_error_t) MSG_file_move(msg_file_t fd, const char* fullpath);
230 XBT_PUBLIC(msg_error_t) MSG_file_rcopy(msg_file_t fd, msg_host_t host, const char* fullpath);
231 XBT_PUBLIC(msg_error_t) MSG_file_rmove(msg_file_t fd, msg_host_t host, const char* fullpath);
232 /************************** Storage handling ***********************************/
233 XBT_PUBLIC(const char *) MSG_storage_get_name(msg_storage_t storage);
234 XBT_PUBLIC(sg_size_t) MSG_storage_get_free_size(msg_storage_t storage);
235 XBT_PUBLIC(sg_size_t) MSG_storage_get_used_size(msg_storage_t storage);
236 XBT_PUBLIC(msg_storage_t) MSG_storage_get_by_name(const char *name);
237 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_properties(msg_storage_t storage);
238 XBT_PUBLIC(void) MSG_storage_set_property_value(msg_storage_t storage, const char *name, char *value,void_f_pvoid_t free_ctn);
239 XBT_PUBLIC(const char *)MSG_storage_get_property_value(msg_storage_t storage, const char *name);
240 XBT_PUBLIC(xbt_dynar_t) MSG_storages_as_dynar(void);
241 XBT_PUBLIC(msg_error_t) MSG_storage_set_data(msg_storage_t host, void *data);
242 XBT_PUBLIC(void *) MSG_storage_get_data(msg_storage_t storage);
243 XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage);
244 XBT_PUBLIC(sg_size_t) MSG_storage_get_size(msg_storage_t storage);
245 XBT_PUBLIC(msg_error_t) MSG_storage_file_move(msg_file_t fd, msg_host_t dest, char* mount, char* fullname);
246 XBT_PUBLIC(const char *) MSG_storage_get_host(msg_storage_t storage);
247 /************************** AS Router handling ************************************/
248 XBT_PUBLIC(const char *) MSG_as_router_get_property_value(const char* asr, const char *name);
249 XBT_PUBLIC(xbt_dict_t) MSG_as_router_get_properties(const char* asr);
250 XBT_PUBLIC(void) MSG_as_router_set_property_value(const char* asr, const char *name, char *value,void_f_pvoid_t free_ctn);
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(void);
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(xbt_swag_t) MSG_host_get_process_list(msg_host_t h);
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 // deprecated
271 XBT_PUBLIC(double) MSG_get_host_speed(msg_host_t h);
272
273
274 XBT_PUBLIC(double) MSG_host_get_power_peak_at(msg_host_t h, int pstate);
275 XBT_PUBLIC(double) MSG_host_get_current_power_peak(msg_host_t h);
276 XBT_PUBLIC(int)    MSG_host_get_nb_pstates(msg_host_t h);
277 #define MSG_host_get_pstate(h)         sg_host_get_pstate(h)
278 #define MSG_host_set_pstate(h, pstate) sg_host_set_pstate(h, pstate)
279 XBT_PUBLIC(xbt_dynar_t) MSG_hosts_as_dynar(void);
280 XBT_PUBLIC(int) MSG_get_host_number(void);
281 XBT_PUBLIC(void) MSG_host_get_params(msg_host_t ind_pm, vm_params_t params);
282 XBT_PUBLIC(void) MSG_host_set_params(msg_host_t ind_pm, vm_params_t params);
283 XBT_PUBLIC(xbt_dict_t) MSG_host_get_mounted_storage_list(msg_host_t host);
284 XBT_PUBLIC(xbt_dynar_t) MSG_host_get_attached_storage_list(msg_host_t host);
285 XBT_PUBLIC(xbt_dict_t) MSG_host_get_storage_content(msg_host_t host);
286
287 /*property handlers*/
288 XBT_PUBLIC(xbt_dict_t) MSG_host_get_properties(msg_host_t host);
289 XBT_PUBLIC(const char *) MSG_host_get_property_value(msg_host_t host,
290                                                      const char *name);
291 XBT_PUBLIC(void) MSG_host_set_property_value(msg_host_t host,
292                                              const char *name, char *value,
293                                              void_f_pvoid_t free_ctn);
294
295
296 XBT_PUBLIC(void) MSG_create_environment(const char *file);
297
298 /************************** Process handling *********************************/
299 XBT_PUBLIC(msg_process_t) MSG_process_create(const char *name,
300                                            xbt_main_func_t code,
301                                            void *data, msg_host_t host);
302 XBT_PUBLIC(msg_process_t) MSG_process_create_with_arguments(const char *name,
303                                                           xbt_main_func_t
304                                                           code, void *data,
305                                                           msg_host_t host,
306                                                           int argc,
307                                                           char **argv);
308 XBT_PUBLIC(msg_process_t) MSG_process_create_with_environment(const char
309                                                             *name,
310                                                             xbt_main_func_t
311                                                             code,
312                                                             void *data,
313                                                             msg_host_t host,
314                                                             int argc,
315                                                             char **argv,
316                                                             xbt_dict_t
317                                                             properties);
318 XBT_PUBLIC(msg_process_t) MSG_process_attach(
319   const char *name, void *data,
320   msg_host_t host, xbt_dict_t properties);
321 XBT_PUBLIC(void) MSG_process_detach(void);
322
323 XBT_PUBLIC(void) MSG_process_kill(msg_process_t process);
324 XBT_PUBLIC(int) MSG_process_killall(int reset_PIDs);
325 XBT_PUBLIC(msg_error_t) MSG_process_migrate(msg_process_t process, msg_host_t host);
326
327 XBT_PUBLIC(void *) MSG_process_get_data(msg_process_t process);
328 XBT_PUBLIC(msg_error_t) MSG_process_set_data(msg_process_t process,
329                                              void *data);
330 XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup);
331 XBT_PUBLIC(msg_host_t) MSG_process_get_host(msg_process_t process);
332 XBT_PUBLIC(msg_process_t) MSG_process_from_PID(int PID);
333 XBT_PUBLIC(int) MSG_process_get_PID(msg_process_t process);
334 XBT_PUBLIC(int) MSG_process_get_PPID(msg_process_t process);
335 XBT_PUBLIC(const char *) MSG_process_get_name(msg_process_t process);
336 XBT_PUBLIC(int) MSG_process_self_PID(void);
337 XBT_PUBLIC(int) MSG_process_self_PPID(void);
338 XBT_PUBLIC(msg_process_t) MSG_process_self(void);
339 XBT_PUBLIC(xbt_dynar_t) MSG_processes_as_dynar(void);
340 XBT_PUBLIC(int) MSG_process_get_number(void);
341
342 XBT_PUBLIC(msg_error_t) MSG_process_set_kill_time(msg_process_t process, double kill_time);
343
344 /*property handlers*/
345 XBT_PUBLIC(xbt_dict_t) MSG_process_get_properties(msg_process_t process);
346 XBT_PUBLIC(const char *) MSG_process_get_property_value(msg_process_t
347                                                         process,
348                                                         const char *name);
349
350 XBT_PUBLIC(msg_error_t) MSG_process_suspend(msg_process_t process);
351 XBT_PUBLIC(msg_error_t) MSG_process_resume(msg_process_t process);
352 XBT_PUBLIC(int) MSG_process_is_suspended(msg_process_t process);
353 XBT_PUBLIC(void) MSG_process_on_exit(int_f_pvoid_pvoid_t fun, void *data);
354 XBT_PUBLIC(void) MSG_process_auto_restart_set(msg_process_t process, int auto_restart);
355
356 XBT_PUBLIC(msg_process_t) MSG_process_restart(msg_process_t process);
357
358 /************************** Task handling ************************************/
359 XBT_PUBLIC(msg_task_t) MSG_task_create(const char *name,
360                                      double flops_amount,
361                                      double bytes_amount, void *data);
362 XBT_PUBLIC(msg_task_t) MSG_parallel_task_create(const char *name,
363                                               int host_nb,
364                                               const msg_host_t * host_list,
365                                               double *flops_amount,
366                                               double *bytes_amount,
367                                               void *data);
368 XBT_PUBLIC(void *) MSG_task_get_data(msg_task_t task);
369 XBT_PUBLIC(void) MSG_task_set_data(msg_task_t task, void *data);
370 XBT_PUBLIC(void) MSG_task_set_copy_callback(void (*callback) (
371     msg_task_t task, msg_process_t src, msg_process_t dst));
372 XBT_PUBLIC(msg_process_t) MSG_task_get_sender(msg_task_t task);
373 XBT_PUBLIC(msg_host_t) MSG_task_get_source(msg_task_t task);
374 XBT_PUBLIC(const char *) MSG_task_get_name(msg_task_t task);
375 XBT_PUBLIC(void) MSG_task_set_name(msg_task_t task, const char *name);
376 XBT_PUBLIC(msg_error_t) MSG_task_cancel(msg_task_t task);
377 XBT_PUBLIC(msg_error_t) MSG_task_destroy(msg_task_t task);
378
379 XBT_PUBLIC(msg_error_t) MSG_task_execute(msg_task_t task);
380 XBT_PUBLIC(msg_error_t) MSG_parallel_task_execute(msg_task_t task);
381 XBT_PUBLIC(void) MSG_task_set_priority(msg_task_t task, double priority);
382 XBT_PUBLIC(void) MSG_task_set_bound(msg_task_t task, double bound);
383 XBT_PUBLIC(void) MSG_task_set_affinity(msg_task_t task, msg_host_t host, unsigned long mask);
384
385 XBT_PUBLIC(msg_error_t) MSG_process_join(msg_process_t process, double timeout);
386 XBT_PUBLIC(msg_error_t) MSG_process_sleep(double nb_sec);
387
388 XBT_PUBLIC(void) MSG_task_set_flops_amount(msg_task_t task,
389                                                double flops_amount);
390 XBT_PUBLIC(double) MSG_task_get_flops_amount(msg_task_t task);
391 XBT_PUBLIC(void) MSG_task_set_bytes_amount(msg_task_t task,
392                                         double bytes_amount);
393
394 XBT_PUBLIC(double) MSG_task_get_remaining_communication(msg_task_t task);
395 XBT_PUBLIC(int) MSG_task_is_latency_bounded(msg_task_t task);
396 XBT_PUBLIC(double) MSG_task_get_bytes_amount(msg_task_t task);
397
398
399 XBT_PUBLIC(msg_error_t)
400     MSG_task_receive_ext(msg_task_t * task, const char *alias, double timeout,
401                      msg_host_t host);
402
403 XBT_PUBLIC(msg_error_t)
404     MSG_task_receive_with_timeout(msg_task_t * task, const char *alias,
405                               double timeout);
406
407 XBT_PUBLIC(msg_error_t)
408     MSG_task_receive(msg_task_t * task, const char *alias);
409 #define MSG_task_recv(t,a) MSG_task_receive(t,a)
410
411
412
413 XBT_PUBLIC(msg_error_t)
414     MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, double timeout,
415                      msg_host_t host, double rate);
416
417 XBT_PUBLIC(msg_error_t) MSG_task_receive_with_timeout_bounded(msg_task_t * task, const char *alias,  double timeout, double rate);
418 XBT_PUBLIC(msg_error_t) MSG_task_receive_bounded(msg_task_t * task, const char *alias,double rate);
419 #define MSG_task_recv_bounded(t,a,r) MSG_task_receive_bounded(t,a,r)
420
421 XBT_PUBLIC(msg_comm_t) MSG_task_isend(msg_task_t task, const char *alias);
422 XBT_PUBLIC(msg_comm_t) MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate);
423 XBT_PUBLIC(msg_comm_t) MSG_task_isend_with_matching(msg_task_t task, const char *alias,
424     int (*match_fun)(void*,void*, smx_synchro_t), void *match_data);
425
426 XBT_PUBLIC(void) MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup);
427 XBT_PUBLIC(void) MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate);
428 XBT_PUBLIC(msg_comm_t) MSG_task_irecv(msg_task_t * task, const char *alias);
429 XBT_PUBLIC(msg_comm_t) MSG_task_irecv_bounded(msg_task_t * task, const char *alias, double rate);
430 XBT_PUBLIC(int) MSG_comm_test(msg_comm_t comm);
431 XBT_PUBLIC(int) MSG_comm_testany(xbt_dynar_t comms);
432 XBT_PUBLIC(void) MSG_comm_destroy(msg_comm_t comm);
433 XBT_PUBLIC(msg_error_t) MSG_comm_wait(msg_comm_t comm, double timeout);
434 XBT_PUBLIC(void) MSG_comm_waitall(msg_comm_t * comm, int nb_elem, double timeout);
435 XBT_PUBLIC(int) MSG_comm_waitany(xbt_dynar_t comms);
436 XBT_PUBLIC(msg_task_t) MSG_comm_get_task(msg_comm_t comm);
437 XBT_PUBLIC(msg_error_t) MSG_comm_get_status(msg_comm_t comm);
438
439 XBT_PUBLIC(int) MSG_task_listen(const char *alias);
440 XBT_PUBLIC(msg_error_t) MSG_task_send_with_timeout(msg_task_t task, const char *alias, double timeout);
441 XBT_PUBLIC(msg_error_t) MSG_task_send_with_timeout_bounded(msg_task_t task, const char *alias, double timeout, double maxrate);
442 XBT_PUBLIC(msg_error_t) MSG_task_send(msg_task_t task, const char *alias);
443 XBT_PUBLIC(msg_error_t) MSG_task_send_bounded(msg_task_t task, const char *alias, double rate);
444 XBT_PUBLIC(int) MSG_task_listen_from(const char *alias);
445 XBT_PUBLIC(void) MSG_task_set_category (msg_task_t task, const char *category);
446 XBT_PUBLIC(const char *) MSG_task_get_category (msg_task_t task);
447
448 /************************** Mailbox handling ************************************/
449 /* @brief MSG_mailbox_new - create a new mailbox.
450  * Creates a new mailbox identified by the key specified by the parameter alias and add it in the global dictionary.
451  * @param  alias  The alias of the mailbox to create.
452  * @return        The newly created mailbox.
453  */
454 XBT_PUBLIC(msg_mailbox_t) MSG_mailbox_new(const char *alias);
455
456 /* @brief MSG_mailbox_get_by_alias - get a mailbox from its alias.
457  * Returns the mailbox associated with the key specified by the parameter alias. If the mailbox does not exists,
458  * the function creates it.
459  * @param   alias    The alias of the mailbox to return.
460  * @return           The mailbox associated with the alias specified as parameter or a new one if the key doesn't match.
461  */
462 XBT_PUBLIC(msg_mailbox_t) MSG_mailbox_get_by_alias(const char *alias);
463
464 /* @brief MSG_mailbox_is_empty - test if a mailbox is empty.
465  * Tests if a mailbox is empty (contains no msg task).
466  * @param   mailbox  The mailbox to get test.
467  * @return           1 if the mailbox is empty, 0 otherwise.
468  */
469 XBT_PUBLIC(int) MSG_mailbox_is_empty(msg_mailbox_t mailbox);
470
471 /* @brief MSG_mailbox_set_async - set a mailbox as eager
472  * Sets the mailbox to a permanent receiver mode. Messages sent to this mailbox will then be sent just after the send
473  * is issued, without waiting for the corresponding receive.
474  * This call should be done before issuing any receive, and on the receiver's side only
475  * @param alias    The alias of the mailbox to modify.
476  */
477 XBT_PUBLIC(void) MSG_mailbox_set_async(const char *alias);
478
479 /* @brief MSG_mailbox_get_head - get the task at the head of a mailbox.
480  * Returns the task at the head of the mailbox. This function does not remove the task from the mailbox.
481  * @param   mailbox  The mailbox concerned by the operation.
482  * @return           The task at the head of the mailbox.
483  */
484 XBT_PUBLIC(msg_task_t) MSG_mailbox_front(msg_mailbox_t mailbox);
485
486 XBT_PUBLIC(msg_error_t) MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, msg_task_t * task, msg_host_t host,
487                                                  double timeout);
488 XBT_PUBLIC(msg_error_t) MSG_mailbox_get_task_ext_bounded(msg_mailbox_t mailbox, msg_task_t *task, msg_host_t host,
489                                                          double timeout, double rate);
490
491 /************************** Action handling **********************************/
492 XBT_PUBLIC(msg_error_t) MSG_action_trace_run(char *path);
493 XBT_PUBLIC(void) MSG_action_init(void);
494 XBT_PUBLIC(void) MSG_action_exit(void);
495
496 /** @brief Opaque type representing a semaphore
497  *  @ingroup msg_synchro
498  *  @hideinitializer
499  */
500 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
501 XBT_PUBLIC(msg_sem_t) MSG_sem_init(int initial_value);
502 XBT_PUBLIC(void) MSG_sem_acquire(msg_sem_t sem);
503 XBT_PUBLIC(msg_error_t) MSG_sem_acquire_timeout(msg_sem_t sem, double timeout);
504 XBT_PUBLIC(void) MSG_sem_release(msg_sem_t sem);
505 XBT_PUBLIC(void) MSG_sem_get_capacity(msg_sem_t sem);
506 XBT_PUBLIC(void) MSG_sem_destroy(msg_sem_t sem);
507 XBT_PUBLIC(int) MSG_sem_would_block(msg_sem_t sem);
508
509 /** @brief Opaque type representing a barrier identifier
510  *  @ingroup msg_synchro
511  *  @hideinitializer
512  */
513
514 #define MSG_BARRIER_SERIAL_PROCESS -1
515 typedef struct s_xbt_bar *msg_bar_t;
516 XBT_PUBLIC(msg_bar_t) MSG_barrier_init( unsigned int count);
517 XBT_PUBLIC(void) MSG_barrier_destroy(msg_bar_t bar);
518 XBT_PUBLIC(int) MSG_barrier_wait(msg_bar_t bar);
519
520 /** @brief Opaque type describing a Virtual Machine.
521  *  @ingroup msg_VMs
522  *
523  * All this is highly experimental and the interface will probably change in the future.
524  * Please don't depend on this yet (although testing is welcomed if you feel so).
525  * Usual lack of guaranty of any kind applies here, and is even increased.
526  *
527  */
528
529 XBT_PUBLIC(int) MSG_vm_is_created(msg_vm_t);
530 XBT_PUBLIC(int) MSG_vm_is_running(msg_vm_t);
531 XBT_PUBLIC(int) MSG_vm_is_migrating(msg_vm_t);
532
533 XBT_PUBLIC(int) MSG_vm_is_suspended(msg_vm_t);
534 XBT_PUBLIC(int) MSG_vm_is_saving(msg_vm_t);
535 XBT_PUBLIC(int) MSG_vm_is_saved(msg_vm_t);
536 XBT_PUBLIC(int) MSG_vm_is_restoring(msg_vm_t);
537
538
539 XBT_PUBLIC(const char*) MSG_vm_get_name(msg_vm_t);
540
541 // TODO add VDI later
542 XBT_PUBLIC(msg_vm_t) MSG_vm_create_core(msg_host_t location, const char *name);
543 XBT_PUBLIC(msg_vm_t) MSG_vm_create(msg_host_t ind_pm, const char *name,
544     int core_nb, int mem_cap, int net_cap, char *disk_path, int disk_size, int mig_netspeed, int dp_intensity);
545
546 XBT_PUBLIC(void) MSG_vm_destroy(msg_vm_t vm);
547
548 XBT_PUBLIC(void) MSG_vm_start(msg_vm_t);
549
550 /* Shutdown the guest operating system. */
551 XBT_PUBLIC(void) MSG_vm_shutdown(msg_vm_t vm);
552
553 XBT_PUBLIC(void) MSG_vm_migrate(msg_vm_t vm, msg_host_t destination);
554
555 /* Suspend the execution of the VM, but keep its state on memory. */
556 XBT_PUBLIC(void) MSG_vm_suspend(msg_vm_t vm);
557 XBT_PUBLIC(void) MSG_vm_resume(msg_vm_t vm);
558
559 /* Save the VM state to a disk. */
560 XBT_PUBLIC(void) MSG_vm_save(msg_vm_t vm);
561 XBT_PUBLIC(void) MSG_vm_restore(msg_vm_t vm);
562
563 XBT_PUBLIC(msg_host_t) MSG_vm_get_pm(msg_vm_t vm);
564 XBT_PUBLIC(void) MSG_vm_set_bound(msg_vm_t vm, double bound);
565 XBT_PUBLIC(void) MSG_vm_set_affinity(msg_vm_t vm, msg_host_t pm, unsigned long mask);
566
567 /* TODO: do we need this? */
568 // XBT_PUBLIC(xbt_dynar_t) MSG_vms_as_dynar(void);
569
570 /*
571 void* MSG_process_get_property(msg_process_t, char* key)
572 void MSG_process_set_property(msg_process_t, char* key, void* data)
573 void MSG_vm_set_property(msg_vm_t, char* key, void* data)
574
575 void MSG_vm_setMemoryUsed(msg_vm_t vm, double size);
576 void MSG_vm_setCpuUsed(msg_vm_t vm, double inducedLoad);
577   // inducedLoad: a percentage (>100 if it loads more than one core;
578   //                            <100 if it's not CPU intensive)
579   // Required contraints:
580   //   HOST_Power >= CpuUsedVm (\forall VM) + CpuUsedTask (\forall Task)
581   //   VM_coreAmount >= Load of all tasks
582 */
583
584   /*
585 xbt_dynar_t<msg_vm_t> MSG_vm_get_list_from_host(msg_host_t)
586 xbt_dynar_t<msg_vm_t> MSG_vm_get_list_from_hosts(msg_dynar_t<msg_host_t>)
587 + filtering functions on dynars
588 */
589 #include "simgrid/instr.h"
590
591
592
593 /* ****************************************************************************************** */
594 /* Used only by the bindings -- unclean pimple, please ignore if you're not writing a binding */
595 XBT_PUBLIC(smx_context_t) MSG_process_get_smx_ctx(msg_process_t process);
596
597
598 /* Functions renamed in 3.14 */
599 #define MSG_mailbox_get_head(m) MSG_mailbox_front(m)
600
601
602 SG_END_DECL()
603 #endif