diff options
Diffstat (limited to 'core/cortex-m0/task.c')
-rw-r--r-- | core/cortex-m0/task.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/cortex-m0/task.c b/core/cortex-m0/task.c index 8796983127..32f67e0d62 100644 --- a/core/cortex-m0/task.c +++ b/core/cortex-m0/task.c @@ -134,6 +134,12 @@ static task_ *current_task = (task_ *)scratchpad; * make a call to enable all tasks. */ static uint32_t tasks_ready = (1 << TASK_ID_HOOKS); +/* + * Initially allow only the HOOKS and IDLE task to run, regardless of ready + * status, in order for HOOK_INIT to complete before other tasks. + * task_enable_all_tasks() will open the flood gates. + */ +static uint32_t tasks_enabled = (1 << TASK_ID_HOOKS) | (1 << TASK_ID_IDLE); static int start_called; /* Has task swapping started */ @@ -234,8 +240,8 @@ task_ __attribute__((noinline)) *__svc_handler(int desched, task_id_t resched) } tasks_ready |= 1 << resched; - ASSERT(tasks_ready); - next = __task_id_to_ptr(__fls(tasks_ready)); + ASSERT(tasks_ready & tasks_enabled); + next = __task_id_to_ptr(__fls(tasks_ready & tasks_enabled)); #ifdef CONFIG_TASK_PROFILING /* Track additional time in re-sched exception context */ @@ -442,8 +448,8 @@ uint32_t task_wait_event_mask(uint32_t event_mask, int timeout_us) void task_enable_all_tasks(void) { - /* Mark all tasks as ready to run. */ - tasks_ready = (1 << TASK_ID_COUNT) - 1; + /* Mark all tasks as ready and able to run. */ + tasks_ready = tasks_enabled = (1 << TASK_ID_COUNT) - 1; /* Reschedule the highest priority task. */ __schedule(0, 0); } |