1 /* Copyright (c) 2006, 2007, 2008, 2009, 2010. 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. */
9 #include "simdag/simdag.h"
13 XBT_LOG_NEW_DEFAULT_CATEGORY(sd_seq_access,
14 "Logging specific to this SimDag example");
16 int main(int argc, char **argv)
19 const char *platform_file;
20 const SD_workstation_t *workstations;
21 SD_task_t taskA, taskB, taskC;
22 xbt_dynar_t changed_tasks;
24 /* initialisation of SD */
27 /* xbt_log_control_set("sd.thres=debug"); */
30 XBT_INFO("Usage: %s platform_file", argv[0]);
31 XBT_INFO("example: %s sd_platform.xml", argv[0]);
35 /* creation of the environment */
36 platform_file = argv[1];
37 SD_create_environment(platform_file);
39 /* Change the access mode of the workstations */
40 workstations = SD_workstation_get_list();
41 for (i = 0; i < 2; i++) {
42 SD_workstation_dump(workstations[i]);
44 SD_workstation_set_access_mode(workstations[i],
45 SD_WORKSTATION_SEQUENTIAL_ACCESS);
46 XBT_INFO(" Change access mode of %s to %s",
47 SD_workstation_get_name(workstations[i]),
48 (SD_workstation_get_access_mode(workstations[i]) ==
49 SD_WORKSTATION_SEQUENTIAL_ACCESS) ? "sequential" : "shared");
52 /* creation of the tasks and their dependencies */
53 taskA = SD_task_create_comp_seq("Task A", NULL, 2e10);
54 taskB = SD_task_create_comm_e2e("Task B", NULL, 2e8);
55 taskC = SD_task_create_comp_seq("Task C", NULL, 1e10);
57 /* if everything is ok, no exception is forwarded or rethrown by main() */
60 SD_task_watch(taskA, SD_RUNNING);
61 SD_task_watch(taskB, SD_RUNNING);
62 SD_task_watch(taskC, SD_RUNNING);
63 SD_task_watch(taskC, SD_DONE);
66 /* scheduling parameters */
67 SD_task_schedulel(taskA, 1, workstations[0]);
68 SD_task_schedulel(taskB, 2, workstations[0], workstations[1]);
69 SD_task_schedulel(taskC, 1, workstations[1]);
71 /* let's launch the simulation! */
72 while (!xbt_dynar_is_empty(changed_tasks = SD_simulate(-1.0))) {
73 XBT_INFO(" Simulation was suspended, check workstation states");
74 for (i = 0; i < 2; i++) {
75 SD_workstation_dump(workstations[i]);
77 xbt_dynar_free(&changed_tasks);
79 xbt_dynar_free(&changed_tasks);
81 XBT_DEBUG("Destroying tasks...");
83 SD_task_destroy(taskA);
84 SD_task_destroy(taskB);
85 SD_task_destroy(taskC);
87 XBT_DEBUG("Tasks destroyed. Exiting SimDag...");