diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-17 20:25:27 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-06-17 20:25:27 +0000 |
commit | d8ee4cfaf8afacfe8ff455900ed391af4f642888 (patch) | |
tree | d477c2d0bde57c71a78722de873a78b035357c75 /nuttx/sched | |
parent | 7a34357c62dd8c1910f444d37f80ed18425b7fad (diff) | |
download | px4-nuttx-d8ee4cfaf8afacfe8ff455900ed391af4f642888.tar.gz px4-nuttx-d8ee4cfaf8afacfe8ff455900ed391af4f642888.tar.bz2 px4-nuttx-d8ee4cfaf8afacfe8ff455900ed391af4f642888.zip |
Add exec_module
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1895 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
-rw-r--r-- | nuttx/sched/task_create.c | 2 | ||||
-rw-r--r-- | nuttx/sched/task_init.c | 92 |
2 files changed, 56 insertions, 38 deletions
diff --git a/nuttx/sched/task_create.c b/nuttx/sched/task_create.c index 31b50da0a..5d7a5872b 100644 --- a/nuttx/sched/task_create.c +++ b/nuttx/sched/task_create.c @@ -1,7 +1,7 @@ /**************************************************************************** * task_create.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without diff --git a/nuttx/sched/task_init.c b/nuttx/sched/task_init.c index 0b4a3a54d..6d5395594 100644 --- a/nuttx/sched/task_init.c +++ b/nuttx/sched/task_init.c @@ -1,7 +1,7 @@ -/************************************************************ +/**************************************************************************** * task_init.c * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * 3. Neither the name Gregory Nutt nor the names of its contributors may be + * 3. Neither the name NuttX nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,56 +31,60 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Included Files - ************************************************************/ + ****************************************************************************/ #include <nuttx/config.h> #include <sys/types.h> #include <sched.h> #include <nuttx/arch.h> + #include "os_internal.h" +#include "env_internal.h" -/************************************************************ +/**************************************************************************** * Definitions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Type Declarations - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Global Variables - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Variables - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Function Prototypes - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Private Functions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Public Functions - ************************************************************/ + ****************************************************************************/ -/************************************************************ +/**************************************************************************** * Name: task_init * * Description: - * 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() + * 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(). + * Unlike task_create(): + * 1. Allocate the TCB. The pre-allocated TCB is passed in the arguments. + * 2. Allocate the stack. The pre-allocated stack is passed in the arguments. + * 3. Activate the task. This must be done by calling task_activate(). * * Input Parameters: * tcb - Address of the new task's TCB @@ -89,19 +93,19 @@ * stack - Start of the pre-allocated stack * stack_size - Size (in bytes) of the stack allocated * entry - Application start point of the new task - * 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. + * 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: - * OK on success; ERROR on failure. (See task_schedsetup() - * for possible failure conditions). + * OK on success; ERROR on failure. (See task_schedsetup() for possible + * failure conditions). On failure, the caller is responsible for freeing + * the stack memory and for calling sched_releasetcb() to free the TCB + * (which could be in most any state). * - ************************************************************/ + ****************************************************************************/ #ifndef CONFIG_CUSTOM_STACK STATUS task_init(FAR _TCB *tcb, const char *name, int priority, @@ -114,6 +118,19 @@ STATUS task_init(FAR _TCB *tcb, const char *name, int priority, { STATUS ret; + /* Associate file descriptors with the new task */ + +#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 + if (sched_setuptaskfiles(tcb) != OK) + { + return ERROR; + } +#endif + + /* Clone the parent's task environment */ + + (void)env_dup(tcb); + /* Configure the user provided stack region */ #ifndef CONFIG_CUSTOM_STACK @@ -130,4 +147,5 @@ STATUS task_init(FAR _TCB *tcb, const char *name, int priority, (void)task_argsetup(tcb, name, argv); } return ret; - } +} + |