diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-26 23:49:02 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-26 23:49:02 +0000 |
commit | 47b94bafa5045532f239ea57a3610873b1a71368 (patch) | |
tree | 59eb55cb25bbd20b052a87de5838d80a410a1439 /nuttx/sched | |
parent | b82c36961aa730fc39a9fc8eac17e2518128cb67 (diff) | |
download | px4-firmware-47b94bafa5045532f239ea57a3610873b1a71368.tar.gz px4-firmware-47b94bafa5045532f239ea57a3610873b1a71368.tar.bz2 px4-firmware-47b94bafa5045532f239ea57a3610873b1a71368.zip |
Move socket data from TCB to task group structure.
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5570 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
-rw-r--r-- | nuttx/sched/Makefile | 6 | ||||
-rw-r--r-- | nuttx/sched/env_clearenv.c | 5 | ||||
-rw-r--r-- | nuttx/sched/env_dup.c | 12 | ||||
-rw-r--r-- | nuttx/sched/env_internal.h | 8 | ||||
-rw-r--r-- | nuttx/sched/env_release.c | 11 | ||||
-rw-r--r-- | nuttx/sched/group_create.c | 2 | ||||
-rw-r--r-- | nuttx/sched/group_internal.h | 8 | ||||
-rw-r--r-- | nuttx/sched/group_leave.c | 34 | ||||
-rw-r--r-- | nuttx/sched/group_releasefiles.c | 112 | ||||
-rw-r--r-- | nuttx/sched/group_setupidlefiles.c (renamed from nuttx/sched/sched_setupidlefiles.c) | 24 | ||||
-rw-r--r-- | nuttx/sched/group_setupstreams.c (renamed from nuttx/sched/sched_setupstreams.c) | 8 | ||||
-rw-r--r-- | nuttx/sched/group_setuptaskfiles.c (renamed from nuttx/sched/sched_setuptaskfiles.c) | 59 | ||||
-rw-r--r-- | nuttx/sched/os_internal.h | 17 | ||||
-rw-r--r-- | nuttx/sched/os_start.c | 2 | ||||
-rw-r--r-- | nuttx/sched/pthread_create.c | 9 | ||||
-rw-r--r-- | nuttx/sched/sched_getsockets.c | 7 | ||||
-rw-r--r-- | nuttx/sched/sched_setuppthreadfiles.c | 91 | ||||
-rw-r--r-- | nuttx/sched/task_create.c | 2 | ||||
-rw-r--r-- | nuttx/sched/task_init.c | 2 | ||||
-rw-r--r-- | nuttx/sched/task_vfork.c | 2 |
20 files changed, 104 insertions, 317 deletions
diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile index c8fe7cf69..7710ae058 100644 --- a/nuttx/sched/Makefile +++ b/nuttx/sched/Makefile @@ -39,9 +39,7 @@ ASRCS = AOBJS = $(ASRCS:.S=$(OBJEXT)) MISC_SRCS = os_start.c os_bringup.c errno_getptr.c errno_get.c errno_set.c -MISC_SRCS += sched_garbage.c sched_setupstreams.c sched_getfiles.c sched_getsockets.c -MISC_SRCS += sched_getstreams.c sched_setupidlefiles.c sched_setuptaskfiles.c -MISC_SRCS += sched_setuppthreadfiles.c +MISC_SRCS += sched_garbage.c sched_getfiles.c sched_getsockets.c sched_getstreams.c TSK_SRCS = prctl.c task_create.c task_init.c task_setup.c task_activate.c TSK_SRCS += task_start.c task_delete.c task_deletecurrent.c task_exithook.c @@ -81,7 +79,7 @@ endif endif GRP_SRCS = group_create.c group_join.c group_leave.c group_find.c -GRP_SRCS += group_releasefiles.c +GRP_SRCS += group_setupstreams.c group_setupidlefiles.c group_setuptaskfiles.c ifeq ($(CONFIG_SCHED_HAVE_PARENT),y) GRP_SRCS += task_reparent.c diff --git a/nuttx/sched/env_clearenv.c b/nuttx/sched/env_clearenv.c index a9e9f5efd..062fd60ed 100644 --- a/nuttx/sched/env_clearenv.c +++ b/nuttx/sched/env_clearenv.c @@ -74,7 +74,10 @@ int clearenv(void) { - env_release((FAR _TCB*)g_readytorun.head); + FAR _TCB *tcb = (FAR _TCB*)g_readytorun.head; + DEBUGASSERT(tcb->group); + + env_release(tcb->group); return OK; } diff --git a/nuttx/sched/env_dup.c b/nuttx/sched/env_dup.c index 479f7cae7..3b653b010 100644 --- a/nuttx/sched/env_dup.c +++ b/nuttx/sched/env_dup.c @@ -68,8 +68,8 @@ * exact duplicate of the parent task's environment. * * Parameters: - * ctcb The child tcb to receive the newly allocated copy of the parent - * TCB's environment structure with reference count equal to one + * group The child task group to receive the newly allocated copy of the + * parent task groups environment structure. * * Return Value: * zero on success @@ -79,14 +79,14 @@ * ****************************************************************************/ -int env_dup(FAR _TCB *ctcb) +int env_dup(FAR struct task_group_s *group) { FAR _TCB *ptcb = (FAR _TCB*)g_readytorun.head; FAR char *envp = NULL; size_t envlen; int ret = OK; - DEBUGASSERT(ctcb && ptcb && ctcb->group && ptcb->group); + DEBUGASSERT(group && ptcb && ptcb->group); /* Pre-emption must be disabled throughout the following because the * environment may be shared. @@ -108,8 +108,8 @@ int env_dup(FAR _TCB *ctcb) } else { - ctcb->group->tg_envsize = envlen; - ctcb->group->tg_envp = envp; + group->tg_envsize = envlen; + group->tg_envp = envp; memcpy(envp, ptcb->group->tg_envp, envlen); } } diff --git a/nuttx/sched/env_internal.h b/nuttx/sched/env_internal.h index 6f1097c0b..e02bf289d 100644 --- a/nuttx/sched/env_internal.h +++ b/nuttx/sched/env_internal.h @@ -49,8 +49,8 @@ ****************************************************************************/ #ifdef CONFIG_DISABLE_ENVIRON -# define env_dup(ptcb) (0) -# define env_release(ptcb) (0) +# define env_dup(group) (0) +# define env_release(group) (0) #else /**************************************************************************** @@ -75,8 +75,8 @@ extern "C" /* Functions used by the task/pthread creation and destruction logic */ -int env_dup(FAR _TCB *ctcb); -void env_release(FAR _TCB *tcb); +int env_dup(FAR struct task_group_s *group); +void env_release(FAR struct task_group_s *group); /* Functions used internally by the environment handling logic */ diff --git a/nuttx/sched/env_release.c b/nuttx/sched/env_release.c index 4de55c388..aebb1f7e8 100644 --- a/nuttx/sched/env_release.c +++ b/nuttx/sched/env_release.c @@ -64,8 +64,8 @@ * environ to NULL. * * Parameters: - * tcb Identifies the TCB containing the environment structure to be - * released. + * group Identifies the task group containing the environment structure + * to be released. * * Return Value: * None @@ -75,12 +75,9 @@ * ****************************************************************************/ -void env_release(FAR _TCB *tcb) +void env_release(FAR struct task_group_s *group) { - FAR struct task_group_s *group; - - DEBUGASSERT(tcb && tcb->group); - group = tcb->group; + DEBUGASSERT(group); /* Free any allocate environment strings */ diff --git a/nuttx/sched/group_create.c b/nuttx/sched/group_create.c index 768641be1..24f6923aa 100644 --- a/nuttx/sched/group_create.c +++ b/nuttx/sched/group_create.c @@ -198,7 +198,7 @@ int group_allocate(FAR _TCB *tcb) /* Duplicate the parent tasks envionment */ - ret = env_dup(tcb); + ret = env_dup(tcb->group); if (ret < 0) { kfree(tcb->group); diff --git a/nuttx/sched/group_internal.h b/nuttx/sched/group_internal.h index e6e0dfd16..ca6aacff7 100644 --- a/nuttx/sched/group_internal.h +++ b/nuttx/sched/group_internal.h @@ -113,10 +113,14 @@ void group_removechildren(FAR struct task_group_s *group); #endif /* CONFIG_SCHED_CHILD_STATUS */ #endif /* CONFIG_SCHED_HAVE_PARENT */ -/* File/network resources */ +/* Group data resource configuration */ #if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 -int group_releasefiles(FAR _TCB *tcb); +int group_setupidlefiles(FAR _TCB *tcb); +int group_setuptaskfiles(FAR _TCB *tcb); +#if CONFIG_NFILE_STREAMS > 0 +int group_setupstreams(FAR _TCB *tcb); +#endif #endif #endif /* __SCHED_GROUP_INERNAL_H */ diff --git a/nuttx/sched/group_leave.c b/nuttx/sched/group_leave.c index 70ef93666..4dec30633 100644 --- a/nuttx/sched/group_leave.c +++ b/nuttx/sched/group_leave.c @@ -44,6 +44,10 @@ #include <errno.h> #include <debug.h> +#include <nuttx/fs/fs.h> +#include <nuttx/net/net.h> +#include <nuttx/lib.h> + #include "group_internal.h" #include "env_internal.h" @@ -142,8 +146,7 @@ void group_remove(FAR struct task_group_s *group) * *****************************************************************************/ -static inline void group_release(FAR _TCB *tcb, - FAR struct task_group_s *group) +static inline void group_release(FAR struct task_group_s *group) { /* Free all un-reaped child exit status */ @@ -155,14 +158,29 @@ static inline void group_release(FAR _TCB *tcb, * soon as possible while we still have a functioning task. */ -#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 - (void)group_releasefiles(tcb); -#endif +#if CONFIG_NFILE_DESCRIPTORS > 0 + /* Free resources held by the file descriptor list */ + + files_releaselist(&group->tg_filelist); + +#if CONFIG_NFILE_STREAMS > 0 + /* Free resource held by the stream list */ + + lib_releaselist(&group->tg_streamlist); + +#endif /* CONFIG_NFILE_STREAMS */ +#endif /* CONFIG_NFILE_DESCRIPTORS */ + +#if CONFIG_NSOCKET_DESCRIPTORS > 0 + /* Free resource held by the socket list */ + + net_releaselist(&group->tg_socketlist); +#endif /* CONFIG_NSOCKET_DESCRIPTORS */ /* Release all shared environment variables */ #ifndef CONFIG_DISABLE_ENVIRON - env_release(tcb); + env_release(group); #endif #ifdef HAVE_GROUP_MEMBERS @@ -232,7 +250,7 @@ void group_leave(FAR _TCB *tcb) { /* Release all of the resource held by the task group */ - group_release(tcb, group); + group_release(group); } /* In any event, we can detach the group from the TCB so that we won't @@ -271,7 +289,7 @@ void group_leave(FAR _TCB *tcb) { /* Release all of the resource held by the task group */ - group_release(tcb, group); + group_release(group); } /* In any event, we can detach the group from the TCB so we won't do diff --git a/nuttx/sched/group_releasefiles.c b/nuttx/sched/group_releasefiles.c deleted file mode 100644 index b33415c76..000000000 --- a/nuttx/sched/group_releasefiles.c +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** - * sched/group_releasefiles.c - * - * Copyright (C) 2007, 2008, 2012-2013 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <gnutt@nuttx.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * 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 <sched.h> -#include <nuttx/fs/fs.h> -#include <nuttx/net/net.h> -#include <nuttx/lib.h> - -#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: group_releasefiles - * - * Description: - * Release file resources attached to a TCB. This file may be called - * multiple times as a task exists. It will be called as early as possible - * to support proper closing of complex drivers that may need to wait - * on external events. - * - * Parameters: - * tcb - tcb of the new task. - * - * Return Value: - * None - * - * Assumptions: - * - ****************************************************************************/ - -int group_releasefiles(_TCB *tcb) -{ - if (tcb) - { -#if CONFIG_NFILE_DESCRIPTORS > 0 - FAR struct task_group_s *group = tcb->group; - DEBUGASSERT(group); -#endif - -#if CONFIG_NFILE_DESCRIPTORS > 0 - /* Free resources used by the file descriptor list */ - - files_releaselist(&group->tg_filelist); - -#if CONFIG_NFILE_STREAMS > 0 - /* Free the stream list */ - - lib_releaselist(&group->tg_streamlist); - -#endif /* CONFIG_NFILE_STREAMS */ -#endif /* CONFIG_NFILE_DESCRIPTORS */ - -#if CONFIG_NSOCKET_DESCRIPTORS > 0 - /* Free the file descriptor list */ - - if (tcb->sockets) - { - net_releaselist(tcb->sockets); - tcb->sockets = NULL; - } -#endif /* CONFIG_NSOCKET_DESCRIPTORS */ - } - - return OK; -} - -#endif /* CONFIG_NFILE_DESCRIPTORS || CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/nuttx/sched/sched_setupidlefiles.c b/nuttx/sched/group_setupidlefiles.c index 4bbd4d3b7..98cc7885e 100644 --- a/nuttx/sched/sched_setupidlefiles.c +++ b/nuttx/sched/group_setupidlefiles.c @@ -1,7 +1,7 @@ /**************************************************************************** - * sched/sched_setupidlefiles.c + * sched/group_setupidlefiles.c * - * Copyright (C) 2007-2010, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2010, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -62,7 +62,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: sched_setupidlefiles + * Name: group_setupidlefiles * * Description: * Configure the idle thread's TCB. @@ -77,33 +77,29 @@ * ****************************************************************************/ -int sched_setupidlefiles(FAR _TCB *tcb) +int group_setupidlefiles(FAR _TCB *tcb) { -#if CONFIG_NFILE_DESCRIPTORS > 0 +#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0 FAR struct task_group_s *group = tcb->group; #endif #if CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_DEV_CONSOLE) int fd; #endif -#if CONFIG_NFILE_DESCRIPTORS > 0 +#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0 DEBUGASSERT(group); #endif +#if CONFIG_NFILE_DESCRIPTORS > 0 /* Initialize file descriptors for the TCB */ -#if CONFIG_NFILE_DESCRIPTORS > 0 files_initlist(&group->tg_filelist); #endif +#if CONFIG_NSOCKET_DESCRIPTORS > 0 /* Allocate socket descriptors for the TCB */ -#if CONFIG_NSOCKET_DESCRIPTORS > 0 - tcb->sockets = net_alloclist(); - if (!tcb->sockets) - { - return -ENOMEM; - } + net_initlist(&group->tg_socketlist); #endif /* Open stdin, dup to get stdout and stderr. This should always @@ -142,7 +138,7 @@ int sched_setupidlefiles(FAR _TCB *tcb) /* Allocate file/socket streams for the TCB */ #if CONFIG_NFILE_STREAMS > 0 - return sched_setupstreams(tcb); + return group_setupstreams(tcb); #else return OK; #endif diff --git a/nuttx/sched/sched_setupstreams.c b/nuttx/sched/group_setupstreams.c index fb2e4d0be..88e266280 100644 --- a/nuttx/sched/sched_setupstreams.c +++ b/nuttx/sched/group_setupstreams.c @@ -1,7 +1,7 @@ /**************************************************************************** - * sched_setupstreams.c + * group_setupstreams.c * - * Copyright (C) 2007-2008, 2010-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2008, 2010-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -62,7 +62,7 @@ ****************************************************************************/ /**************************************************************************** - * Name: sched_setupstreams + * Name: group_setupstreams * * Description: * Setup streams data structures that may be used for standard C buffered @@ -70,7 +70,7 @@ * ****************************************************************************/ -int sched_setupstreams(FAR _TCB *tcb) +int group_setupstreams(FAR _TCB *tcb) { DEBUGASSERT(tcb && tcb->group); diff --git a/nuttx/sched/sched_setuptaskfiles.c b/nuttx/sched/group_setuptaskfiles.c index 9e44147e9..d52adcfee 100644 --- a/nuttx/sched/sched_setuptaskfiles.c +++ b/nuttx/sched/group_setuptaskfiles.c @@ -1,5 +1,5 @@ /**************************************************************************** - * sched/sched_setuptaskfiles.c + * sched/group_setuptaskfiles.c * * Copyright (C) 2007-2008, 2010, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> @@ -151,32 +151,31 @@ static inline void sched_dupsockets(FAR _TCB *tcb) FAR struct socket *child; int i; - /* Duplicate the socket descriptors of all sockets opened by the parent - * task. - */ + /* Duplicate the socket descriptors of all sockets opened by the parent + * task. + */ - if (rtcb->sockets) - { - /* Get pointers to the parent and child task socket lists */ + DEBUGASSERT(tcb && tcb->group && rtcb->group); - parent = rtcb->sockets->sl_sockets; - child = tcb->sockets->sl_sockets; + /* Get pointers to the parent and child task socket lists */ - /* Check each socket in the parent socket list */ + parent = rtcb->group->tg_sockets->sl_sockets; + child = tcb->group->tg_sockets->sl_sockets; - for (i = 0; i < CONFIG_NSOCKET_DESCRIPTORS; i++) - { - /* Check if this parent socket is allocated. We can tell if the - * socket is allocated because it will have a positive, non-zero - * reference count. - */ + /* Check each socket in the parent socket list */ - if (parent[i].s_crefs > 0) - { - /* Yes... duplicate it for the child */ + for (i = 0; i < CONFIG_NSOCKET_DESCRIPTORS; i++) + { + /* Check if this parent socket is allocated. We can tell if the + * socket is allocated because it will have a positive, non-zero + * reference count. + */ + + if (parent[i].s_crefs > 0) + { + /* Yes... duplicate it for the child */ - (void)net_clone(&parent[i], &child[i]); - } + (void)net_clone(&parent[i], &child[i]); } } } @@ -189,7 +188,7 @@ static inline void sched_dupsockets(FAR _TCB *tcb) ****************************************************************************/ /**************************************************************************** - * Name: sched_setuptaskfiles + * Name: group_setuptaskfiles * * Description: * Configure a newly allocated TCB so that it will inherit @@ -206,26 +205,24 @@ static inline void sched_dupsockets(FAR _TCB *tcb) * ****************************************************************************/ -int sched_setuptaskfiles(FAR _TCB *tcb) +int group_setuptaskfiles(FAR _TCB *tcb) { -#if CONFIG_NFILE_DESCRIPTORS > 0 +#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 FAR struct task_group_s *group = tcb->group; DEBUGASSERT(group); +#endif +#if CONFIG_NFILE_DESCRIPTORS > 0 /* Initialize file descriptors for the TCB */ files_initlist(&group->tg_filelist); #endif +#if CONFIG_NSOCKET_DESCRIPTORS > 0 /* Allocate socket descriptors for the TCB */ -#if CONFIG_NSOCKET_DESCRIPTORS > 0 - tcb->sockets = net_alloclist(); - if (!tcb->sockets) - { - return -ENOMEM; - } + net_initlist(&group->tg_socketlist); #endif /* Duplicate the parent task's file descriptors */ @@ -239,7 +236,7 @@ int sched_setuptaskfiles(FAR _TCB *tcb) /* Allocate file/socket streams for the new TCB */ #if CONFIG_NFILE_STREAMS > 0 - return sched_setupstreams(tcb); + return group_setupstreams(tcb); #else return OK; #endif diff --git a/nuttx/sched/os_internal.h b/nuttx/sched/os_internal.h index 5aa6487d0..262a40ccc 100644 --- a/nuttx/sched/os_internal.h +++ b/nuttx/sched/os_internal.h @@ -99,14 +99,6 @@ enum os_crash_codes_e #define MAX_TASKS_MASK (CONFIG_MAX_TASKS-1) #define PIDHASH(pid) ((pid) & MAX_TASKS_MASK) -/* Stubs used when there are no file descriptors */ - -#if CONFIG_NFILE_DESCRIPTORS <= 0 && CONFIG_NSOCKET_DESCRIPTORS <= 0 -# define sched_setupidlefiles(t) (OK) -# define sched_setuptaskfiles(t) (OK) -# define sched_setuppthreadfiles(t) (OK) -#endif - /* One processor family supported by NuttX has a single, fixed hardware stack. * That is the 8051 family. So for that family only, there is a variant form * of kernel_thread() that does not take a stack size parameter. The following @@ -293,15 +285,6 @@ int sched_reprioritize(FAR _TCB *tcb, int sched_priority); FAR _TCB *sched_gettcb(pid_t pid); bool sched_verifytcb(FAR _TCB *tcb); -#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 -int sched_setupidlefiles(FAR _TCB *tcb); -int sched_setuptaskfiles(FAR _TCB *tcb); -int sched_setuppthreadfiles(FAR _TCB *tcb); -#if CONFIG_NFILE_STREAMS > 0 -int sched_setupstreams(FAR _TCB *tcb); -#endif -#endif - int sched_releasetcb(FAR _TCB *tcb); void sched_garbagecollection(void); diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c index b2551d2a3..5e6eaa858 100644 --- a/nuttx/sched/os_start.c +++ b/nuttx/sched/os_start.c @@ -451,7 +451,7 @@ void os_start(void) * inherited by all of the threads created by the IDLE task. */ - (void)sched_setupidlefiles(&g_idletcb); + (void)group_setupidlefiles(&g_idletcb); /* Create initial tasks and bring-up the system */ diff --git a/nuttx/sched/pthread_create.c b/nuttx/sched/pthread_create.c index 9fd6a4a61..48a0788a6 100644 --- a/nuttx/sched/pthread_create.c +++ b/nuttx/sched/pthread_create.c @@ -296,15 +296,6 @@ int pthread_create(FAR pthread_t *thread, FAR pthread_attr_t *attr, } #endif - /* Associate file descriptors with the new task */ - - ret = sched_setuppthreadfiles(ptcb); - if (ret != OK) - { - errcode = ret; - goto errout_with_tcb; - } - /* Allocate a detachable structure to support pthread_join logic */ pjoin = (FAR join_t*)kzalloc(sizeof(join_t)); diff --git a/nuttx/sched/sched_getsockets.c b/nuttx/sched/sched_getsockets.c index cd499420f..ea988d6ff 100644 --- a/nuttx/sched/sched_getsockets.c +++ b/nuttx/sched/sched_getsockets.c @@ -1,7 +1,7 @@ /************************************************************************ * sched/sched_getsockets.c * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -71,7 +71,10 @@ FAR struct socketlist *sched_getsockets(void) { FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; - return rtcb->sockets; + FAR struct task_group_s *group = rtcb->group; + + DEBUGASSERT(group); + return &group->tg_socketlist; } #endif /* CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/nuttx/sched/sched_setuppthreadfiles.c b/nuttx/sched/sched_setuppthreadfiles.c deleted file mode 100644 index 91d72fa7f..000000000 --- a/nuttx/sched/sched_setuppthreadfiles.c +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** - * sched_setuppthreadfiles.c - * - * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <gnutt@nuttx.org> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * 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 <sched.h> - -#include <nuttx/fs/fs.h> -#include <nuttx/net/net.h> -#include <nuttx/lib.h> - -#include "os_internal.h" - -#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: sched_setuppthreadfiles - * - * Description: - * Configure a newly allocated TCB so that it will inherit file - * descriptors and streams from the parent pthread. - * - * Parameters: - * tcb - tcb of the new task. - * - * Return Value: - * OK (if an error were returned, it would need to be a non-negated - * errno value). - * - * Assumptions: - * - ****************************************************************************/ - -int sched_setuppthreadfiles(FAR _TCB *tcb) -{ -#if CONFIG_NSOCKET_DESCRIPTORS > 0 - /* The child thread inherits the parent socket descriptors */ - - tcb->sockets = rtcb->sockets; - net_addreflist(tcb->sockets); - -#endif /* CONFIG_NSOCKET_DESCRIPTORS */ - - return OK; -} - -#endif /* CONFIG_NFILE_DESCRIPTORS || CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/nuttx/sched/task_create.c b/nuttx/sched/task_create.c index 85c0f5e92..944743200 100644 --- a/nuttx/sched/task_create.c +++ b/nuttx/sched/task_create.c @@ -134,7 +134,7 @@ static int thread_create(const char *name, uint8_t ttype, int priority, /* Associate file descriptors with the new task */ #if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 - ret = sched_setuptaskfiles(tcb); + ret = group_setuptaskfiles(tcb); if (ret != OK) { errcode = -ret; diff --git a/nuttx/sched/task_init.c b/nuttx/sched/task_init.c index 8dfd8b7f6..78f35bc2a 100644 --- a/nuttx/sched/task_init.c +++ b/nuttx/sched/task_init.c @@ -137,7 +137,7 @@ int task_init(FAR _TCB *tcb, const char *name, int priority, /* Associate file descriptors with the new task */ #if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 - ret = sched_setuptaskfiles(tcb); + ret = group_setuptaskfiles(tcb); if (ret < 0) { errcode = -ret; diff --git a/nuttx/sched/task_vfork.c b/nuttx/sched/task_vfork.c index 3f058bdec..5b42a1e55 100644 --- a/nuttx/sched/task_vfork.c +++ b/nuttx/sched/task_vfork.c @@ -125,7 +125,7 @@ FAR _TCB *task_vforksetup(start_t retaddr) /* Associate file descriptors with the new task */ #if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 - ret = sched_setuptaskfiles(child); + ret = group_setuptaskfiles(child); if (ret != OK) { goto errout_with_tcb; |