2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Search a task by name.
8 #include <exec/execbase.h>
9 #include <aros/libcall.h>
10 #include <proto/exec.h>
12 /*****************************************************************************
16 AROS_LH1(struct Task
*, FindTask
,
19 AROS_LHA(CONST_STRPTR
, name
, A1
),
22 struct ExecBase
*, SysBase
, 49, Exec
)
25 Find a task with a given name or get the address of the current task.
26 Finding the address of the current task is a very quick function
27 call, but finding a special task is a very CPU intensive instruction.
28 Note that generally a task may already be gone when this function
32 name - Pointer to name or NULL for current task.
35 Address of task structure found.
47 ******************************************************************************/
53 /* Quick return for a quick argument */
55 return SysBase
->ThisTask
;
57 /* Always protect task lists with a Disable(). */
60 /* First look into the ready list. */
61 ret
=(struct Task
*)FindName(&SysBase
->TaskReady
,name
);
64 /* Then into the waiting list. */
65 ret
=(struct Task
*)FindName(&SysBase
->TaskWait
,name
);
69 Finally test the current task. Note that generally
70 you know the name of your own task - so it is close
71 to nonsense to look for it this way.
73 char *s1
=SysBase
->ThisTask
->tc_Node
.ln_Name
;
76 /* Check as long as the names are identical. */
78 /* Terminator found? */
82 ret
=SysBase
->ThisTask
;
88 /* Return whatever I found. */