1 /* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved. */
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. */
6 #include "simgrid/Exception.hpp"
7 #include "src/msg/msg_private.hpp"
9 #define MSG_CALL(type, oldname, args)
11 /* ************************** Engine *************************** */
12 void MSG_create_environment(const char* filename)
14 simgrid_load_platform(filename);
17 void MSG_launch_application(const char* filename)
19 simgrid_load_deployment(filename);
21 msg_error_t MSG_main()
26 void MSG_function_register(const char* name, xbt_main_func_t code)
28 simgrid_register_function(name, code);
30 void MSG_function_register_default(xbt_main_func_t code)
32 simgrid_register_default(code);
34 double MSG_get_clock()
36 return simgrid_get_clock();
39 /* ************************** Mailboxes ************************ */
40 void MSG_mailbox_set_async(const char* alias)
42 sg_mailbox_set_receiver(alias);
44 int MSG_task_listen(const char* alias)
46 return sg_mailbox_listen(alias);
49 /* ************************** Actors *************************** */
50 int MSG_process_get_PID(sg_actor_t actor)
52 return sg_actor_get_PID(actor);
54 int MSG_process_get_PPID(sg_actor_t actor)
56 return sg_actor_get_PPID(actor);
58 msg_process_t MSG_process_from_PID(int PID)
60 return sg_actor_by_PID(PID);
62 const char* MSG_process_get_name(sg_actor_t actor)
64 return sg_actor_get_name(actor);
66 sg_host_t MSG_process_get_host(sg_actor_t actor)
68 return sg_actor_get_host(actor);
70 xbt_dict_t MSG_process_get_properties(sg_actor_t actor)
72 return sg_actor_get_properties(actor);
74 const char* MSG_process_get_property_value(sg_actor_t actor, const char* name)
76 return sg_actor_get_property_value(actor, name);
78 void MSG_process_suspend(sg_actor_t actor)
80 sg_actor_suspend(actor);
82 void MSG_process_resume(sg_actor_t actor)
84 sg_actor_resume(actor);
86 int MSG_process_is_suspended(sg_actor_t actor)
88 return sg_actor_is_suspended(actor);
90 void MSG_process_restart(sg_actor_t actor)
92 sg_actor_restart(actor);
94 void MSG_process_auto_restart_set(sg_actor_t actor, int auto_restart)
96 sg_actor_set_auto_restart(actor, auto_restart);
99 void MSG_process_daemonize(sg_actor_t actor)
101 sg_actor_daemonize(actor);
103 void MSG_process_migrate(sg_actor_t actor, sg_host_t host)
105 sg_actor_migrate(actor, host);
107 void MSG_process_join(sg_actor_t actor, double timeout)
109 sg_actor_join(actor, timeout);
111 void MSG_process_kill(sg_actor_t actor)
113 sg_actor_kill(actor);
115 void MSG_process_killall()
119 void MSG_process_set_kill_time(sg_actor_t actor, double kill_time)
121 sg_actor_set_kill_time(actor, kill_time);
123 void MSG_process_yield()
128 msg_error_t MSG_process_sleep(double duration)
131 sg_actor_sleep_for(duration);
133 } catch (const simgrid::HostFailureException&) {
134 return MSG_HOST_FAILURE;
138 msg_process_t MSG_process_attach(const char* name, void* data, msg_host_t host, xbt_dict_t properties)
140 return sg_actor_attach(name, data, host, properties);
143 void MSG_process_detach()
148 /* ************************** NetZones *************************** */
149 sg_netzone_t MSG_zone_get_root()
151 return sg_zone_get_root();
153 const char* MSG_zone_get_name(sg_netzone_t zone)
155 return sg_zone_get_name(zone);
157 sg_netzone_t MSG_zone_get_by_name(const char* name)
159 return sg_zone_get_by_name(name);
161 void MSG_zone_get_sons(sg_netzone_t zone, xbt_dict_t whereto)
163 return sg_zone_get_sons(zone, whereto);
165 const char* MSG_zone_get_property_value(sg_netzone_t zone, const char* name)
167 return sg_zone_get_property_value(zone, name);
169 void MSG_zone_set_property_value(sg_netzone_t zone, const char* name, char* value)
171 sg_zone_set_property_value(zone, name, value);
173 void MSG_zone_get_hosts(sg_netzone_t zone, xbt_dynar_t whereto)
175 sg_zone_get_hosts(zone, whereto);
178 /* ************************** Storages *************************** */
179 const char* MSG_storage_get_name(sg_storage_t storage)
181 return sg_storage_get_name(storage);
183 sg_storage_t MSG_storage_get_by_name(const char* name)
185 return sg_storage_get_by_name(name);
187 xbt_dict_t MSG_storage_get_properties(sg_storage_t storage)
189 return sg_storage_get_properties(storage);
191 void MSG_storage_set_property_value(sg_storage_t storage, const char* name, const char* value)
193 sg_storage_set_property_value(storage, name, value);
195 const char* MSG_storage_get_property_value(sg_storage_t storage, const char* name)
197 return sg_storage_get_property_value(storage, name);
199 xbt_dynar_t MSG_storages_as_dynar()
201 return sg_storages_as_dynar();
203 void MSG_storage_set_data(sg_storage_t storage, void* data)
205 sg_storage_set_data(storage, data);
207 void* MSG_storage_get_data(sg_storage_t storage)
209 return sg_storage_get_data(storage);
211 const char* MSG_storage_get_host(sg_storage_t storage)
213 return sg_storage_get_host(storage);
215 sg_size_t MSG_storage_read(sg_storage_t storage, sg_size_t size)
217 return sg_storage_read(storage, size);
219 sg_size_t MSG_storage_write(sg_storage_t storage, sg_size_t size)
221 return sg_storage_write(storage, size);
224 /* ************************** hosts *************************** */
225 xbt_dynar_t MSG_hosts_as_dynar()
227 return sg_hosts_as_dynar();
229 size_t MSG_get_host_number()
231 return sg_host_count();
233 sg_host_t MSG_get_host_by_name(const char* name)
235 return sg_host_by_name(name);
237 sg_host_t MSG_host_by_name(const char* name)
239 return sg_host_by_name(name);
241 const char* MSG_host_get_name(sg_host_t host)
243 return sg_host_get_name(host);
245 void* MSG_host_get_data(sg_host_t host)
247 return sg_host_user(host);
249 void MSG_host_set_data(sg_host_t host, void* data)
251 return sg_host_user_set(host, data);
253 xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host)
255 return sg_host_get_mounted_storage_list(host);
257 xbt_dynar_t MSG_host_get_attached_storage_lists(sg_host_t host)
259 return sg_host_get_attached_storage_list(host);
261 double MSG_host_get_speed(sg_host_t host)
263 return sg_host_speed(host);
265 double MSG_host_get_power_peak_at(sg_host_t host, int pstate_index)
267 return sg_host_get_pstate_speed(host, pstate_index);
269 int MSG_host_get_core_number(sg_host_t host)
271 return sg_host_core_count(host);
273 int MSG_host_get_nb_pstates(sg_host_t host)
275 return sg_host_get_nb_pstates(host);
277 int MSG_host_get_pstate(sg_host_t host)
279 return sg_host_get_pstate(host);
281 void MSG_host_set_pstate(sg_host_t host, int pstate)
283 sg_host_set_pstate(host, pstate);
285 void MSG_host_on(sg_host_t h)
289 void MSG_host_off(sg_host_t h)
293 int MSG_host_is_on(sg_host_t h)
295 return sg_host_is_on(h);
297 int MSG_host_is_off(sg_host_t h) // deprecated
299 return not sg_host_is_on(h);
301 xbt_dict_t MSG_host_get_properties(sg_host_t host)
303 return sg_host_get_properties(host);
305 const char* MSG_host_get_property_value(sg_host_t host, const char* name)
307 return sg_host_get_property_value(host, name);
309 void MSG_host_set_property_value(sg_host_t host, const char* name, const char* value)
311 sg_host_set_property_value(host, name, value);
313 void MSG_host_get_process_list(sg_host_t host, xbt_dynar_t whereto)
315 sg_host_get_actor_list(host, whereto);
317 sg_host_t MSG_host_self()
319 return sg_host_self();
322 double MSG_host_get_load(sg_host_t host)
324 return sg_host_load(host);
326 /* ************************** Virtual Machines *************************** */
327 sg_vm_t MSG_vm_create_core(sg_host_t pm, const char* name)
329 return sg_vm_create_core(pm, name);
331 sg_vm_t MSG_vm_create_multicore(sg_host_t pm, const char* name, int coreAmount)
333 return sg_vm_create_multicore(pm, name, coreAmount);
335 int MSG_vm_is_created(sg_vm_t vm)
337 return sg_vm_is_created(vm);
339 int MSG_vm_is_running(sg_vm_t vm)
341 return sg_vm_is_running(vm);
343 int MSG_vm_is_suspended(sg_vm_t vm)
345 return sg_vm_is_suspended(vm);
347 const char* MSG_vm_get_name(sg_vm_t vm)
349 return sg_vm_get_name(vm);
351 void MSG_vm_set_ramsize(sg_vm_t vm, size_t size)
353 sg_vm_set_ramsize(vm, size);
355 size_t MSG_vm_get_ramsize(sg_vm_t vm)
357 return sg_vm_get_ramsize(vm);
359 sg_host_t MSG_vm_get_pm(sg_vm_t vm)
361 return sg_vm_get_pm(vm);
363 void MSG_vm_set_bound(sg_vm_t vm, double bound)
365 sg_vm_set_bound(vm, bound);
367 void MSG_vm_start(sg_vm_t vm)
371 void MSG_vm_suspend(sg_vm_t vm)
375 void MSG_vm_resume(sg_vm_t vm)
379 void MSG_vm_shutdown(sg_vm_t vm)
383 void MSG_vm_destroy(sg_vm_t vm)
387 /********* barriers ************/
388 sg_bar_t MSG_barrier_init(unsigned int count)
390 return sg_barrier_init(count);
393 void MSG_barrier_destroy(sg_bar_t bar)
395 sg_barrier_destroy(bar);
398 int MSG_barrier_wait(sg_bar_t bar)
400 return sg_barrier_wait(bar);
403 sg_sem_t MSG_sem_init(int initial_value)
405 return sg_sem_init(initial_value);
407 void MSG_sem_acquire(sg_sem_t sem)
411 int MSG_sem_acquire_timeout(sg_sem_t sem, double timeout)
413 return sg_sem_acquire_timeout(sem, timeout);
415 void MSG_sem_release(sg_sem_t sem)
419 int MSG_sem_get_capacity(sg_sem_t sem)
421 return sg_sem_get_capacity(sem);
423 void MSG_sem_destroy(sg_sem_t sem)
427 int MSG_sem_would_block(sg_sem_t sem)
429 return sg_sem_would_block(sem);