Reverted #44466 because it looks ugly.
[AROS.git] / rom / task / task_support.c
blob163ba4e99c0c32db1a6e81b94ecf3a16d5d03a0c
1 /*
2 Copyright © 2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
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 */
24 Forbid();
25 #else
26 EXEC_SPINLOCK_LOCK(&TaskResBase->TaskListSpinLock, SPINLOCK_MODE_WRITE);
27 #endif
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__)
46 Permit();
47 #else
48 EXEC_SPINLOCK_UNLOCK(&TaskResBase->TaskListSpinLock);
49 #endif