Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix copyright headers in simdag
[simgrid.git] / src / simdag / sd_task.c
index 501f2a4..8dea332 100644 (file)
@@ -1,3 +1,8 @@
+/* Copyright (c) 2007-2009 Da 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 "private.h"
 #include "simdag/simdag.h"
 #include "xbt/sysdep.h"
@@ -129,14 +134,12 @@ void __SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state)
   case SD_RUNNING:
     task->state_set = sd_global->running_task_set;
     task->start_time =
-      surf_workstation_model->common_public->action_get_start_time(task->
-                                                                   surf_action);
+      surf_workstation_model->action_get_start_time(task->surf_action);
     break;
   case SD_DONE:
     task->state_set = sd_global->done_task_set;
     task->finish_time =
-      surf_workstation_model->common_public->action_get_finish_time(task->
-                                                                    surf_action);
+      surf_workstation_model->action_get_finish_time(task->surf_action);
     task->remains = 0;
     break;
   case SD_FAILED:
@@ -195,7 +198,7 @@ double SD_task_get_remaining_amount(SD_task_t task)
   xbt_assert0(task != NULL, "Invalid parameter");
 
   if (task->surf_action)
-    return task->surf_action->remains;
+    return surf_workstation_model->get_remains(task->surf_action);
   else
     return task->remains;
 }
@@ -413,7 +416,7 @@ void SD_task_dependency_remove(SD_task_t src, SD_task_t dst)
   if (xbt_dynar_length(dst->tasks_before) == 0 && __SD_task_is_scheduled(dst))
     __SD_task_set_state(dst, SD_READY);
 
-  /*  __SD_print_dependencies(src); 
+  /*  __SD_print_dependencies(src);
      __SD_print_dependencies(dst); */
 }
 
@@ -476,7 +479,7 @@ static void __SD_print_watch_points(SD_task_t task)
  * SD_simulate() will stop as soon as the \ref e_SD_task_state_t "state" of this
  * task becomes the one given in argument. The
  * watch point is then automatically removed.
- * 
+ *
  * \param task a task
  * \param state the \ref e_SD_task_state_t "state" you want to watch
  * (cannot be #SD_NOT_SCHEDULED)
@@ -497,7 +500,7 @@ void SD_task_watch(SD_task_t task, e_SD_task_state_t state)
 
 /**
  * \brief Removes a watch point from a task
- * 
+ *
  * \param task a task
  * \param state the \ref e_SD_task_state_t "state" you no longer want to watch
  * \see SD_task_watch()
@@ -515,10 +518,10 @@ void SD_task_unwatch(SD_task_t task, e_SD_task_state_t state)
 
 /**
  * \brief Returns an approximative estimation of the execution time of a task.
- * 
+ *
  * The estimation is very approximative because the value returned is the time
  * the task would take if it was executed now and if it was the only task.
- * 
+ *
  * \param task the task to evaluate
  * \param workstation_nb number of workstations on which the task would be executed
  * \param workstation_list the workstations on which the task would be executed
@@ -570,7 +573,7 @@ double SD_task_get_execution_time(SD_task_t task,
  * The task state must be #SD_NOT_SCHEDULED.
  * Once scheduled, a task will be executed as soon as possible in SD_simulate(),
  * i.e. when its dependencies are satisfied.
- * 
+ *
  * \param task the task you want to schedule
  * \param workstation_nb number of workstations on which the task will be executed
  * \param workstation_list the workstations on which the task will be executed
@@ -645,7 +648,7 @@ void SD_task_unschedule(SD_task_t task)
     __SD_task_destroy_scheduling_data(task);
 
   if (__SD_task_is_running(task))       /* the task should become SD_FAILED */
-    surf_workstation_model->common_public->action_cancel(task->surf_action);
+    surf_workstation_model->action_cancel(task->surf_action);
   else
     __SD_task_set_state(task, SD_NOT_SCHEDULED);
   task->remains = task->amount;
@@ -713,18 +716,14 @@ void __SD_task_really_run(SD_task_t task)
   task->surf_action = NULL;
   if ((task->workstation_nb == 1) && (task->communication_amount[0] == 0.0)) {
     task->surf_action =
-      surf_workstation_model->extension_public->execute(surf_workstations[0],
-                                                        task->
-                                                        computation_amount
-                                                        [0]);
+      surf_workstation_model->extension.
+      workstation.execute(surf_workstations[0], task->computation_amount[0]);
   } else if ((task->workstation_nb == 1)
              && (task->computation_amount[0] == 0.0)) {
     task->surf_action =
-      surf_workstation_model->
-      extension_public->communicate(surf_workstations[0],
-                                    surf_workstations[0],
-                                    task->communication_amount[0],
-                                    task->rate);
+      surf_workstation_model->extension.
+      workstation.communicate(surf_workstations[0], surf_workstations[0],
+                              task->communication_amount[0], task->rate);
   } else if ((task->workstation_nb == 2)
              && (task->computation_amount[0] == 0.0)
              && (task->computation_amount[1] == 0.0)) {
@@ -739,10 +738,9 @@ void __SD_task_really_run(SD_task_t task)
     }
     if (nb == 1) {
       task->surf_action =
-        surf_workstation_model->
-        extension_public->communicate(surf_workstations[0],
-                                      surf_workstations[1], value,
-                                      task->rate);
+        surf_workstation_model->extension.
+        workstation.communicate(surf_workstations[0], surf_workstations[1],
+                                value, task->rate);
     }
   }
   if (!task->surf_action) {
@@ -756,21 +754,16 @@ void __SD_task_really_run(SD_task_t task)
            sizeof(double) * task->workstation_nb * task->workstation_nb);
 
     task->surf_action =
