Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
SimDag Revolution: SD_workstation becomes sg_host
[simgrid.git] / teshsuite / simdag / availability / availability_test.c
index 1fb03f4..a426e74 100644 (file)
@@ -1,9 +1,15 @@
+/* Copyright (c) 2013-2015. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stddef.h>
 #include <unistd.h>
-#include <simdag/simdag.h>
+#include <simgrid/simdag.h>
 #include <xbt/log.h>
 #include <xbt/ex.h>
 #include <signal.h>
@@ -51,8 +57,8 @@ static void checkParameters(int argc, char *argv[])
 static int name_compare_hosts(const void *n1, const void *n2)
 {
   char name1[80], name2[80];
-  strcpy(name1, SD_workstation_get_name(*((SD_workstation_t *) n1)));
-  strcpy(name2, SD_workstation_get_name(*((SD_workstation_t *) n2)));
+  strcpy(name1, sg_host_get_name(*((sg_host_t *) n1)));
+  strcpy(name2, sg_host_get_name(*((sg_host_t *) n2)));
 
   return strcmp(name1, name2);
 }
@@ -62,25 +68,24 @@ static void scheduleDAX(xbt_dynar_t dax)
   unsigned int cursor;
   SD_task_t task;
 
-  const SD_workstation_t *ws_list = SD_workstation_get_list();
-  int totalHosts = SD_workstation_get_number();
-  qsort((void *) ws_list, totalHosts, sizeof(SD_workstation_t),
+  const sg_host_t *ws_list = sg_host_list();
+  int totalHosts = sg_host_count();
+  qsort((void *) ws_list, totalHosts, sizeof(sg_host_t),
         name_compare_hosts);
 
-  int count = SD_workstation_get_number();
-  //fprintf(stdout, "No. workstations: %d, %d\n", count, (dax != NULL));
+  //fprintf(stdout, "No. workstations: %d, %d\n", totalHosts, (dax != NULL));
 
   xbt_dynar_foreach(dax, cursor, task) {
     if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
       if (!strcmp(SD_task_get_name(task), "end")
           || !strcmp(SD_task_get_name(task), "root")) {
         fprintf(stdout, "Scheduling %s to node: %s\n", SD_task_get_name(task),
-                SD_workstation_get_name(ws_list[0]));
+                sg_host_get_name(ws_list[0]));
         SD_task_schedulel(task, 1, ws_list[0]);
       } else {
         fprintf(stdout, "Scheduling %s to node: %s\n", SD_task_get_name(task),
-                SD_workstation_get_name(ws_list[(cursor) % count]));
-        SD_task_schedulel(task, 1, ws_list[(cursor) % count]);
+                sg_host_get_name(ws_list[(cursor) % totalHosts]));
+        SD_task_schedulel(task, 1, ws_list[(cursor) % totalHosts]);
       }
     }
   }
@@ -149,11 +154,11 @@ static xbt_dynar_t initDynamicThrottling(int *argc, char *argv[])
  */
 static void garbageCollector(xbt_dynar_t dax)
 {
-  SD_task_t task;
-  unsigned int cursor;
-  xbt_dynar_foreach(dax, cursor, task) {
+  while (!xbt_dynar_is_empty(dax)) {
+    SD_task_t task = xbt_dynar_pop_as(dax, SD_task_t);
     SD_task_destroy(task);
   }
+  xbt_dynar_free(&dax);
   SD_exit();
 }