diff options
Diffstat (limited to 'core/cortex-m/task.c')
-rw-r--r-- | core/cortex-m/task.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c index f23b8142ff..6b978c9d33 100644 --- a/core/cortex-m/task.c +++ b/core/cortex-m/task.c @@ -167,6 +167,12 @@ static int need_resched_or_profiling; * 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 */ @@ -271,8 +277,8 @@ void svc_handler(int desched, task_id_t resched) ASSERT(resched <= TASK_ID_COUNT); 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 time in interrupts */ @@ -443,8 +449,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); } |