Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sort examples, improve doc
[simgrid.git] / teshsuite / msg / task-priority / task-priority.c
1 /* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "simgrid/msg.h"
7 XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
8
9 static int test(int argc, char* argv[])
10 {
11   double computation_amount = xbt_str_parse_double(argv[1], "Invalid argument: %s");
12   double priority           = xbt_str_parse_double(argv[2], "Invalid argument: %s");
13
14   XBT_INFO("Hello! Running a task of size %g with priority %g", computation_amount, priority);
15   msg_task_t task = MSG_task_create("Task", computation_amount, 0.0, NULL);
16   MSG_task_set_priority(task, priority);
17
18   MSG_task_execute(task);
19   MSG_task_destroy(task);
20
21   XBT_INFO("Goodbye now!");
22   return 0;
23 }
24
25 int main(int argc, char* argv[])
26 {
27   MSG_init(&argc, argv);
28   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n"
29                        "\tExample: %s msg_platform.xml msg_deployment.xml\n",
30              argv[0], argv[0]);
31
32   MSG_create_environment(argv[1]);
33   MSG_function_register("test", test);
34   MSG_launch_application(argv[2]);
35
36   msg_error_t res = MSG_main();
37
38   XBT_INFO("Simulation time %g", MSG_get_clock());
39
40   return res != MSG_OK;
41 }