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
);
60 ForeachNode(&PrivExecBase(SysBase
)->TaskRunning
, t
)
63 if (et
!= NULL
&& et
->et_UniqueID
== id
)
65 EXEC_SPINLOCK_UNLOCK(listLock
);
70 EXEC_SPINLOCK_UNLOCK(listLock
);
72 listLock
= EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase
)->TaskSpinningLock
, SPINLOCK_MODE_READ
);
74 ForeachNode(&PrivExecBase(SysBase
)->TaskSpinning
, t
)
77 if (et
!= NULL
&& et
->et_UniqueID
== id
)
79 EXEC_SPINLOCK_UNLOCK(listLock
);
84 EXEC_SPINLOCK_UNLOCK(listLock
);
86 listLock
= EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase
)->TaskReadySpinLock
, SPINLOCK_MODE_READ
);
90 if (GET_THIS_TASK
!= NULL
)
92 et
= GetETask(GET_THIS_TASK
);
93 if (et
!= NULL
&& et
->et_UniqueID
== id
)
100 /* Next, go through the ready list */
101 ForeachNode(&SysBase
->TaskReady
, t
)
104 if (et
!= NULL
&& et
->et_UniqueID
== id
)
106 #if defined(__AROSEXEC_SMP__)
107 EXEC_SPINLOCK_UNLOCK(listLock
);
115 #if defined(__AROSEXEC_SMP__)
116 EXEC_SPINLOCK_UNLOCK(listLock
);
118 listLock
= EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase
)->TaskWaitSpinLock
, SPINLOCK_MODE_READ
);
121 /* Finally, go through the wait list */
122 ForeachNode(&SysBase
->TaskWait
, t
)
125 if (et
!= NULL
&& et
->et_UniqueID
== id
)
127 #if defined(__AROSEXEC_SMP__)
128 EXEC_SPINLOCK_UNLOCK(listLock
);
137 #if defined(__AROSEXEC_SMP__)
138 EXEC_SPINLOCK_UNLOCK(listLock
);