2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
6 #include <exec/execbase.h>
7 #include <exec/tasks.h>
9 #include "exec_intern.h"
11 /*****************************************************************************
14 #include <proto/exec.h>
16 AROS_LH1(struct Task
*, FindTaskByPID
,
19 AROS_LHA(ULONG
, id
, D0
),
22 struct ExecBase
*, SysBase
, 166, Exec
)
25 Scan through the task lists searching for the task whose
26 et_UniqueID field matches.
29 id - The task ID to match.
32 Address of the Task control structure that matches, or
36 This function is source-compatible with MorphOS.
46 ******************************************************************************/
50 #if defined(__AROSEXEC_SMP__)
56 /* First up, check running task(s) */
57 #if defined(__AROSEXEC_SMP__)
58 listLock
= EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase
)->TaskRunningSpinLock
, SPINLOCK_MODE_READ
);
61 #if defined(__AROSEXEC_SMP__)
62 ForeachNode(&PrivExecBase(SysBase
)->TaskRunning
, t
)
65 if (et
!= NULL
&& et
->et_UniqueID
== id
)
67 EXEC_SPINLOCK_UNLOCK(listLock
);
72 EXEC_SPINLOCK_UNLOCK(listLock
);
74 listLock
= EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase
)->TaskReadySpinLock
, SPINLOCK_MODE_READ
);
77 if (GET_THIS_TASK
!= NULL
)
79 et
= GetETask(GET_THIS_TASK
);
80 if (et
!= NULL
&& et
->et_UniqueID
== id
)
87 /* Next, go through the ready list */
88 ForeachNode(&SysBase
->TaskReady
, t
)
91 if (et
!= NULL
&& et
->et_UniqueID
== id
)
93 #if defined(__AROSEXEC_SMP__)
94 EXEC_SPINLOCK_UNLOCK(listLock
);
100 #if defined(__AROSEXEC_SMP__)
101 EXEC_SPINLOCK_UNLOCK(listLock
);
103 listLock
= EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase
)->TaskWaitSpinLock
, SPINLOCK_MODE_READ
);
106 /* Finally, go through the wait list */
107 ForeachNode(&SysBase
->TaskWait
, t
)
110 if (et
!= NULL
&& et
->et_UniqueID
== id
)
112 #if defined(__AROSEXEC_SMP__)
113 EXEC_SPINLOCK_UNLOCK(listLock
);
120 #if defined(__AROSEXEC_SMP__)
121 EXEC_SPINLOCK_UNLOCK(listLock
);