-      surf_workstation_model->extension_public->execute_parallel_task(task->
-                                                                      workstation_nb,
-                                                                      surf_workstations,
-                                                                      computation_amount,
-                                                                      communication_amount,
-                                                                      task->
-                                                                      amount,
-                                                                      task->
-                                                                      rate);
+      surf_workstation_model->extension.
+      workstation.execute_parallel_task(task->workstation_nb,
+                                        surf_workstations, computation_amount,
+                                        communication_amount, task->amount,
+                                        task->rate);
   } else {
     xbt_free(surf_workstations);
   }
 
-  surf_workstation_model->common_public->action_set_data(task->surf_action,
-                                                         task);
+  surf_workstation_model->action_data_set(task->surf_action, task);
 
   DEBUG1("surf_action = %p", task->surf_action);
 
@@ -854,7 +847,7 @@ void __SD_task_just_done(SD_task_t task)
   candidates = xbt_new(SD_task_t, 8);
 
   __SD_task_set_state(task, SD_DONE);
-  surf_workstation_model->common_public->action_free(task->surf_action);
+  surf_workstation_model->action_unref(task->surf_action);
   task->surf_action = NULL;
 
   DEBUG0("Looking for candidates");
@@ -1008,8 +1001,7 @@ double SD_task_get_start_time(SD_task_t task)
   SD_CHECK_INIT_DONE();
   xbt_assert0(task != NULL, "Invalid parameter");
   if (task->surf_action)
-    return surf_workstation_model->common_public->action_get_start_time(task->
-                                                                        surf_action);
+    return surf_workstation_model->action_get_start_time(task->surf_action);
   else
     return task->start_time;
 }
@@ -1019,7 +1011,7 @@ double SD_task_get_start_time(SD_task_t task)
  *
  * The task state must be SD_RUNNING, SD_DONE or SD_FAILED.
  * If the state is not completed yet, the returned value is an
- * estimation of the task finish time. This value can fluctuate 
+ * estimation of the task finish time. This value can fluctuate
  * until the task is completed.
  *
  * \param task: a task
@@ -1031,8 +1023,7 @@ double SD_task_get_finish_time(SD_task_t task)
   xbt_assert0(task != NULL, "Invalid parameter");
 
   if (task->surf_action)        /* should never happen as actions are destroyed right after their completion */
-    return surf_workstation_model->common_public->
-      action_get_finish_time(task->surf_action);
+    return surf_workstation_model->action_get_finish_time(task->surf_action);
   else
     return task->finish_time;
 }
@@ -1062,7 +1053,7 @@ void SD_task_destroy(SD_task_t task)
     xbt_free(task->name);
 
   if (task->surf_action != NULL)
-    surf_workstation_model->common_public->action_free(task->surf_action);
+    surf_workstation_model->action_unref(task->surf_action);
 
   if (task->workstation_list != NULL)
     xbt_free(task->workstation_list);