summaryrefslogtreecommitdiff
path: root/nuttx/sched/task_init.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-11 22:19:01 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-03-11 22:19:01 +0000
commitdc5ec457e96f2c2e874f0626e0d8399ce136a4b3 (patch)
tree13a9ee8ef6cfb9e62ad01f65d34e3d82d274db51 /nuttx/sched/task_init.c
parent7e354ad57b4d040ab88e2eeb4ac84240e65e0e52 (diff)
downloadpx4-nuttx-dc5ec457e96f2c2e874f0626e0d8399ce136a4b3.tar.gz
px4-nuttx-dc5ec457e96f2c2e874f0626e0d8399ce136a4b3.tar.bz2
px4-nuttx-dc5ec457e96f2c2e874f0626e0d8399ce136a4b3.zip
Divided _task_init() in several smaller functions that take fewer paramters. This was necessary to reduce the stack usage for the 8051/2 which has a tiny, 256 byte stack
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@58 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/task_init.c')
-rw-r--r--nuttx/sched/task_init.c53
1 files changed, 37 insertions, 16 deletions
diff --git a/nuttx/sched/task_init.c b/nuttx/sched/task_init.c
index b603ddc80..92fd53fb2 100644
--- a/nuttx/sched/task_init.c
+++ b/nuttx/sched/task_init.c
@@ -37,6 +37,7 @@
* Included Files
************************************************************/
+#include <nuttx/config.h>
#include <sys/types.h>
#include <sched.h>
#include <nuttx/arch.h>
@@ -74,22 +75,31 @@
* Name: task_init
*
* Description:
- * This is a wrapper around the internal _task_init() that
- * provides a VxWorks-like API. See _task_init() for
- * further information.
+ * This function initializes a Task Control Block (TCB)
+ * in preparation for starting a new thread. It performs a
+ * subset of the functionality of task_create()
+ *
+ * Unlike task_create(), task_init() does not activate the
+ * task. This must be done by calling task_activate().
*
* Input Parameters:
* tcb - Address of the new task's TCB
* name - Name of the new task (not used)
* priority - Priority of the new task
- * stack - start of the pre-allocated stack
- * stack_size - size (in bytes) of the stack allocated
+ * stack - Start of the pre-allocated stack
+ * stack_size - Size (in bytes) of the stack allocated
* entry - Application start point of the new task
- * arg1-4 - Four required task arguments to pass to
- * the task when it is started.
+ * arg - A pointer to an array of input parameters.
+ * Up to CONFIG_MAX_TASK_ARG parameters may
+ * be provided. If fewer than CONFIG_MAX_TASK_ARG
+ * parameters are passed, the list should be
+ * terminated with a NULL argv[] value.
+ * If no parameters are required, argv may be
+ * NULL.
*
* Return Value:
- * see _task_init()
+ * OK on success; ERROR on failure. (See task_schedsetup()
+ * for possible failure conditions).
*
************************************************************/
@@ -97,16 +107,27 @@
STATUS task_init(FAR _TCB *tcb, const char *name, int priority,
FAR uint32 *stack, uint32 stack_size,
main_t entry, char *argv[])
-{
- up_use_stack(tcb, stack, stack_size);
- return _task_init(tcb, name, priority, task_start, entry,
- FALSE, argv);
-}
#else
STATUS task_init(FAR _TCB *tcb, const char *name, int priority,
main_t entry, char *argv[])
+#endif
{
- return _task_init(tcb, name, priority, task_start, entry,
- FALSE, argv);
-}
+ STATUS ret;
+
+ /* Configure the user provided stack region */
+
+#ifndef CONFIG_CUSTOM_STACK
+ up_use_stack(tcb, stack, stack_size);
#endif
+
+ /* Initialize the task control block */
+
+ ret = task_schedsetup(tcb, priority, task_start, entry);
+ if (ret == OK)
+ {
+ /* Setup to pass parameters to the new task */
+
+ (void)task_argsetup(tcb, name, FALSE, argv);
+ }
+ return ret;
+ }