revert between 56095 -> 55830 in arch
[AROS.git] / rom / task / task_support.c
blob19daff21d52ee80cf87d5f3267a9a167b54a002d
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>
12 #include "task_intern.h"
14 void task_CleanList(struct Task * task, struct TaskResBase *TaskResBase)
16 /* Are there any lock holders?, if not, do housecleaning */
17 if (IsListEmpty(&TaskResBase->trb_LockedLists))
19 struct TaskListEntry *taskEntry, *tetmp;
21 #if !defined(__AROSEXEC_SMP__)
22 /* Don't let any other task interfere with us at the moment */
23 Forbid();
24 #else
25 EXEC_SPINLOCK_LOCK(&TaskResBase->TaskListSpinLock, NULL, SPINLOCK_MODE_WRITE);
26 #endif
28 ForeachNodeSafe(&TaskResBase->trb_TaskList, taskEntry, tetmp)
30 if ((!taskEntry->tle_Task) ||
31 ((task) && (task == taskEntry->tle_Task)))
33 D(bug("[TaskRes] RemTask: destroying old taskentry @ 0x%p\n", taskEntry));
34 Remove(&taskEntry->tle_Node);
35 FreeMem(taskEntry, sizeof(struct TaskListEntry));
38 ForeachNodeSafe(&TaskResBase->trb_NewTasks, taskEntry, tetmp)
40 Remove(&taskEntry->tle_Node);
41 AddTail(&TaskResBase->trb_TaskList, &taskEntry->tle_Node);
44 #if !defined(__AROSEXEC_SMP__)
45 Permit();
46 #else
47 EXEC_SPINLOCK_UNLOCK(&TaskResBase->TaskListSpinLock);
48 #endif