summaryrefslogtreecommitdiffstats
path: root/nuttx/sched
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-03-12 17:49:47 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2011-03-12 17:49:47 +0000
commit5792da5257d849743163a59161c5b76422401f3d (patch)
tree4f798fecb44a0a79183b734b1f6f8450871adeba /nuttx/sched
parent6d6aebced7e7a870887351740c7223c030f52a30 (diff)
More apps/ related changes
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@3372 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/Makefile2
-rw-r--r--nuttx/sched/os_bringup.c167
-rw-r--r--nuttx/sched/os_internal.h3
-rw-r--r--nuttx/sched/os_start.c55
4 files changed, 173 insertions, 54 deletions
diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile
index 55dd15547b..50ef997fca 100644
--- a/nuttx/sched/Makefile
+++ b/nuttx/sched/Makefile
@@ -38,7 +38,7 @@
ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
-MISC_SRCS = os_start.c get_errno_ptr.c sched_garbage.c \
+MISC_SRCS = os_start.c os_bringup.c get_errno_ptr.c sched_garbage.c \
sched_setupstreams.c sched_getfiles.c sched_getsockets.c sched_getstreams.c \
sched_setupidlefiles.c sched_setuptaskfiles.c sched_setuppthreadfiles.c \
sched_releasefiles.c
diff --git a/nuttx/sched/os_bringup.c b/nuttx/sched/os_bringup.c
new file mode 100644
index 0000000000..0436afec7f
--- /dev/null
+++ b/nuttx/sched/os_bringup.c
@@ -0,0 +1,167 @@
+/****************************************************************************
+ * sched/os_bringup.c
+ *
+ * Copyright (C) 2011 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * With extensions by:
+ *
+ * Author: Uros Platise <uros.platise@isotel.eu>
+ *
+ * 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 <debug.h>
+
+#include <nuttx/init.h>
+
+#ifdef CONFIG_PAGING
+# include "pg_internal.h"
+#endif
+#ifdef CONFIG_SCHED_WORKQUEUE
+# include "work_internal.h"
+#endif
+#ifdef CONFIG_BUILTIN_APPS_NUTTX
+# include "nuttx/nuttapp.h"
+#endif
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#ifndef CONFIG_CUSTOM_STACK
+# define START_TASK(n,p,s,e,a) task_create(n,p,s,e,a)
+#else
+# define START_TASK(n,p,s,e,a) task_create(n,p,e,a)
+#endif
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: os_bringup
+ *
+ * Description:
+ * Start all initial system tasks. This does the "system bring-up" after
+ * the conclusion of basic OS initialization. These initial system tasks
+ * may include:
+ *
+ * - pg_worker: The page-fault worker thread (only if CONFIG_PAGING is
+ * defined.
+ * - work_thread: The work thread. This general thread can be used to
+ * perform most any kind of queued work. Its primary
+ * function is to serve as the "bottom half" of device
+ * drivers.
+ *
+ * And the main application entry point. This may be one of two different
+ * symbols:
+ *
+ * - user_start: This is the default entry point used for all of the
+ * examples.
+ * - CONFIG_BUILTIN_APP_START: The system can also be configured to start
+ * custom applications at however CONFIG_BUILTIN_APP_START
+ * is defined in the NuttX start-up file.
+ *
+ ****************************************************************************/
+
+int os_bringup(void)
+{
+ int init_taskid;
+
+ /* Start the page fill worker thread that will resolve page faults.
+ * This should always be the first thread started because it may
+ * have to resolve page faults in other threads
+ */
+
+#ifdef CONFIG_PAGING
+ svdbg("Starting paging thread\n");
+
+ g_pgworker = START_TASK("pgfill", CONFIG_PAGING_DEFPRIO,
+ CONFIG_PAGING_STACKSIZE,
+ (main_t)pg_worker, (const char **)NULL);
+ ASSERT(g_pgworker != ERROR);
+#endif
+
+ /* Start the worker thread that will perform misc garbage clean-up */
+
+#ifdef CONFIG_SCHED_WORKQUEUE
+ svdbg("Starting worker thread\n");
+
+ g_worker = START_TASK("work", CONFIG_SCHED_WORKPRIORITY,
+ CONFIG_SCHED_WORKSTACKSIZE,
+ (main_t)work_thread, (const char **)NULL);
+ ASSERT(g_worker != ERROR);
+#endif
+
+ /* Once the operating system has been initialized, the system must be
+ * started by spawning the user init thread of execution.
+ */
+
+ svdbg("Starting init thread\n");
+
+#if defined(CONFIG_BUILTIN_APPS_NUTTX) && defined(CONFIG_BUILTIN_APP_START)
+ init_taskid = exec_nuttapp(CONFIG_BUILTIN_APP_START, (const char **)NULL);
+#else
+ init_taskid = START_TASK("init", SCHED_PRIORITY_DEFAULT,
+ CONFIG_USERMAIN_STACKSIZE,
+ (main_t)user_start, (const char **)NULL);
+#endif
+ ASSERT(init_taskid != ERROR);
+ return OK;
+}
+
+
diff --git a/nuttx/sched/os_internal.h b/nuttx/sched/os_internal.h
index f2cbbf863c..8cd7257b4c 100644
--- a/nuttx/sched/os_internal.h
+++ b/nuttx/sched/os_internal.h
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/os_internal.h
*
- * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -248,6 +248,7 @@ extern const tasklist_t g_tasklisttable[NUM_TASK_STATES];
* Public Function Prototypes
****************************************************************************/
+extern int os_bringup(void);
extern void task_start(void);
extern int task_schedsetup(FAR _TCB *tcb, int priority, start_t start,
main_t main);
diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c
index 6ca865fbc3..9b5fd4938d 100644
--- a/nuttx/sched/os_start.c
+++ b/nuttx/sched/os_start.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/os_start.c
*
- * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -62,12 +62,6 @@
#include "clock_internal.h"
#include "timer_internal.h"
#include "irq_internal.h"
-#ifdef CONFIG_PAGING
-# include "pg_internal.h"
-#endif
-#ifdef CONFIG_SCHED_WORKQUEUE
-# include "work_internal.h"
-#endif
/****************************************************************************
* Pre-processor Definitions
@@ -238,7 +232,6 @@ static FAR char g_idlename[] = "Idle Task";
void os_start(void)
{
- int init_taskid;
int i;
slldbg("Entry\n");
@@ -451,51 +444,9 @@ void os_start(void)
(void)sched_setupidlefiles(&g_idletcb);
- /* Start the page fill worker thread that will resolve page faults.
- * This should always be the first thread started because it may
- * have to resolve page faults in other threads
- */
-
-#ifdef CONFIG_PAGING
-#ifndef CONFIG_CUSTOM_STACK
- g_pgworker = task_create("pgfill", CONFIG_PAGING_DEFPRIO,
- CONFIG_PAGING_STACKSIZE,
- (main_t)pg_worker, (const char **)NULL);
-#else
- g_pgworker = task_create("pgfill", CONFIG_PAGING_DEFPRIO,
- (main_t)pg_worker, (const char **)NULL);
-#endif
- ASSERT(g_pgworker != ERROR);
-#endif
-
- /* Start the worker thread that will perform misc garbage clean-up */
-
-#ifdef CONFIG_SCHED_WORKQUEUE
-#ifndef CONFIG_CUSTOM_STACK
- g_worker = task_create("work", CONFIG_SCHED_WORKPRIORITY,
- CONFIG_SCHED_WORKSTACKSIZE,
- (main_t)work_thread, (const char **)NULL);
-#else
- g_worker = task_create("work", CONFIG_SCHED_WORKPRIORITY,
- (main_t)work_thread, (const char **)NULL);
-#endif
- ASSERT(g_worker != ERROR);
-#endif
-
- /* Once the operating system has been initialized, the system must be
- * started by spawning the user init thread of execution.
- */
+ /* Create initial tasks and bring-up the system */
- sdbg("Starting init thread\n");
-#ifndef CONFIG_CUSTOM_STACK
- init_taskid = task_create("init", SCHED_PRIORITY_DEFAULT,
- CONFIG_USERMAIN_STACKSIZE,
- (main_t)user_start, (const char **)NULL);
-#else
- init_taskid = task_create("init", SCHED_PRIORITY_DEFAULT,
- (main_t)user_start, (const char **)NULL);
-#endif
- ASSERT(init_taskid != ERROR);
+ (void)os_bringup();
/* When control is return to this point, the system is idle. */