+/* Runs a task. This function is called by SD_simulate() when a scheduled task can start
+ * (ie when its dependencies are satisfied).
+ */
+surf_action_t __SD_task_run(SD_task_t task) {
+ SD_CHECK_INIT_DONE();
+ xbt_assert0(task != NULL, "Invalid parameter");
+ xbt_assert2(__SD_task_is_ready(task), "Task '%s' is not ready! Task state: %d",
+ SD_task_get_name(task), SD_task_get_state(task));
+
+ surf_action_t surf_action = surf_workstation_resource->extension_public->
+ execute_parallel_task(task->workstation_nb,
+ task->workstation_list,
+ task->computation_amount,
+ task->communication_amount,
+ task->amount,
+ task->rate);
+
+ DEBUG1("surf_action = %p", surf_action);
+
+ __SD_task_destroy_scheduling_data(task); /* now the scheduling data are not useful anymore */
+ __SD_task_set_state(task, SD_RUNNING);
+
+ return surf_action;
+}
+/* Remove all dependencies associated with a task. This function is called when the task is destroyed.
+ */
+static void __SD_task_remove_dependencies(SD_task_t task) {
+ /* we must destroy the dependencies carefuly (with SD_dependency_remove)
+ because each one is stored twice */
+ SD_dependency_t dependency;
+ while (xbt_dynar_length(task->tasks_before) > 0) {
+ xbt_dynar_get_cpy(task->tasks_before, 0, &dependency);
+ SD_task_dependency_remove(dependency->src, dependency->dst);
+ }
+
+ while (xbt_dynar_length(task->tasks_after) > 0) {
+ xbt_dynar_get_cpy(task->tasks_after, 0, &dependency);
+ SD_task_dependency_remove(dependency->src, dependency->dst);
+ }
+}
+
+/**
+ * \brief Destroys a task.
+ *
+ * The user data (if any) should have been destroyed first.
+ *
+ * \param task the task you want to destroy
+ * \see SD_task_create()