2 Copyright © 2015, The AROS Development Team. All rights reserved.
8 #include <aros/debug.h>
9 #include <exec/types.h>
10 #include <aros/libcall.h>
11 #include <proto/utility.h>
12 #include <resources/task.h>
14 #include <resources/task.h>
16 #include "taskres_intern.h"
18 /*****************************************************************************
21 #include <proto/task.h>
23 AROS_LH1(void, UnLockTaskList
,
26 AROS_LHA(ULONG
, flags
, D1
),
29 struct TaskResBase
*, TaskResBase
, 2, Task
)
32 Frees a lock on the task lists given by LockTaskList().
35 flags - the same value as given to LockTaskList().
46 LockTaskList(), NextTaskEntry()
50 *****************************************************************************/
54 struct TaskListPrivate
*taskList
, *tltmp
;
55 struct Task
*thisTask
= FindTask(NULL
);
57 D(bug("[TaskRes] UnLockTaskList: flags = $%lx\n", flags
));
59 ReleaseSemaphore(&TaskResBase
->trb_Sem
);
61 ForeachNodeSafe(&TaskResBase
->trb_LockedLists
, taskList
, tltmp
)
63 if (((struct Task
*)taskList
->tlp_Node
.ln_Name
== thisTask
) &&
64 (taskList
->tlp_Flags
== flags
))
66 D(bug("[TaskRes] UnLockTaskList: Releasing TaskList @ 0x%p\n", taskList
));
67 Remove(&taskList
->tlp_Node
);
68 FreeMem(taskList
, sizeof(struct TaskListPrivate
));
73 /* If we are the last lock holder, do housecleaning */
74 if (IsListEmpty(&TaskResBase
->trb_LockedLists
))
76 struct TaskListEntry
*taskEntry
, *tetmp
;
78 ForeachNodeSafe(&TaskResBase
->trb_TaskList
, taskEntry
, tetmp
)
80 if (taskEntry
->tle_Task
== NULL
)
82 D(bug("[TaskRes] RemTask: destroying old taskentry @ 0x%p\n", taskEntry
));
83 Remove(&taskEntry
->tle_Node
);
84 FreeMem(taskEntry
, sizeof(struct TaskListEntry
));
87 ForeachNodeSafe(&TaskResBase
->trb_NewTasks
, taskEntry
, tetmp
)
89 Remove(&taskEntry
->tle_Node
);
90 AddTail(&TaskResBase
->trb_TaskList
, &taskEntry
->tle_Node
);
94 } /* UnLockTaskList */