summaryrefslogtreecommitdiff
path: root/nuttx/sched/init
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-10-10 09:34:03 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-10-10 09:38:28 -0600
commit6c1b5b7358c89907d4de7b9d433993ef7a5c9325 (patch)
treeda5861abed2ed00ffd6c89da95203386ed843d10 /nuttx/sched/init
parentcebd34bc8c6a04b2cdc5671feb533526c4478ac7 (diff)
downloadnuttx-6c1b5b7358c89907d4de7b9d433993ef7a5c9325.tar.gz
nuttx-6c1b5b7358c89907d4de7b9d433993ef7a5c9325.tar.bz2
nuttx-6c1b5b7358c89907d4de7b9d433993ef7a5c9325.zip
Modularize starting of worker threads to better isolate individual initialization characteristics
Diffstat (limited to 'nuttx/sched/init')
-rw-r--r--nuttx/sched/init/os_bringup.c90
1 files changed, 32 insertions, 58 deletions
diff --git a/nuttx/sched/init/os_bringup.c b/nuttx/sched/init/os_bringup.c
index b4a5537d5..09f31d2e0 100644
--- a/nuttx/sched/init/os_bringup.c
+++ b/nuttx/sched/init/os_bringup.c
@@ -117,24 +117,10 @@
# endif
#endif
-/* If NuttX is built as a separately compiled module, then the config.h header
- * file should contain the address of the entry point (or path to the file)
- * that will perform the application-level initialization.
- */
+/* In the protected build (only) we also need to start the user work queue */
-/* Customize some strings */
-
-#ifdef CONFIG_SCHED_WORKQUEUE
-# ifdef CONFIG_SCHED_HPWORK
-# if defined(CONFIG_SCHED_LPWORK)
-# define HPWORKNAME "hpwork"
-# define LPWORKNAME "lpwork"
-# elif defined(CONFIG_SCHED_USRWORK)
-# define HPWORKNAME "knlwork"
-# else
-# define HPWORKNAME "work"
-# endif
-# endif
+#if !defined(CONFIG_BUILD_PROTECTED)
+# undef CONFIG_SCHED_USRWORK
#endif
/****************************************************************************
@@ -211,47 +197,35 @@ static inline void os_pgworker(void)
#ifdef CONFIG_SCHED_WORKQUEUE
static inline void os_workqueues(void)
{
-#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_SCHED_USRWORK)
- int taskid;
+#ifdef CONFIG_SCHED_USRWORK
+ pid_t pid;
#endif
#ifdef CONFIG_SCHED_HPWORK
-#ifdef CONFIG_SCHED_LPWORK
- svdbg("Starting high-priority kernel worker thread\n");
-#else
- svdbg("Starting kernel worker thread\n");
-#endif
+ /* Start the high-priority worker thread to support device driver lower
+ * halves.
+ */
- g_hpwork.pid = kernel_thread(HPWORKNAME, CONFIG_SCHED_WORKPRIORITY,
- CONFIG_SCHED_WORKSTACKSIZE,
- (main_t)work_hpthread,
- (FAR char * const *)NULL);
- DEBUGASSERT(g_hpwork.pid > 0);
+ (void)work_hpstart();
- /* Start a lower priority worker thread for other, non-critical continuation
- * tasks
- */
+#endif /* CONFIG_SCHED_HPWORK */
#ifdef CONFIG_SCHED_LPWORK
+ /* Start the low-priority worker thread for other, non-critical continuation
+ * tasks
+ */
- svdbg("Starting low-priority kernel worker thread\n");
-
- g_lpwork.pid = kernel_thread(LPWORKNAME, CONFIG_SCHED_LPWORKPRIORITY,
- CONFIG_SCHED_LPWORKSTACKSIZE,
- (main_t)work_lpthread,
- (FAR char * const *)NULL);
- DEBUGASSERT(g_lpwork.pid > 0);
+ (void)work_lpstart();
#endif /* CONFIG_SCHED_LPWORK */
-#endif /* CONFIG_SCHED_HPWORK */
-#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_SCHED_USRWORK)
+#ifdef CONFIG_SCHED_USRWORK
/* Start the user-space work queue */
DEBUGASSERT(USERSPACE->work_usrstart != NULL);
- taskid = USERSPACE->work_usrstart();
- DEBUGASSERT(taskid > 0);
- UNUSED(taskid);
+ pid = USERSPACE->work_usrstart();
+ DEBUGASSERT(pid > 0);
+ UNUSED(pid);
#endif
}
@@ -278,7 +252,7 @@ static inline void os_workqueues(void)
#if defined(CONFIG_INIT_ENTRYPOINT)
static inline void os_do_appstart(void)
{
- int taskid;
+ int pid;
#ifdef CONFIG_BOARD_INITIALIZE
/* Perform any last-minute, board-specific initialization, if so
@@ -298,16 +272,16 @@ static inline void os_do_appstart(void)
#ifdef CONFIG_BUILD_PROTECTED
DEBUGASSERT(USERSPACE->us_entrypoint != NULL);
- taskid = task_create("init", SCHED_PRIORITY_DEFAULT,
- CONFIG_USERMAIN_STACKSIZE, USERSPACE->us_entrypoint,
- (FAR char * const *)NULL);
+ pid = task_create("init", SCHED_PRIORITY_DEFAULT,
+ CONFIG_USERMAIN_STACKSIZE, USERSPACE->us_entrypoint,
+ (FAR char * const *)NULL);
#else
- taskid = task_create("init", SCHED_PRIORITY_DEFAULT,
- CONFIG_USERMAIN_STACKSIZE,
- (main_t)CONFIG_USER_ENTRYPOINT,
- (FAR char * const *)NULL);
+ pid = task_create("init", SCHED_PRIORITY_DEFAULT,
+ CONFIG_USERMAIN_STACKSIZE,
+ (main_t)CONFIG_USER_ENTRYPOINT,
+ (FAR char * const *)NULL);
#endif
- ASSERT(taskid > 0);
+ ASSERT(pid > 0);
}
#elif defined(CONFIG_INIT_FILEPATH)
@@ -389,16 +363,16 @@ static int os_start_task(int argc, FAR char **argv)
static inline void os_start_application(void)
{
#ifdef CONFIG_BOARD_INITTHREAD
- int taskid;
+ int pid;
/* Do the board/application initialization on a separate thread of
* execution.
*/
- taskid = kernel_thread("AppBringUp", CONFIG_BOARD_INITTHREAD_PRIORITY,
- CONFIG_BOARD_INITTHREAD_STACKSIZE,
- (main_t)os_start_task, (FAR char * const *)NULL);
- ASSERT(taskid > 0);
+ pid = kernel_thread("AppBringUp", CONFIG_BOARD_INITTHREAD_PRIORITY,
+ CONFIG_BOARD_INITTHREAD_STACKSIZE,
+ (main_t)os_start_task, (FAR char * const *)NULL);
+ ASSERT(pid > 0);
#else
/* Do the board/application initialization on this thread of execution. */