Logo AND Algorithmique Numérique Distribuée

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