+
+ /*
+ * SimDag allows tasks to be executed concurrently when they can by default.
+ * Yet schedulers take decisions assuming that tasks wait for resource
+ * availability to start.
+ * The solution (well crude hack is to keep track of the last task scheduled
+ * on a workstation and add a special type of dependency if needed to
+ * force the sequential execution meant by the scheduler.
+ * If the last scheduled task is already done, has failed or is a
+ * predecessor of the current task, no need for a new dependency
+ */
+
+ last_scheduled_task =
+ SD_workstation_get_last_scheduled_task(selected_workstation);
+ if (last_scheduled_task &&
+ (SD_task_get_state(last_scheduled_task) != SD_DONE) &&
+ (SD_task_get_state(last_scheduled_task) != SD_FAILED) &&
+ !SD_task_dependency_exists(
+ SD_workstation_get_last_scheduled_task(selected_workstation),
+ selected_task))
+ SD_task_dependency_add("resource", NULL,
+ last_scheduled_task, selected_task);
+
+ SD_workstation_set_last_scheduled_task(selected_workstation, selected_task);
+