2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
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>
16 #include "exec_intern.h"
17 #include "exec_util.h"
18 #include "exec_debug.h"
20 /*****************************************************************************
24 AROS_LH3(APTR
, AddTask
,
27 AROS_LHA(struct Task
*, task
, A1
),
28 AROS_LHA(APTR
, initialPC
, A2
),
29 AROS_LHA(APTR
, finalPC
, A3
),
32 struct ExecBase
*, SysBase
, 47, Exec
)
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
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.
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.
61 The address of the new task or NULL if the operation failed.
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.
76 RemTask(), NewAddTask()
80 ******************************************************************************/
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
);