summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-04 23:02:00 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-04 23:02:00 +0000
commita086a5b65839065f33764678c541d3af4afb0568 (patch)
treeb432725a3d8fadeaa4e8b00c071284cdf0fe2fec /nuttx/sched
parentf83c9b840d045664f99114a3c71bbdab5744367c (diff)
downloadpx4-nuttx-a086a5b65839065f33764678c541d3af4afb0568.tar.gz
px4-nuttx-a086a5b65839065f33764678c541d3af4afb0568.tar.bz2
px4-nuttx-a086a5b65839065f33764678c541d3af4afb0568.zip
Move core of fdopen() logic from lib/stdio to fs/
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3464 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/Makefile2
-rw-r--r--nuttx/sched/sched_gettcb.c4
-rw-r--r--nuttx/sched/sched_self.c83
-rw-r--r--nuttx/sched/sched_setupstreams.c16
4 files changed, 95 insertions, 10 deletions
diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile
index 86e7c0b76..f5d2ce9db 100644
--- a/nuttx/sched/Makefile
+++ b/nuttx/sched/Makefile
@@ -53,7 +53,7 @@ TSK_SRCS = task_create.c task_init.c task_setup.c task_activate.c \
SCHED_SRCS = sched_setparam.c sched_setpriority.c sched_getparam.c \
sched_setscheduler.c sched_getscheduler.c \
sched_yield.c sched_rrgetinterval.c sched_foreach.c \
- sched_lock.c sched_unlock.c sched_lockcount.c
+ sched_lock.c sched_unlock.c sched_lockcount.c sched_self.c
ifeq ($(CONFIG_PRIORITY_INHERITANCE),y)
SCHED_SRCS += sched_reprioritize.c
endif
diff --git a/nuttx/sched/sched_gettcb.c b/nuttx/sched/sched_gettcb.c
index a44e310e6..39933369f 100644
--- a/nuttx/sched/sched_gettcb.c
+++ b/nuttx/sched/sched_gettcb.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * sched/ched_gettcb.c
+ * sched/sched_gettcb.c
*
- * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2009, 2011 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/sched_self.c b/nuttx/sched/sched_self.c
new file mode 100644
index 000000000..99a0f1995
--- /dev/null
+++ b/nuttx/sched/sched_self.c
@@ -0,0 +1,83 @@
+/****************************************************************************
+ * sched/sched_self.c
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * 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 <sys/types.h>
+#include <sched.h>
+#include "os_internal.h"
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Type Declarations
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sched_self
+ *
+ * Description:
+ * Return the current threads TCB. Basically, this function just wraps the
+ * head of the ready-to-run list and manages access to the TCB from outside
+ * of the sched/ sub-directory.
+ *
+ ****************************************************************************/
+
+FAR _TCB *sched_self(void)
+{
+ return (FAR _TCB*)g_readytorun.head;
+}
+
+
diff --git a/nuttx/sched/sched_setupstreams.c b/nuttx/sched/sched_setupstreams.c
index 28b824f26..a30a9259d 100644
--- a/nuttx/sched/sched_setupstreams.c
+++ b/nuttx/sched/sched_setupstreams.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched_setupstreams.c
*
- * Copyright (C) 2007-2008, 2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2008, 2010-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,8 @@
#include <nuttx/config.h>
#include <sched.h>
+#include <fcntl.h>
+
#include <nuttx/fs.h>
#include <nuttx/net.h>
#include <nuttx/lib.h>
@@ -65,14 +67,14 @@ int sched_setupstreams(FAR _TCB *tcb)
* The following logic depends on the fact that the library
* layer will allocate FILEs in order.
*
- * fd = 0 is stdin
- * fd = 1 is stdout
- * fd = 2 is stderr
+ * fd = 0 is stdin (read-only)
+ * fd = 1 is stdout (write-only, append)
+ * fd = 2 is stderr (write-only, append)
*/
- (void)lib_fdopen(0, "r", tcb->filelist, tcb->streams);
- (void)lib_fdopen(1, "w", tcb->filelist, tcb->streams);
- (void)lib_fdopen(2, "w", tcb->filelist, tcb->streams);
+ (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;