Indentation fix, cleanup.
[AROS.git] / rom / exec / addtask.c
blob52984b1cc204d9882b77b087e06f20847ac0bdfb
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a task.
6 Lang: english
7 */
9 #include <exec/execbase.h>
10 #include <exec/memory.h>
11 #include <aros/debug.h>
12 #include <aros/libcall.h>
13 #include <proto/exec.h>
15 #include "etask.h"
16 #include "exec_intern.h"
17 #include "exec_util.h"
18 #include "exec_debug.h"
20 /*****************************************************************************
22 NAME */
24 AROS_LH3(APTR, AddTask,
26 /* SYNOPSIS */
27 AROS_LHA(struct Task *, task, A1),
28 AROS_LHA(APTR, initialPC, A2),
29 AROS_LHA(APTR, finalPC, A3),
31 /* LOCATION */
32 struct ExecBase *, SysBase, 47, Exec)
34 /* FUNCTION
35 Add a new task to the system. If the new task has the highest
36 priority of all and task switches are allowed it will be started
37 immediately.
39 You must initialise certain fields, and allocate a stack before
40 calling this function. The fields that must be initialised are:
41 tc_SPLower, tc_SPUpper, tc_SPReg, and the tc_Node structure.
43 If any other fields are initialised to zero, then they will be
44 filled in with the system defaults.
46 The value of tc_SPReg will be used as the location for the stack
47 pointer. You can place any arguments you wish to pass to the Task
48 onto the stack before calling AddTask(). However note that you may
49 need to consider the stack direction on your processor.
51 Memory can be added to the tc_MemEntry list and will be freed when
52 the task dies. The new task's registers are set to 0.
54 INPUTS
55 task - Pointer to task structure.
56 initialPC - Entry point for the new task.
57 finalPC - Routine that is called if the initialPC() function
58 returns. A NULL pointer installs the default finalizer.
60 RESULT
61 The address of the new task or NULL if the operation failed.
63 NOTES
64 Use of AddTask() is deprecated on AROS; NewAddTask() should be used
65 instead. AddTask() is only retained for backwards compatiblity.
67 No proper initialization for alternative stack is done so alternative
68 stack can't be in tasks started with AddTask(). This means that on
69 some archs no shared library functions can be called.
71 EXAMPLE
73 BUGS
75 SEE ALSO
76 RemTask(), NewAddTask()
78 INTERNALS
80 ******************************************************************************/
82 AROS_LIBFUNC_INIT
84 struct Task *t;
86 DADDTASK("AddTask (0x%p (\"%s\"), 0x%p, 0x%p)", task, task->tc_Node.ln_Name, initialPC, finalPC);
88 t = NewAddTask(task, initialPC, finalPC, NULL);
90 ReturnPtr ("AddTask", struct Task *, t);
92 AROS_LIBFUNC_EXIT
93 } /* AddTask */