1 /* Copyright (c) 2007-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/msg.h"
7 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
9 static int test(int argc, char* argv[])
11 xbt_assert(argc == 3);
12 double computation_amount = xbt_str_parse_double(argv[1], "Invalid argument: %s");
13 double priority = xbt_str_parse_double(argv[2], "Invalid argument: %s");
15 XBT_INFO("Hello! Running a task of size %g with priority %g", computation_amount, priority);
16 msg_task_t task = MSG_task_create("Task", computation_amount, 0.0, NULL);
17 MSG_task_set_priority(task, priority);
19 MSG_task_execute(task);
20 MSG_task_destroy(task);
22 XBT_INFO("Goodbye now!");
26 int main(int argc, char* argv[])
28 MSG_init(&argc, argv);
29 xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
30 "\tExample: %s msg_platform.xml msg_deployment.xml\n",
33 MSG_create_environment(argv[1]);
34 MSG_function_register("test", test);
35 MSG_launch_application(argv[2]);
37 msg_error_t res = MSG_main();
39 XBT_INFO("Simulation time %g", MSG_get_clock());