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 * - <b>priority/priority.c</b>: Demonstrates the use of @ref
13 * MSG_task_set_priority to change the computation priority of a given task.
16 static int test(int argc, char *argv[])
18 double computation_amount = xbt_str_parse_double(argv[1], "Invalid argument: %s");
19 double priority = xbt_str_parse_double(argv[2], "Invalid argument: %s");
21 XBT_INFO("Hello! Running a task of size %g with priority %g", computation_amount, priority);
22 msg_task_t task = MSG_task_create("Task", computation_amount, 0.0, NULL);
23 MSG_task_set_priority(task, priority);
25 MSG_task_execute(task);
26 MSG_task_destroy(task);
28 XBT_INFO("Goodbye now!");
32 int main(int argc, char *argv[])
34 msg_error_t res = MSG_OK;
36 MSG_init(&argc, argv);
37 xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
38 "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
40 MSG_create_environment(argv[1]);
41 MSG_function_register("test", test);
42 MSG_launch_application(argv[2]);
46 XBT_INFO("Simulation time %g", MSG_get_clock());