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 = 0.0;
19 double priority = 1.0;
20 msg_task_t task = NULL;
22 XBT_ATTRIB_UNUSED int res = sscanf(argv[1], "%lg", &computation_amount);
23 xbt_assert(res, "Invalid argument %s\n", argv[1]);
24 res = sscanf(argv[2], "%lg", &priority);
25 xbt_assert(res, "Invalid argument %s\n", argv[2]);
27 XBT_INFO("Hello! Running a task of size %g with priority %g", computation_amount, priority);
28 task = MSG_task_create("Task", computation_amount, 0.0, NULL);
29 MSG_task_set_priority(task, priority);
31 MSG_task_execute(task);
32 MSG_task_destroy(task);
34 XBT_INFO("Goodbye now!");
38 int main(int argc, char *argv[])
40 msg_error_t res = MSG_OK;
42 MSG_init(&argc, argv);
43 xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
44 "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]);
46 MSG_create_environment(argv[1]);
47 MSG_function_register("test", test);
48 MSG_launch_application(argv[2]);
52 XBT_INFO("Simulation time %g", MSG_get_clock());