summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/group_internal.h27
-rw-r--r--nuttx/sched/group_leave.c2
-rw-r--r--nuttx/sched/group_releasefiles.c9
-rw-r--r--nuttx/sched/sched_getfiles.c2
-rw-r--r--nuttx/sched/sched_getstreams.c7
-rw-r--r--nuttx/sched/sched_setuppthreadfiles.c9
-rw-r--r--nuttx/sched/sched_setupstreams.c35
-rw-r--r--nuttx/sched/task_exithook.c2
8 files changed, 34 insertions, 59 deletions
diff --git a/nuttx/sched/group_internal.h b/nuttx/sched/group_internal.h
index 39d0a2b7c..e6e0dfd16 100644
--- a/nuttx/sched/group_internal.h
+++ b/nuttx/sched/group_internal.h
@@ -86,28 +86,11 @@ void group_leave(FAR _TCB *tcb);
FAR struct task_group_s *group_find(gid_t gid);
int group_addmember(FAR struct task_group_s *group, pid_t pid);
int group_removemember(FAR struct task_group_s *group, pid_t pid);
-#else
-# define group_find(gid) (NULL)
-# define group_addmember(group,pid) (0)
-# define group_removemember(group,pid) (1)
#endif
#ifndef CONFIG_DISABLE_SIGNALS
int group_signal(FAR struct task_group_s *group, FAR siginfo_t *info);
-#else
-# define group_signal(tcb,info) (0)
#endif
-
-#else
-# define group_allocate(tcb) (0)
-# define group_initialize(tcb) (0)
-# define group_bind(tcb) (0)
-# define group_join(tcb) (0)
-# define group_leave(tcb)
-# define group_find(gid) (NULL)
-# define group_addmember(group,pid) (0)
-# define group_removemember(group,pid) (1)
-# define group_signal(tcb,info) (0)
#endif /* HAVE_TASK_GROUP */
/* Parent/child data management */
@@ -127,15 +110,13 @@ FAR struct child_status_s *group_removechild(FAR struct task_group_s *group,
pid_t pid);
void group_removechildren(FAR struct task_group_s *group);
+#endif /* CONFIG_SCHED_CHILD_STATUS */
+#endif /* CONFIG_SCHED_HAVE_PARENT */
+
/* File/network resources */
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0
-int group_releasefiles(FAR _TCB *tcb);
-#else
-# define group_releasefiles(t) (OK)
+int group_releasefiles(FAR _TCB *tcb);
#endif
-#endif /* CONFIG_SCHED_CHILD_STATUS */
-#endif /* CONFIG_SCHED_HAVE_PARENT */
-
#endif /* __SCHED_GROUP_INERNAL_H */
diff --git a/nuttx/sched/group_leave.c b/nuttx/sched/group_leave.c
index 158ba30b5..70ef93666 100644
--- a/nuttx/sched/group_leave.c
+++ b/nuttx/sched/group_leave.c
@@ -165,6 +165,7 @@ static inline void group_release(FAR _TCB *tcb,
env_release(tcb);
#endif
+#ifdef HAVE_GROUP_MEMBERS
/* Remove the group from the list of groups */
group_remove(group);
@@ -176,6 +177,7 @@ static inline void group_release(FAR _TCB *tcb,
sched_free(group->tg_members);
group->tg_members = NULL;
}
+#endif
/* Release the group container itself */
diff --git a/nuttx/sched/group_releasefiles.c b/nuttx/sched/group_releasefiles.c
index 40bf373b4..b33415c76 100644
--- a/nuttx/sched/group_releasefiles.c
+++ b/nuttx/sched/group_releasefiles.c
@@ -80,7 +80,9 @@ int group_releasefiles(_TCB *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);
@@ -88,11 +90,8 @@ int group_releasefiles(_TCB *tcb)
#if CONFIG_NFILE_STREAMS > 0
/* Free the stream list */
- if (tcb->streams)
- {
- lib_releaselist(tcb->streams);
- tcb->streams = NULL;
- }
+ lib_releaselist(&group->tg_streamlist);
+
#endif /* CONFIG_NFILE_STREAMS */
#endif /* CONFIG_NFILE_DESCRIPTORS */
diff --git a/nuttx/sched/sched_getfiles.c b/nuttx/sched/sched_getfiles.c
index eca4ba3ff..17ca2bbf6 100644
--- a/nuttx/sched/sched_getfiles.c
+++ b/nuttx/sched/sched_getfiles.c
@@ -1,7 +1,7 @@
/************************************************************************
* sched/sched_getfiles.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
diff --git a/nuttx/sched/sched_getstreams.c b/nuttx/sched/sched_getstreams.c
index f7c21ab4c..dab406e66 100644
--- a/nuttx/sched/sched_getstreams.c
+++ b/nuttx/sched/sched_getstreams.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/sched_getstreams.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -70,7 +70,10 @@
FAR struct streamlist *sched_getstreams(void)
{
FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
- return rtcb->streams;
+ FAR struct task_group_s *group = rtcb->group;
+
+ DEBUGASSERT(group);
+ return &group->tg_streamlist;
}
#endif /* CONFIG_NFILE_DESCRIPTORS && CONFIG_NFILE_STREAMS */
diff --git a/nuttx/sched/sched_setuppthreadfiles.c b/nuttx/sched/sched_setuppthreadfiles.c
index 78d6cbfec..91d72fa7f 100644
--- a/nuttx/sched/sched_setuppthreadfiles.c
+++ b/nuttx/sched/sched_setuppthreadfiles.c
@@ -77,8 +77,6 @@
int sched_setuppthreadfiles(FAR _TCB *tcb)
{
- FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head;
-
#if CONFIG_NSOCKET_DESCRIPTORS > 0
/* The child thread inherits the parent socket descriptors */
@@ -87,13 +85,6 @@ int sched_setuppthreadfiles(FAR _TCB *tcb)
#endif /* CONFIG_NSOCKET_DESCRIPTORS */
-#if CONFIG_NFILE_STREAMS > 0
- /* The child thread inherits the parent streams */
-
- tcb->streams = rtcb->streams;
- lib_addreflist(tcb->streams);
-
-#endif /* CONFIG_NFILE_STREAMS */
return OK;
}
diff --git a/nuttx/sched/sched_setupstreams.c b/nuttx/sched/sched_setupstreams.c
index 22895b047..fb2e4d0be 100644
--- a/nuttx/sched/sched_setupstreams.c
+++ b/nuttx/sched/sched_setupstreams.c
@@ -72,24 +72,23 @@
int sched_setupstreams(FAR _TCB *tcb)
{
- /* Allocate file streams for the TCB */
-
- tcb->streams = lib_alloclist();
- if (tcb->streams)
- {
- /* fdopen to get the stdin, stdout and stderr streams.
- * The following logic depends on the fact that the library
- * layer will allocate FILEs in order.
- *
- * fd = 0 is stdin (read-only)
- * fd = 1 is stdout (write-only, append)
- * fd = 2 is stderr (write-only, append)
- */
-
- (void)fs_fdopen(0, O_RDONLY, tcb);
- (void)fs_fdopen(1, O_WROK|O_CREAT, tcb);
- (void)fs_fdopen(2, O_WROK|O_CREAT, tcb);
- }
+ DEBUGASSERT(tcb && tcb->group);
+
+ /* Initialize file streams for the task group */
+
+ lib_streaminit(&tcb->group->tg_streamlist);
+
+ /* fdopen to get the stdin, stdout and stderr streams. The following logic
+ * depends on the fact that the library layer will allocate FILEs in order.
+ *
+ * fd = 0 is stdin (read-only)
+ * fd = 1 is stdout (write-only, append)
+ * fd = 2 is stderr (write-only, append)
+ */
+
+ (void)fs_fdopen(0, O_RDONLY, tcb);
+ (void)fs_fdopen(1, O_WROK|O_CREAT, tcb);
+ (void)fs_fdopen(2, O_WROK|O_CREAT, tcb);
return OK;
}
diff --git a/nuttx/sched/task_exithook.c b/nuttx/sched/task_exithook.c
index 5a2b9e57e..889df25e0 100644
--- a/nuttx/sched/task_exithook.c
+++ b/nuttx/sched/task_exithook.c
@@ -543,7 +543,7 @@ void task_exithook(FAR _TCB *tcb, int status)
*/
#if CONFIG_NFILE_STREAMS > 0
- (void)lib_flushall(tcb->streams);
+ (void)lib_flushall(&tcb->group->tg_streamlist);
#endif
/* Leave the task group. Perhaps discarding any un-reaped child