allow the other configure based build templates to pass use_build_env down.
[AROS.git] / rom / task / LockTaskList.c
blob4d64fc5e045af5e4e4cc732a90f923c7660e1118
1 /*
2 Copyright © 2015-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 0
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 "task_intern.h"
18 /*****************************************************************************
20 NAME */
21 #include <proto/task.h>
23 AROS_LH1(struct TaskList *, LockTaskList,
25 /* SYNOPSIS */
26 AROS_LHA(ULONG, flags, D0),
28 /* LOCATION */
29 struct TaskResBase *, TaskResBase, 1, Task)
31 /* FUNCTION
33 INPUTS
34 flags -
35 LTF_WRITE Lock The TaskList for writing
36 NB: In general software SHOULDNT
37 need to use this!
39 LTF_RUNNING Lock The TaskList to show running tasks.
40 LTF_READY Lock The TaskList to show ready tasks.
41 LTF_WAITING Lock The TaskList to show waiting/spinning tasks.
42 LTF_ALL Lock The TaskList to show all of the above tasks.
44 RESULT
45 Handle to the task list. This is not a direct pointer
46 to the first list element but to a pseudo element instead.
48 NOTES
50 EXAMPLE
52 BUGS
54 SEE ALSO
55 UnLockTaskList(), NextTaskEntry()
57 INTERNALS
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct TaskListPrivate *taskList = NULL;
65 D(bug("[TaskRes] LockTaskList: flags = $%lx\n", flags));
67 #ifdef TASKRES_ENABLE
68 if (flags & LTF_WRITE)
69 ObtainSemaphore(&TaskResBase->trb_Sem);
70 else
71 ObtainSemaphoreShared(&TaskResBase->trb_Sem);
73 if ((taskList = AllocMem(sizeof(struct TaskListPrivate), MEMF_CLEAR)) != NULL)
75 D(bug("[TaskRes] LockTaskList: TaskList @ 0x%p\n", taskList));
76 taskList->tlp_Node.ln_Name = (char *)FindTask(NULL);
77 taskList->tlp_Flags = flags;
78 taskList->tlp_Tasks = &TaskResBase->trb_TaskList;
79 taskList->tlp_Next = (struct TaskListEntry *)GetHead(taskList->tlp_Tasks);
80 AddTail(&TaskResBase->trb_LockedLists, &taskList->tlp_Node);
82 #else
83 Disable();
84 if ((taskList = (struct TaskListPrivate *)AllocVec(sizeof(struct TaskListPrivate), MEMF_PUBLIC)) != NULL)
86 if (flags & LTF_RUNNING)
87 taskList->tlp_TaskList = NULL;
88 else if (flags & LTF_READY)
89 taskList->tlp_TaskList = &SysBase->TaskReady;
90 else if (flags & LTF_WAITING)
91 taskList->tlp_TaskList = &SysBase->TaskWait;
92 taskList->tlp_Current = NULL;
94 #endif /* TASKRES_ENABLE */
96 return (struct TaskList *)taskList;
98 AROS_LIBFUNC_EXIT
99 } /* LockTaskList */