summaryrefslogtreecommitdiffstats
path: root/nuttx/sched/os_start.c
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/sched/os_start.c')
-rw-r--r--nuttx/sched/os_start.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c
index ac52c4d664..9e299a9467 100644
--- a/nuttx/sched/os_start.c
+++ b/nuttx/sched/os_start.c
@@ -62,6 +62,9 @@
#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
@@ -172,12 +175,6 @@ pidhash_t g_pidhash[CONFIG_MAX_TASKS];
pid_t g_worker;
#endif
-/* The task ID of the page fill worker thread */
-
-#ifdef CONFIG_PAGING
-pid_t g_pgworker;
-#endif
-
/* This is a table of task lists. This table is indexed by
* the task state enumeration type (tstate_t) and provides
* a pointer to the associated static task list (if there
@@ -451,6 +448,23 @@ 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