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
);
63 #if defined(__AROSEXEC_SMP__)
64 ForeachNode(&PrivExecBase(SysBase
)->TaskRunning
, t
)
67 if (et
!= NULL
&& et
->et_UniqueID
== id
)
69 EXEC_SPINLOCK_UNLOCK(listLock
);
74 EXEC_SPINLOCK_UNLOCK(listLock
);
76 listLock
= EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase
)->TaskReadySpinLock
, SPINLOCK_MODE_READ
);
79 if (GET_THIS_TASK
!= NULL
)
81 et
= GetETask(GET_THIS_TASK
);
82 if (et
!= NULL
&& et
->et_UniqueID
== id
)
89 /* Next, go through the ready list */
90 ForeachNode(&SysBase
->TaskReady
, t
)
93 if (et
!= NULL
&& et
->et_UniqueID
== id
)
95 #if defined(__AROSEXEC_SMP__)
96 EXEC_SPINLOCK_UNLOCK(listLock
);
104 #if defined(__AROSEXEC_SMP__)
105 EXEC_SPINLOCK_UNLOCK(listLock
);
107 listLock
= EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase
)->TaskWaitSpinLock
, SPINLOCK_MODE_READ
);
110 /* Finally, go through the wait list */
111 ForeachNode(&SysBase
->TaskWait
, t
)
114 if (et
!= NULL
&& et
->et_UniqueID
== id
)
116 #if defined(__AROSEXEC_SMP__)
117 EXEC_SPINLOCK_UNLOCK(listLock
);
126 #if defined(__AROSEXEC_SMP__)
127 EXEC_SPINLOCK_UNLOCK(listLock
);