1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include "simgrid/msg.h"
8 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
10 /** @addtogroup MSG_examples
12 * @section msg_ex_misc Miscellaneous
13 * - <b>Task priorities: task-priority/task-priority.c</b>. This examples demonstrates the use of
14 * @ref MSG_task_set_priority to change the computation priority of a given task.
17 static int test(int argc, char *argv[])
19 double computation_amount = xbt_str_parse_double(argv[1], "Invalid argument: %s");
20 double priority = xbt_str_parse_double(argv[2], "Invalid argument: %s");
22 XBT_INFO("Hello! Running a task of size %g with priority %g", computation_amount, priority);
23 msg_task_t task = MSG_task_create("Task", computation_amount, 0.0, NULL);
24 MSG_task_set_priority(task, priority);
26 MSG_task_execute(task);
27 MSG_task_destroy(task);
29 XBT_INFO("Goodbye now!");
33 int main(int argc, char *argv[])
35 msg_error_t res = MSG_OK;
37 MSG_init(&argc, argv);
38 xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
39 "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
41 MSG_create_environment(argv[1]);
42 MSG_function_register("test", test);
43 MSG_launch_application(argv[2]);
47 XBT_INFO("Simulation time %g", MSG_get_clock());