Copyright clean-up (part 1):
[AROS.git] / rom / exec / findtaskbypid.c
blob32781b7be0a0bc5e32d518238cbcb205965e9b60
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/execbase.h>
7 #include <exec/tasks.h>
9 /*****************************************************************************
11 NAME */
12 #include <proto/exec.h>
14 AROS_LH1(struct Task *, FindTaskByPID,
16 /* SYNOPSIS */
17 AROS_LHA(ULONG, id, D0),
19 /* LOCATION */
20 struct ExecBase *, SysBase, 166, Exec)
22 /* FUNCTION
23 Scan through the task lists searching for the task whose
24 et_UniqueID field matches.
26 INPUTS
27 id - The task ID to match.
29 RESULT
30 Address of the Task control structure that matches, or
31 NULL otherwise.
33 NOTES
34 This function is source-compatible with MorphOS.
36 EXAMPLE
38 BUGS
40 SEE ALSO
42 INTERNALS
44 ******************************************************************************/
46 AROS_LIBFUNC_INIT
48 struct Task *t;
49 struct ETask *et;
52 First up, check ThisTask. It could be NULL because of exec_init.c
54 if (SysBase->ThisTask != NULL)
56 et = GetETask(SysBase->ThisTask);
57 if (et != NULL && et->et_UniqueID == id)
58 return SysBase->ThisTask;
61 /* Next, go through the ready list */
62 ForeachNode(&SysBase->TaskReady, t)
64 et = GetETask(t);
65 if (et != NULL && et->et_UniqueID == id)
66 return t;
69 /* Finally, go through the wait list */
70 ForeachNode(&SysBase->TaskWait, t)
72 et = GetETask(t);
73 if (et != NULL && et->et_UniqueID == id)
74 return t;
77 return NULL;
79 AROS_LIBFUNC_EXIT