2 Copyright © 2015-2017, 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 "task_intern.h"
18 /*****************************************************************************
21 #include <proto/task.h>
23 AROS_LH1(struct TaskList
*, LockTaskList
,
26 AROS_LHA(ULONG
, flags
, D0
),
29 struct TaskResBase
*, TaskResBase
, 1, Task
)
35 LTF_WRITE Lock The TaskList for writing
36 NB: In general software SHOULDNT
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.
45 Handle to the task list. This is not a direct pointer
46 to the first list element but to a pseudo element instead.
55 UnLockTaskList(), NextTaskEntry()
59 *****************************************************************************/
63 struct TaskListPrivate
*taskList
= NULL
;
65 D(bug("[TaskRes] LockTaskList: flags = $%lx\n", flags
));
68 if (flags
& LTF_WRITE
)
69 ObtainSemaphore(&TaskResBase
->trb_Sem
);
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
);
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
;