+ DEBUG1("Candidates found: %d", candidate_nb);
+
+ /* now we check every candidate task */
+ for (i = 0; i < candidate_nb; i++) {
+ candidate = candidates[i];
+
+ if (candidate->fifo_checked) {
+ continue; /* we have already evaluated that task */
+ }
+
+ xbt_assert2(__SD_task_is_in_fifo(candidate),
+ "Bad state of candidate '%s': %d",
+ SD_task_get_name(candidate), SD_task_get_state(candidate));
+
+ for (j = 0; j < candidate->workstation_nb && can_start; j++) {
+ workstation = candidate->workstation_list[j];
+
+ /* I can start on this workstation if the workstation is shared
+ or if I am the first task in the fifo */
+ can_start = workstation->access_mode == SD_WORKSTATION_SHARED_ACCESS ||
+ candidate ==
+ xbt_fifo_get_item_content(xbt_fifo_get_first_item
+ (workstation->task_fifo));
+ }
+
+ DEBUG2("Candidate '%s' can start: %d", SD_task_get_name(candidate),
+ can_start);
+
+ /* now we are sure that I can start! */
+ if (can_start) {
+ for (j = 0; j < candidate->workstation_nb && can_start; j++) {
+ workstation = candidate->workstation_list[j];
+
+ /* update the fifo */
+ if (workstation->access_mode == SD_WORKSTATION_SEQUENTIAL_ACCESS) {
+ candidate = xbt_fifo_shift(workstation->task_fifo); /* the return value is stored just for debugging */
+ DEBUG1("Head of the fifo: '%s'",
+ (candidate != NULL) ? SD_task_get_name(candidate) : "NULL");
+ xbt_assert0(candidate == candidates[i],
+ "Error in __SD_task_just_done: bad first task in the fifo");
+ }
+ } /* for each workstation */
+
+ /* finally execute the task */
+ DEBUG2("Task '%s' state: %d", SD_task_get_name(candidate),
+ SD_task_get_state(candidate));
+ __SD_task_really_run(candidate);
+
+ DEBUG4
+ ("Calling __SD_task_is_running: task '%s', state set: %p, running_task_set: %p, is running: %d",
+ SD_task_get_name(candidate), candidate->state_set,
+ sd_global->running_task_set, __SD_task_is_running(candidate));
+ xbt_assert2(__SD_task_is_running(candidate),
+ "Bad state of task '%s': %d", SD_task_get_name(candidate),
+ SD_task_get_state(candidate));
+ DEBUG0("Okay, the task is running.");
+
+ } /* can start */
+ candidate->fifo_checked = 1;
+ } /* for each candidate */
+
+ xbt_free(candidates);
+}
+
+/* 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)
+{