mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
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
This commit is contained in:
+38
-17
@@ -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[])
|
||||
{
|
||||
return _task_init(tcb, name, priority, task_start, entry,
|
||||
FALSE, argv);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user