2 Copyright © 2017, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
10 #include <proto/exec.h>
11 #include <proto/kernel.h>
13 #include "task_intern.h"
15 void task_CleanList(struct Task
* task
, struct TaskResBase
*TaskResBase
)
17 /* Are there any lock holders?, if not, do housecleaning */
18 if (IsListEmpty(&TaskResBase
->trb_LockedLists
))
20 struct TaskListEntry
*taskEntry
, *tetmp
;
22 #if !defined(__AROSEXEC_SMP__)
23 /* Don't let any other task interfere with us at the moment */
26 EXEC_SPINLOCK_LOCK(&TaskResBase
->TaskListSpinLock
, SPINLOCK_MODE_WRITE
);
29 ForeachNodeSafe(&TaskResBase
->trb_TaskList
, taskEntry
, tetmp
)
31 if ((!taskEntry
->tle_Task
) ||
32 ((task
) && (task
== taskEntry
->tle_Task
)))
34 D(bug("[TaskRes] RemTask: destroying old taskentry @ 0x%p\n", taskEntry
));
35 Remove(&taskEntry
->tle_Node
);
36 FreeMem(taskEntry
, sizeof(struct TaskListEntry
));
39 ForeachNodeSafe(&TaskResBase
->trb_NewTasks
, taskEntry
, tetmp
)
41 Remove(&taskEntry
->tle_Node
);
42 AddTail(&TaskResBase
->trb_TaskList
, &taskEntry
->tle_Node
);
45 #if !defined(__AROSEXEC_SMP__)
48 EXEC_SPINLOCK_UNLOCK(&TaskResBase
->TaskListSpinLock
);