Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix on hppa: there is no working backtrace() there
[simgrid.git] / src / simdag / sd_task.c
1 #include "private.h"
2 #include "simdag/simdag.h"
3 #include "xbt/sysdep.h"
4 #include "xbt/dynar.h"
5
6 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sd_task,sd,
7                                 "Logging specific to SimDag (task)");
8
9 static void __SD_task_remove_dependencies(SD_task_t task);
10 static void __SD_task_destroy_scheduling_data(SD_task_t task);
11
12 /**
13  * \brief Creates a new task.
14  *
15  * \param name the name of the task (can be \c NULL)
16  * \param data the user data you want to associate with the task (can be \c NULL)
17  * \param amount amount of the task
18  * \return the new task
19  * \see SD_task_destroy()
20  */
21 SD_task_t SD_task_create(const char *name, void *data, double amount) {
22   SD_CHECK_INIT_DONE();
23
24   SD_task_t task = xbt_new0(s_SD_task_t, 1);
25
26   /* general information */
27   task->data = data; /* user data */
28   if (name != NULL)
29     task->name = xbt_strdup(name);
30   else
31     task->name = NULL;
32
33   task->state_set = sd_global->not_scheduled_task_set;
34   xbt_swag_insert(task,task->state_set);
35
36   task->amount = amount;
37   task->remains = amount;
38   task->start_time = -1.0;
39   task->finish_time = -1.0;
40   task->surf_action = NULL;
41   task->watch_points = 0;
42   task->state_changed = 0;
43
44   /* dependencies */
45   task->tasks_before = xbt_dynar_new(sizeof(SD_dependency_t), NULL);
46   task->tasks_after = xbt_dynar_new(sizeof(SD_dependency_t), NULL);
47
48   /* scheduling parameters */
49   task->workstation_nb = 0;
50   task->workstation_list = NULL;
51   task->computation_amount = NULL;
52   task->communication_amount = NULL;
53   task->rate = 0;
54
55   return task;
56 }
57
58 /**
59  * \brief Returns the user data of a task
60  *
61  * \param task a task
62  * \return the user data associated with this task (can be \c NULL)
63  * \see SD_task_set_data()
64  */
65 void* SD_task_get_data(SD_task_t task) {
66   SD_CHECK_INIT_DONE();
67   xbt_assert0(task != NULL, "Invalid parameter");
68   return task->data;
69 }
70
71 /**
72  * \brief Sets the user data of a task
73  *
74  * The new data can be \c NULL. The old data should have been freed first
75  * if it was not \c NULL.
76  *
77  * \param task a task
78  * \param data the new data you want to associate with this task
79  * \see SD_task_get_data()
80  */
81 void SD_task_set_data(SD_task_t task, void *data) {
82   SD_CHECK_INIT_DONE();
83   xbt_assert0(task != NULL, "Invalid parameter");
84   task->data = data;
85 }
86
87 /**
88  * \brief Returns the state of a task
89  *
90  * \param task a task
91  * \return the current \ref e_SD_task_state_t "state" of this task:
92  * #SD_NOT_SCHEDULED, #SD_SCHEDULED, #SD_READY, #SD_RUNNING, #SD_DONE or #SD_FAILED
93  * \see e_SD_task_state_t
94  */
95 e_SD_task_state_t SD_task_get_state(SD_task_t task) {
96   SD_CHECK_INIT_DONE();
97   xbt_assert0(task != NULL, "Invalid parameter");
98
99   if (task->state_set == sd_global->scheduled_task_set)
100     return SD_SCHEDULED;
101   if (task->state_set == sd_global->done_task_set)
102     return SD_DONE;
103   if (task->state_set == sd_global->running_task_set)
104     return SD_RUNNING;
105   if (task->state_set == sd_global->ready_task_set)
106     return SD_READY;
107   if (task->state_set == sd_global->not_scheduled_task_set)
108     return SD_NOT_SCHEDULED;
109   return SD_FAILED;
110 }
111
112 /* Changes the state of a task. Updates the swags and the flag sd_global->watch_point_reached.
113  */
114 void __SD_task_set_state(SD_task_t task, e_SD_task_state_t new_state) {
115   xbt_swag_remove(task, task->state_set);
116   switch (new_state) {
117   case SD_NOT_SCHEDULED:
118     task->state_set = sd_global->not_scheduled_task_set;
119     break;
120   case SD_SCHEDULED:
121     task->state_set = sd_global->scheduled_task_set;
122     break;
123   case SD_READY:
124     task->state_set = sd_global->ready_task_set;
125     break;
126   case SD_RUNNING:
127     task->state_set = sd_global->running_task_set;
128     task->start_time = surf_workstation_resource->common_public->
129       action_get_start_time(task->surf_action);
130     break;
131   case SD_DONE:
132     task->state_set = sd_global->done_task_set;
133     task->finish_time = surf_workstation_resource->common_public->
134       action_get_finish_time(task->surf_action);
135     task->remains = 0;
136     break;
137   case SD_FAILED:
138     task->state_set = sd_global->failed_task_set;
139     break;
140   default:
141     xbt_assert0(0, "Invalid state");
142   }
143   xbt_swag_insert(task, task->state_set);
144
145   if (task->watch_points & new_state) {
146     INFO1("Watch point reached with task '%s'!", SD_task_get_name(task));
147     sd_global->watch_point_reached = 1;
148     SD_task_unwatch(task, new_state); /* remove the watch point */
149   }
150 }
151
152 /**
153  * \brief Returns the name of a task
154  *
155  * \param task a task
156  * \return the name of this task (can be \c NULL)
157  */
158 const char* SD_task_get_name(SD_task_t task) {
159   SD_CHECK_INIT_DONE();
160   xbt_assert0(task != NULL, "Invalid parameter");
161   return task->name;
162 }
163
164 /**
165  * \brief Returns the total amount of a task
166  *
167  * \param task a task
168  * \return the total amount of this task
169  * \see SD_task_get_remaining_amount()
170  */
171 double SD_task_get_amount(SD_task_t task) {
172   SD_CHECK_INIT_DONE();
173   xbt_assert0(task != NULL, "Invalid parameter");
174   return task->amount;
175 }
176
177 /**
178  * \brief Returns the remaining amount of a task
179  *
180  * \param task a task
181  * \return the remaining amount of this task
182  * \see SD_task_get_amount()
183  */
184 double SD_task_get_remaining_amount(SD_task_t task) {
185   SD_CHECK_INIT_DONE();
186   xbt_assert0(task != NULL, "Invalid parameter");
187
188   if (task->surf_action)
189     return task->surf_action->remains;
190   else
191     return task->remains;
192 }
193
194 /* temporary function for debbuging */
195 static void __SD_print_dependencies(SD_task_t task) {
196   INFO1("The following tasks must be executed before %s:", SD_task_get_name(task));
197   xbt_dynar_t dynar = task->tasks_before;
198   int length = xbt_dynar_length(dynar);
199   int i;
200   SD_dependency_t dependency;
201   for (i = 0; i < length; i++) {
202     xbt_dynar_get_cpy(dynar, i, &dependency);
203     INFO1(" %s", SD_task_get_name(dependency->src));
204   }
205
206   INFO1("The following tasks must be executed after %s:", SD_task_get_name(task));
207
208   dynar = task->tasks_after;
209   length = xbt_dynar_length(dynar);
210   for (i = 0; i < length; i++) {
211     xbt_dynar_get_cpy(dynar, i, &dependency);
212     INFO1(" %s", SD_task_get_name(dependency->dst));
213   }
214   INFO0("----------------------------");
215 }
216
217 /* Destroys a dependency between two tasks.
218  */
219 static void __SD_task_dependency_destroy(void *dependency) {
220   if (((SD_dependency_t) dependency)->name != NULL)
221     xbt_free(((SD_dependency_t) dependency)->name);
222   xbt_free(dependency);
223 }
224
225 /**
226  * \brief Adds a dependency between two tasks
227  *
228  * \a dst will depend on \a src, ie \a dst will not start before \a src is finished.
229  * Their \ref e_SD_task_state_t "state" must be #SD_NOT_SCHEDULED, #SD_SCHEDULED or #SD_READY.
230  *
231  * \param name the name of the new dependency (can be \c NULL)
232  * \param data the user data you want to associate with this dependency (can be \c NULL)
233  * \param src the task which must be executed first
234  * \param dst the task you want to make depend on \a src
235  * \see SD_task_dependency_remove()
236  */
237 void SD_task_dependency_add(const char *name, void *data, SD_task_t src, SD_task_t dst) {
238   SD_CHECK_INIT_DONE();
239   xbt_assert0(src != NULL && dst != NULL, "Invalid parameter");
240   xbt_assert1(src != dst, "Cannot add a dependency between task '%s' and itself", SD_task_get_name(src));
241   xbt_assert1(__SD_task_is_not_scheduled(src) || __SD_task_is_scheduled_or_ready(src),
242               "Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULED or SD_READY", SD_task_get_name(src));
243   xbt_assert1(__SD_task_is_not_scheduled(dst) || __SD_task_is_scheduled_or_ready(dst),
244               "Task '%s' must be SD_NOT_SCHEDULED, SD_SCHEDULED or SD_READY", SD_task_get_name(dst));
245
246   xbt_dynar_t dynar = src->tasks_after;
247   int length = xbt_dynar_length(dynar);
248   int found = 0;
249   int i;
250   SD_dependency_t dependency;
251   for (i = 0; i < length && !found; i++) {
252     xbt_dynar_get_cpy(dynar, i, &dependency);
253     found = (dependency->dst == dst);
254   }
255   xbt_assert2(!found, "A dependency already exists between task '%s' and task '%s'",
256               SD_task_get_name(src), SD_task_get_name(dst));
257
258   dependency = xbt_new0(s_SD_dependency_t, 1);
259
260   if (name != NULL)
261     dependency->name = xbt_strdup(name);
262   else
263     dependency->name = NULL;
264
265   dependency->data = data;
266   dependency->src = src;
267   dependency->dst = dst;
268
269   /* src must be executed before dst */
270   xbt_dynar_push(src->tasks_after, &dependency);
271   xbt_dynar_push(dst->tasks_before, &dependency);
272
273   /* if the task was ready, then dst->tasks_before is not empty anymore,
274      so we must go back to state SD_SCHEDULED */
275   if (__SD_task_is_ready(dst)) {
276     DEBUG1("SD_task_dependency_add: %s was ready and becomes scheduled!", SD_task_get_name(dst));
277     __SD_task_set_state(dst, SD_SCHEDULED);
278   }
279
280   /*  __SD_print_dependencies(src);
281       __SD_print_dependencies(dst); */
282 }
283
284 /**
285  * \brief Remove a dependency between two tasks
286  *
287  * \param src a task
288  * \param dst a task depending on \a src
289  * \see SD_task_dependency_add()
290  */
291 void SD_task_dependency_remove(SD_task_t src, SD_task_t dst) {
292   SD_CHECK_INIT_DONE();
293   xbt_assert0(src != NULL && dst != NULL, "Invalid parameter");
294
295   /* remove the dependency from src->tasks_after */
296   xbt_dynar_t dynar = src->tasks_after;
297   int length = xbt_dynar_length(dynar);
298   int found = 0;
299   int i;
300   SD_dependency_t dependency;
301   for (i = 0; i < length && !found; i++) {
302     xbt_dynar_get_cpy(dynar, i, &dependency);
303     if (dependency->dst == dst) {
304       xbt_dynar_remove_at(dynar, i, NULL);
305       found = 1;
306     }
307   }
308   xbt_assert4(found, "No dependency found between task '%s' and '%s': task '%s' is not a successor of task '%s'",
309               SD_task_get_name(src), SD_task_get_name(dst), SD_task_get_name(dst), SD_task_get_name(src));
310
311   /* remove the dependency from dst->tasks_before */
312   dynar = dst->tasks_before;
313   length = xbt_dynar_length(dynar);
314   found = 0;
315   
316   for (i = 0; i < length && !found; i++) {
317     xbt_dynar_get_cpy(dynar, i, &dependency);
318     if (dependency->src == src) {
319       xbt_dynar_remove_at(dynar, i, NULL);
320       __SD_task_dependency_destroy(dependency);
321       found = 1;
322     }
323   }
324   xbt_assert4(found, "SimDag error: task '%s' is a successor of '%s' but task '%s' is not a predecessor of task '%s'",
325               SD_task_get_name(dst), SD_task_get_name(src), SD_task_get_name(src), SD_task_get_name(dst)); /* should never happen... */
326
327   /* if the task was scheduled and dst->tasks_before is empty now, we can make it ready */
328   if (xbt_dynar_length(dst->tasks_before) == 0 && __SD_task_is_scheduled(dst))
329     __SD_task_set_state(dst, SD_READY);
330
331   /*  __SD_print_dependencies(src); 
332       __SD_print_dependencies(dst);*/
333 }
334
335 /**
336  * \brief Returns the user data associated with a dependency between two tasks
337  *
338  * \param src a task
339  * \param dst a task depending on \a src
340  * \return the user data associated with this dependency (can be \c NULL)
341  * \see SD_task_dependency_add()
342  */
343 void *SD_task_dependency_get_data(SD_task_t src, SD_task_t dst) {
344   SD_CHECK_INIT_DONE();
345   xbt_assert0(src != NULL && dst != NULL, "Invalid parameter");
346
347   xbt_dynar_t dynar = src->tasks_after;
348   int length = xbt_dynar_length(dynar);
349   int found = 0;
350   int i;
351   SD_dependency_t dependency;
352   for (i = 0; i < length && !found; i++) {
353     xbt_dynar_get_cpy(dynar, i, &dependency);
354     found = (dependency->dst == dst);
355   }
356   xbt_assert2(found, "No dependency found between task '%s' and '%s'", SD_task_get_name(src), SD_task_get_name(dst));
357   return dependency->data;
358 }
359
360 /* temporary function for debugging */
361 static void __SD_print_watch_points(SD_task_t task) {
362   static const int state_masks[] = {SD_SCHEDULED, SD_RUNNING, SD_READY, SD_DONE, SD_FAILED};
363   static const char* state_names[] = {"scheduled", "running", "ready", "done", "failed"};
364
365   INFO2("Task '%s' watch points (%x): ", SD_task_get_name(task), task->watch_points);
366
367   int i;
368   for (i = 0; i < 5; i++) {
369     if (task->watch_points & state_masks[i])
370       INFO1("%s ", state_names[i]);
371   }
372 }
373
374 /**
375  * \brief Adds a watch point to a task
376  *
377  * 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
378  * watch point is then automatically removed.
379  * 
380  * \param task a task
381  * \param state the \ref e_SD_task_state_t "state" you want to watch (cannot be #SD_NOT_SCHEDULED)
382  * \see SD_task_unwatch()
383  */
384 void SD_task_watch(SD_task_t task, e_SD_task_state_t state) {
385   SD_CHECK_INIT_DONE();
386   xbt_assert0(task != NULL, "Invalid parameter");
387   xbt_assert0(state != SD_NOT_SCHEDULED, "Cannot add a watch point for state SD_NOT_SCHEDULED");
388
389   task->watch_points = task->watch_points | state;
390   /*  __SD_print_watch_points(task);*/
391 }
392
393 /**
394  * \brief Removes a watch point from a task
395  * 
396  * \param task a task
397  * \param state the \ref e_SD_task_state_t "state" you no longer want to watch
398  * \see SD_task_watch()
399  */
400 void SD_task_unwatch(SD_task_t task, e_SD_task_state_t state) {
401   SD_CHECK_INIT_DONE();
402   xbt_assert0(task != NULL, "Invalid parameter");
403   xbt_assert0(state != SD_NOT_SCHEDULED, "Cannot have a watch point for state SD_NOT_SCHEDULED");
404   
405   task->watch_points = task->watch_points & ~state;
406   /*  __SD_print_watch_points(task);*/
407 }
408
409 /**
410  * \brief Returns an approximative estimation of the execution time of a task.
411  * 
412  * The estimation is very approximative because the value returned is the time
413  * the task would take if it was executed now and if it was the only task.
414  * 
415  * \param task the task to evaluate
416  * \param workstation_nb number of workstations on which the task would be executed
417  * \param workstation_list the workstations on which the task would be executed
418  * \param computation_amount computation amount for each workstation
419  * \param communication_amount communication amount between each pair of workstations
420  * \param rate task execution speed rate
421  * \see SD_schedule()
422  */
423 double SD_task_get_execution_time(SD_task_t task,
424                                   int workstation_nb,
425                                   const SD_workstation_t *workstation_list,
426                                   const double *computation_amount,
427                                   const double *communication_amount,
428                                   double rate) {
429   /* the task execution time is the maximum execution time of the parallel tasks */
430   double time, max_time = 0.0;
431   int i, j;
432   for (i = 0; i < workstation_nb; i++) {
433     time = SD_workstation_get_computation_time(workstation_list[i], computation_amount[i]);
434     
435     for (j = 0; j < workstation_nb; j++) {
436       time += SD_route_get_communication_time(workstation_list[i], workstation_list[j],
437                                               communication_amount[i * workstation_nb + j]);
438     }
439
440     if (time > max_time) {
441       max_time = time;
442     }
443   }
444   return max_time * SD_task_get_amount(task);
445 }
446
447 /**
448  * \brief Schedules a task
449  *
450  * The task state must be #SD_NOT_SCHEDULED.
451  * Once scheduled, a task will be executed as soon as possible in SD_simulate(),
452  * i.e. when its dependencies are satisfied.
453  * 
454  * \param task the task you want to schedule
455  * \param workstation_nb number of workstations on which the task will be executed
456  * \param workstation_list the workstations on which the task will be executed
457  * \param computation_amount computation amount for each workstation
458  * \param communication_amount communication amount between each pair of workstations
459  * \param rate task execution speed rate
460  * \see SD_task_unschedule()
461  */
462 void SD_task_schedule(SD_task_t task, int workstation_nb,
463                      const SD_workstation_t *workstation_list, const double *computation_amount,
464                      const double *communication_amount, double rate) {
465   SD_CHECK_INIT_DONE();
466   xbt_assert0(task, "Invalid parameter");
467   xbt_assert1(__SD_task_is_not_scheduled(task), "Task '%s' has already been scheduled.", SD_task_get_name(task));
468   xbt_assert0(workstation_nb > 0, "workstation_nb must be positive");
469
470   task->workstation_nb = workstation_nb;
471   task->rate = rate;
472
473   task->computation_amount = xbt_new0(double, workstation_nb);
474   memcpy(task->computation_amount, computation_amount, sizeof(double) * workstation_nb);
475
476   int communication_nb = workstation_nb * workstation_nb;
477   task->communication_amount = xbt_new0(double, communication_nb);
478   memcpy(task->communication_amount, communication_amount, sizeof(double) * communication_nb);
479
480   /* we have to create a Surf workstation array instead of the SimDag workstation array */
481   task->workstation_list = xbt_new0(void*, workstation_nb);
482   int i;
483   for (i = 0; i < workstation_nb; i++) {
484     task->workstation_list[i] = workstation_list[i]->surf_workstation;
485   }
486
487   /* update the task state */
488   if (xbt_dynar_length(task->tasks_before) == 0)
489     __SD_task_set_state(task, SD_READY);
490   else
491     __SD_task_set_state(task, SD_SCHEDULED);
492 }
493
494 /**
495  * \brief Unschedules a task
496  *
497  * The task state must be #SD_SCHEDULED, #SD_READY, #SD_RUNNING or #SD_FAILED.
498  * If you call this function, the task state becomes #SD_NOT_SCHEDULED.
499  * Call SD_task_schedule() to schedule it again.
500  *
501  * \param task the task you want to unschedule
502  * \see SD_task_schedule()
503  */
504 void SD_task_unschedule(SD_task_t task) {
505   SD_CHECK_INIT_DONE();
506   xbt_assert0(task != NULL, "Invalid parameter");
507   xbt_assert1(task->state_set == sd_global->scheduled_task_set ||
508               task->state_set == sd_global->ready_task_set ||
509               task->state_set == sd_global->running_task_set ||
510               task->state_set == sd_global->failed_task_set,
511               "Task %s: the state must be SD_SCHEDULED, SD_READY, SD_RUNNING or SD_FAILED",
512               SD_task_get_name(task));
513
514   if (__SD_task_is_scheduled_or_ready(task)) /* if the task is scheduled or ready */
515     __SD_task_destroy_scheduling_data(task);
516
517   if (__SD_task_is_running(task)) /* the task should become SD_FAILED */
518     surf_workstation_resource->common_public->action_cancel(task->surf_action);
519   else
520     __SD_task_set_state(task, SD_NOT_SCHEDULED);
521   task->remains = task->amount;
522   task->start_time = -1.0;
523 }
524
525 /* Destroys the data memorised by SD_task_schedule. Task state must be SD_SCHEDULED or SD_READY.
526  */
527 static void __SD_task_destroy_scheduling_data(SD_task_t task) {
528   SD_CHECK_INIT_DONE();
529   xbt_assert1(__SD_task_is_scheduled_or_ready(task),
530               "Task '%s' must be SD_SCHEDULED or SD_READY", SD_task_get_name(task));
531   xbt_free(task->workstation_list);
532   xbt_free(task->computation_amount);
533   xbt_free(task->communication_amount);
534 }
535
536 /* Runs a task. This function is called by SD_simulate() when a scheduled task can start
537  * (ie when its dependencies are satisfied).
538  */
539 surf_action_t __SD_task_run(SD_task_t task) {
540   SD_CHECK_INIT_DONE();
541   xbt_assert0(task != NULL, "Invalid parameter");
542   xbt_assert2(__SD_task_is_ready(task), "Task '%s' is not ready! Task state: %d",
543               SD_task_get_name(task), SD_task_get_state(task));
544
545   task->surf_action = surf_workstation_resource->extension_public->
546     execute_parallel_task(task->workstation_nb,
547                           task->workstation_list,
548                           task->computation_amount,
549                           task->communication_amount,
550                           task->amount,
551                           task->rate);
552
553   DEBUG1("surf_action = %p",  task->surf_action);
554
555   __SD_task_destroy_scheduling_data(task); /* now the scheduling data are not useful anymore */
556   __SD_task_set_state(task, SD_RUNNING);
557
558   return task->surf_action;
559 }
560 /* Remove all dependencies associated with a task. This function is called when the task is destroyed.
561  */
562 static void __SD_task_remove_dependencies(SD_task_t task) {
563   /* we must destroy the dependencies carefuly (with SD_dependency_remove)
564      because each one is stored twice */
565   SD_dependency_t dependency;
566   while (xbt_dynar_length(task->tasks_before) > 0) {
567     xbt_dynar_get_cpy(task->tasks_before, 0, &dependency);
568     SD_task_dependency_remove(dependency->src, dependency->dst);
569   }
570
571   while (xbt_dynar_length(task->tasks_after) > 0) {
572     xbt_dynar_get_cpy(task->tasks_after, 0, &dependency);
573     SD_task_dependency_remove(dependency->src, dependency->dst);
574   }
575 }
576
577 /**
578  * \brief Returns the start time of a task
579  *
580  * The task state must be SD_RUNNING, SD_DONE or SD_FAILED.
581  *
582  * \task a task
583  * \return the start time of this task
584  */
585 double SD_task_get_start_time(SD_task_t task) {
586   SD_CHECK_INIT_DONE();
587   xbt_assert0(task != NULL, "Invalid parameter");
588   if(task->surf_action)
589     return surf_workstation_resource->common_public->action_get_start_time(task->surf_action);
590   else 
591     return task->start_time;
592 }
593
594 /**
595  * \brief Returns the finish time of a task
596  *
597  * The task state must be SD_RUNNING, SD_DONE or SD_FAILED.
598  * If the state is not completed yet, the returned value is an
599  * estimation of the task finish time. This value can fluctuate 
600  * until the task is completed.
601  *
602  * \task a task
603  * \return the start time of this task
604  */
605 double SD_task_get_finish_time(SD_task_t task) {
606   SD_CHECK_INIT_DONE();
607   xbt_assert0(task != NULL, "Invalid parameter");
608
609   if(task->surf_action)
610     return surf_workstation_resource->common_public->action_get_finish_time(task->surf_action); /* should never happen as actions are destroyed right after their completion */
611   else 
612     return task->finish_time;
613 }
614
615 /**
616  * \brief Destroys a task.
617  *
618  * The user data (if any) should have been destroyed first.
619  *
620  * \param task the task you want to destroy
621  * \see SD_task_create()
622  */
623 void SD_task_destroy(SD_task_t task) {
624   SD_CHECK_INIT_DONE();
625   xbt_assert0(task != NULL, "Invalid parameter");
626
627   DEBUG1("Destroying task %s...", SD_task_get_name(task));
628
629   __SD_task_remove_dependencies(task);
630
631   /* if the task was scheduled or ready we have to free the scheduling parameters */
632   if (__SD_task_is_scheduled_or_ready(task))
633     __SD_task_destroy_scheduling_data(task);
634
635   if (task->name != NULL)
636     xbt_free(task->name);
637
638   if (task->surf_action != NULL)
639     surf_workstation_resource->common_public->action_free(task->surf_action);
640
641   xbt_dynar_free(&task->tasks_before);
642   xbt_dynar_free(&task->tasks_after);
643   xbt_free(task);
644
645   DEBUG0("Task destroyed.");
646 }