forked from Archive/PX4-Autopilot
Move stream data from TCB to task group structure.
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5569 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
3bec164b3a
commit
b82c36961a
|
@ -4036,3 +4036,5 @@
|
|||
task group IN the child task's task group.
|
||||
* fs/, sched/, include/nuttx/sched.h, and include/nutts/fs/fs.h:
|
||||
Move file data from TCB to task group structure.
|
||||
* libc/stdio/, sched/, include/nuttx/lib.h, and include/nutts/fs/fs.h:
|
||||
Move stream data from TCB to task group structure.
|
||||
|
|
|
@ -75,7 +75,11 @@
|
|||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_STREAMS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *filelist;
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streamlist;
|
||||
#endif
|
||||
int i;
|
||||
#endif
|
||||
|
||||
|
@ -83,30 +87,23 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
sdbg(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
FAR struct filelist *list = tcb->group->tg_filelist;
|
||||
filelist = tcb->group->tg_filelist;
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = list->fl_files[i].f_inode;
|
||||
struct inode *inode = filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
sdbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
sdbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
|
||||
streamlist = tcb->group->tg_streamlist;
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
struct file_struct *filep = &tcb->streams->sl_streams[i];
|
||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||
if (filep->fs_filedes >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
|
@ -118,7 +115,6 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -75,7 +75,11 @@
|
|||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_STREAMS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *filelist;
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streamlist;
|
||||
#endif
|
||||
int i;
|
||||
#endif
|
||||
|
||||
|
@ -83,30 +87,23 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
sdbg(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
FAR struct filelist *list = tcb->group->tg_filelist;
|
||||
filelist = tcb->group->tg_filelist;
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = list->fl_files[i].f_inode;
|
||||
struct inode *inode = filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
sdbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
sdbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
|
||||
streamlist = tcb->group->tg_streamlist;
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
struct file_struct *filep = &tcb->streams->sl_streams[i];
|
||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||
if (filep->fs_filedes >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
|
@ -118,7 +115,6 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -75,7 +75,11 @@
|
|||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_STREAMS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *filelist;
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streamlist;
|
||||
#endif
|
||||
int i;
|
||||
#endif
|
||||
|
||||
|
@ -83,30 +87,23 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
sdbg(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
FAR struct filelist *list = tcb->group->tg_filelist;
|
||||
filelist = tcb->group->tg_filelist;
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = list->fl_files[i].f_inode;
|
||||
struct inode *inode = filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
sdbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
sdbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
|
||||
streamlist = tcb->group->tg_streamlist;
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
struct file_struct *filep = &tcb->streams->sl_streams[i];
|
||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||
if (filep->fs_filedes >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
|
@ -118,7 +115,6 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -77,7 +77,11 @@
|
|||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_STREAMS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *filelist;
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streamlist;
|
||||
#endif
|
||||
int i;
|
||||
#endif
|
||||
|
||||
|
@ -85,30 +89,23 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
sdbg(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
FAR struct filelist *list = tcb->group->tg_filelist;
|
||||
filelist = tcb->group->tg_filelist;
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = list->fl_files[i].f_inode;
|
||||
struct inode *inode = filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
sdbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
sdbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
|
||||
streamlist = tcb->group->tg_streamlist;
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
struct file_struct *filep = &tcb->streams->sl_streams[i];
|
||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||
if (filep->fs_filedes >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
|
@ -120,7 +117,6 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -76,7 +76,11 @@
|
|||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_STREAMS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *filelist;
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streamlist;
|
||||
#endif
|
||||
int i;
|
||||
#endif
|
||||
|
||||
|
@ -84,30 +88,23 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
sdbg(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
FAR struct filelist *list = tcb->group->tg_filelist;
|
||||
filelist = tcb->group->tg_filelist;
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = list->fl_files[i].f_inode;
|
||||
struct inode *inode = filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
sdbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
sdbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
|
||||
streamlist = tcb->group->tg_streamlist;
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
struct file_struct *filep = &tcb->streams->sl_streams[i];
|
||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||
if (filep->fs_filedes >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
|
@ -119,7 +116,6 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* common/up_exit.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -75,7 +75,11 @@
|
|||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_STREAMS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *filelist;
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streamlist;
|
||||
#endif
|
||||
int i;
|
||||
#endif
|
||||
|
||||
|
@ -83,30 +87,23 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
sdbg(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
FAR struct filelist *list = tcb->group->tg_filelist;
|
||||
filelist = tcb->group->tg_filelist;
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = list->fl_files[i].f_inode;
|
||||
struct inode *inode = filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
sdbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
sdbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
|
||||
streamlist = tcb->group->tg_streamlist;
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
struct file_struct *filep = &tcb->streams->sl_streams[i];
|
||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||
if (filep->fs_filedes >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
|
@ -118,7 +115,6 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -77,7 +77,11 @@
|
|||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_STREAMS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *filelist;
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streamlist;
|
||||
#endif
|
||||
int i;
|
||||
#endif
|
||||
|
||||
|
@ -85,30 +89,23 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
lldbg(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
FAR struct filelist *list = tcb->group->tg_filelist;
|
||||
filelist = tcb->group->tg_filelist;
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = list->fl_files[i].f_inode;
|
||||
struct inode *inode = filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
lldbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
lldbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
|
||||
streamlist = tcb->group->tg_streamlist;
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
struct file_struct *filep = &tcb->streams->sl_streams[i];
|
||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||
if (filep->fs_filedes >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
|
@ -120,7 +117,6 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* common/up_exit.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
|
||||
|
@ -78,7 +78,11 @@
|
|||
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
|
||||
static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NFILE_STREAMS > 0
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
FAR struct filelist *filelist;
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streamlist;
|
||||
#endif
|
||||
int i;
|
||||
#endif
|
||||
|
||||
|
@ -86,30 +90,23 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
lldbg(" priority=%d state=%d\n", tcb->sched_priority, tcb->task_state);
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
if (tcb->filelist)
|
||||
{
|
||||
FAR struct filelist *list = tcb->group->tg_filelist;
|
||||
filelist = tcb->group->tg_filelist;
|
||||
for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++)
|
||||
{
|
||||
struct inode *inode = list->fl_files[i].f_inode;
|
||||
struct inode *inode = filelist->fl_files[i].f_inode;
|
||||
if (inode)
|
||||
{
|
||||
lldbg(" fd=%d refcount=%d\n",
|
||||
i, inode->i_crefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
if (tcb->streams)
|
||||
{
|
||||
lldbg(" streamlist refcount=%d\n",
|
||||
tcb->streams->sl_crefs);
|
||||
|
||||
streamlist = tcb->group->tg_streamlist;
|
||||
for (i = 0; i < CONFIG_NFILE_STREAMS; i++)
|
||||
{
|
||||
struct file_struct *filep = &tcb->streams->sl_streams[i];
|
||||
struct file_struct *filep = &streamlist->sl_streams[i];
|
||||
if (filep->fs_filedes >= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
|
@ -121,7 +118,6 @@ static void _up_dumponexit(FAR _TCB *tcb, FAR void *arg)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -144,6 +144,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR _TCB *tcb)
|
|||
{
|
||||
tcb = sched_self();
|
||||
}
|
||||
DEBUGASSERT(tcb && tcb->group);
|
||||
|
||||
/* Verify that this is a valid file/socket descriptor and that the
|
||||
* requested access can be support.
|
||||
|
@ -191,7 +192,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR _TCB *tcb)
|
|||
|
||||
/* Get the stream list from the TCB */
|
||||
|
||||
slist = tcb->streams;
|
||||
slist = &tcb->group->tg_streamlist;
|
||||
|
||||
/* Find an unallocated FILE structure in the stream list */
|
||||
|
||||
|
|
|
@ -293,7 +293,6 @@ struct file_struct
|
|||
|
||||
struct streamlist
|
||||
{
|
||||
int sl_crefs; /* Reference count */
|
||||
sem_t sl_sem; /* For thread safety */
|
||||
struct file_struct sl_streams[CONFIG_NFILE_STREAMS];
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* include/nuttx/lib.h
|
||||
* Non-standard, internal APIs available in lib/.
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -67,11 +67,10 @@ extern "C" {
|
|||
|
||||
/* Functions contained in lib_init.c ****************************************/
|
||||
|
||||
EXTERN void weak_function lib_initialize(void);
|
||||
void weak_function lib_initialize(void);
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
EXTERN FAR struct streamlist *lib_alloclist(void);
|
||||
EXTERN void lib_addreflist(FAR struct streamlist *list);
|
||||
EXTERN void lib_releaselist(FAR struct streamlist *list);
|
||||
void lib_streaminit(FAR struct streamlist *list);
|
||||
void lib_releaselist(FAR struct streamlist *list);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
|
|
|
@ -81,6 +81,8 @@
|
|||
# define HAVE_TASK_GROUP 1
|
||||
# elif CONFIG_NFILE_DESCRIPTORS > 0
|
||||
# define HAVE_TASK_GROUP 1
|
||||
# elif CONFIG_NFILE_STREAMS > 0
|
||||
# define HAVE_TASK_GROUP 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -303,7 +305,10 @@ struct task_group_s
|
|||
#endif
|
||||
|
||||
/* FILE streams ***************************************************************/
|
||||
/* Not yet (see streamlist) */
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
struct streamlist tg_streamlist; /* Holds C buffered I/O info */
|
||||
#endif /* CONFIG_NFILE_STREAMS */
|
||||
|
||||
/* Sockets ********************************************************************/
|
||||
/* Not yet (see struct socketlist) */
|
||||
|
@ -445,12 +450,6 @@ struct _TCB
|
|||
|
||||
int pterrno; /* Current per-thread errno */
|
||||
|
||||
/* File system support ********************************************************/
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
FAR struct streamlist *streams; /* Holds C buffered I/O info */
|
||||
#endif
|
||||
|
||||
/* Network socket *************************************************************/
|
||||
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/************************************************************
|
||||
* libc/misc/lib_init.c
|
||||
*
|
||||
* Copyright (C) 2007, 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -76,22 +76,14 @@ void weak_const_function lib_initialize(void)
|
|||
}
|
||||
|
||||
#if CONFIG_NFILE_STREAMS > 0
|
||||
/* The following function is called when a new TCB is allocated. It
|
||||
* creates the streamlist instance that is stored in the TCB.
|
||||
/* The following function is called when a new task is allocated. It
|
||||
* intializes the streamlist instance that is stored in the task group.
|
||||
*/
|
||||
|
||||
FAR struct streamlist *lib_alloclist(void)
|
||||
{
|
||||
FAR struct streamlist *list;
|
||||
list = (FAR struct streamlist*)lib_zalloc(sizeof(struct streamlist));
|
||||
if (list)
|
||||
void lib_streaminit(FAR struct streamlist *list)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Start with a reference count of one */
|
||||
|
||||
list->sl_crefs = 1;
|
||||
|
||||
/* Initialize the list access mutex */
|
||||
|
||||
(void)sem_init(&list->sl_sem, 0, 1);
|
||||
|
@ -115,32 +107,6 @@ FAR struct streamlist *lib_alloclist(void)
|
|||
lib_sem_initialize(&list->sl_streams[i]);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
/* This function is called when a TCB is closed (such as with
|
||||
* pthread_create(). It increases the reference count on the stream
|
||||
* list.
|
||||
*/
|
||||
|
||||
void lib_addreflist(FAR struct streamlist *list)
|
||||
{
|
||||
if (list)
|
||||
{
|
||||
/* Increment the reference count on the list.
|
||||
* NOTE: that we disable interrupts to do this
|
||||
* (vs. taking the list semaphore). We do this
|
||||
* because file cleanup operations often must be
|
||||
* done from the IDLE task which cannot wait
|
||||
* on semaphores.
|
||||
*/
|
||||
|
||||
register irqstate_t flags = irqsave();
|
||||
list->sl_crefs++;
|
||||
irqrestore(flags);
|
||||
}
|
||||
}
|
||||
|
||||
/* this function is called when a TCB is destroyed. Note that is
|
||||
* does not close the file by release this inode. This happens
|
||||
|
@ -149,32 +115,12 @@ void lib_addreflist(FAR struct streamlist *list)
|
|||
|
||||
void lib_releaselist(FAR struct streamlist *list)
|
||||
{
|
||||
int crefs;
|
||||
if (list)
|
||||
{
|
||||
/* Decrement the reference count on the list.
|
||||
* NOTE: that we disable interrupts to do this
|
||||
* (vs. taking the list semaphore). We do this
|
||||
* because file cleanup operations often must be
|
||||
* done from the IDLE task which cannot wait
|
||||
* on semaphores.
|
||||
*/
|
||||
|
||||
register irqstate_t flags = irqsave();
|
||||
crefs = --(list->sl_crefs);
|
||||
irqrestore(flags);
|
||||
|
||||
/* If the count decrements to zero, then there is no reference
|
||||
* to the structure and it should be deallocated. Since there
|
||||
* are references, it would be an error if any task still held
|
||||
* a reference to the list's semaphore.
|
||||
*/
|
||||
|
||||
if (crefs <= 0)
|
||||
{
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
int i;
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(list);
|
||||
|
||||
/* Destroy the semaphore and release the filelist */
|
||||
|
||||
(void)sem_destroy(&list->sl_sem);
|
||||
|
@ -189,17 +135,13 @@ void lib_releaselist(FAR struct streamlist *list)
|
|||
(void)sem_destroy(&list->sl_streams[i].fs_sem);
|
||||
|
||||
/* Release the IO buffer */
|
||||
|
||||
if (list->sl_streams[i].fs_bufstart)
|
||||
{
|
||||
sched_free(list->sl_streams[i].fs_bufstart);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* Finally, release the list itself */
|
||||
|
||||
sched_free(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NFILE_STREAMS */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* libc/stdio/lib_libflushall.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -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)
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_SCHED_CHILD_STATUS */
|
||||
#endif /* CONFIG_SCHED_HAVE_PARENT */
|
||||
|
||||
#endif /* __SCHED_GROUP_INERNAL_H */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,14 +72,14 @@
|
|||
|
||||
int sched_setupstreams(FAR _TCB *tcb)
|
||||
{
|
||||
/* Allocate file streams for the TCB */
|
||||
DEBUGASSERT(tcb && tcb->group);
|
||||
|
||||
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.
|
||||
/* 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)
|
||||
|
@ -89,7 +89,6 @@ int sched_setupstreams(FAR _TCB *tcb)
|
|||
(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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue