+/* Destroys the data memorised by SD_task_schedule. Task state must be SD_SCHEDULED.
+ */
+static void __SD_task_destroy_scheduling_data(SD_task_t task) {
+ xbt_free(task->workstation_list);
+ xbt_free(task->computation_amount);
+ xbt_free(task->communication_amount);
+}
+
+/* Schedules a task.
+ * task: the task to schedule
+ * workstation_nb: number of workstations where the task will be executed
+ * workstation_list: workstations where the task will be executed
+ * computation_amount: computation amount for each workstation
+ * communication_amount: communication amount between each pair of workstations
+ * rate: task execution speed rate
+ */
+void SD_task_schedule(SD_task_t task, int workstation_nb,
+ const SD_workstation_t *workstation_list, double *computation_amount,
+ double *communication_amount, double rate) {
+ SD_CHECK_INIT_DONE();
+ xbt_assert0(task, "Invalid parameter");
+ xbt_assert1(SD_task_get_state(task) == SD_NOT_SCHEDULED, "Task '%s' has already been scheduled.", SD_task_get_name(task));
+ xbt_assert0(workstation_nb > 0, "workstation_nb must be positive");
+
+ task->workstation_nb = workstation_nb;
+ task->rate = rate;
+
+ task->computation_amount = xbt_new0(double, workstation_nb);
+ memcpy(task->computation_amount, computation_amount, sizeof(double) * workstation_nb);
+
+ int communication_nb = workstation_nb * workstation_nb;
+ task->communication_amount = xbt_new0(double, communication_nb);
+ memcpy(task->communication_amount, communication_amount, sizeof(double) * communication_nb);
+
+ /* we have to create a Surf workstation array instead of the SimDag workstation array */
+ task->workstation_list = xbt_new0(void*, workstation_nb);
+ int i;
+ for (i = 0; i < workstation_nb; i++) {
+ task->workstation_list[i] = workstation_list[i]->sd_data->surf_workstation;
+ }
+
+ __SD_task_set_state(task, SD_SCHEDULED);
+}
+