Define USB 2.0 extension descriptor as Usb20ExtDesc
[AROS.git] / rom / exec / findtaskbypid.c
blob1c16cd48f990e1676aefbdcaf9a40a2c7f924a49
1 #include <exec/execbase.h>
2 #include <exec/tasks.h>
4 /*****************************************************************************
6 NAME */
7 #include <proto/exec.h>
9 AROS_LH1(struct Task *, FindTaskByPID,
11 /* SYNOPSIS */
12 AROS_LHA(ULONG, id, D0),
14 /* LOCATION */
15 struct ExecBase *, SysBase, 166, Exec)
17 /* FUNCTION
18 Scan through the task lists searching for the task whose
19 et_UniqueID field matches.
21 INPUTS
22 id - The task ID to match.
24 RESULT
25 Address of the Task control structure that matches, or
26 NULL otherwise.
28 NOTES
29 This function is source-compatible with MorphOS.
31 EXAMPLE
33 BUGS
35 SEE ALSO
37 INTERNALS
39 ******************************************************************************/
41 AROS_LIBFUNC_INIT
43 struct Task *t;
44 struct ETask *et;
47 First up, check ThisTask. It could be NULL because of exec_init.c
49 if (SysBase->ThisTask != NULL)
51 et = GetETask(SysBase->ThisTask);
52 if (et != NULL && et->et_UniqueID == id)
53 return SysBase->ThisTask;
56 /* Next, go through the ready list */
57 ForeachNode(&SysBase->TaskReady, t)
59 et = GetETask(t);
60 if (et != NULL && et->et_UniqueID == id)
61 return t;
64 /* Finally, go through the wait list */
65 ForeachNode(&SysBase->TaskWait, t)
67 et = GetETask(t);
68 if (et != NULL && et->et_UniqueID == id)
69 return t;
72 return NULL;
74 AROS_LIBFUNC_EXIT