kernel/thread: Must always initialize is_idle field
Our thread struct gets initialized piecewise in a bunch of locations (this is sort of a design flaw). The is_idle field, which was introduced to identify idle threads in SMP (where there can be more than one), was correctly set for idle threads but was being left uninitialized elsewhere, and in a tiny handful of cases was turning up nonzero. The case in pipes. was particularly vexsome, as that isn't a thread at all but one of the "dummy" threads used for timeouts (another design flaw IMHO). Get this right everywhere. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
cb3964f04f
commit
6c283ca3d0
3 changed files with 11 additions and 4 deletions
|
@ -310,14 +310,14 @@ void __weak main(void)
|
|||
#if defined(CONFIG_MULTITHREADING)
|
||||
static void init_idle_thread(struct k_thread *thr, k_thread_stack_t *stack)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
thr->base.is_idle = 1U;
|
||||
#endif
|
||||
|
||||
z_setup_new_thread(thr, stack,
|
||||
IDLE_STACK_SIZE, idle, NULL, NULL, NULL,
|
||||
K_LOWEST_THREAD_PRIO, K_ESSENTIAL, IDLE_THREAD_NAME);
|
||||
z_mark_thread_as_started(thr);
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
thr->base.is_idle = 1U;
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_MULTITHREADING */
|
||||
|
||||
|
|
|
@ -767,6 +767,9 @@ void k_pipe_block_put(struct k_pipe *pipe, struct k_mem_block *block,
|
|||
async_desc->desc.copy_block = *block;
|
||||
async_desc->desc.sem = sem;
|
||||
async_desc->thread.prio = k_thread_priority_get(_current);
|
||||
#ifdef CONFIG_SMP
|
||||
async_desc->thread.is_idle = 0;
|
||||
#endif
|
||||
|
||||
(void) z_pipe_put_internal(pipe, async_desc, block->data,
|
||||
bytes_to_write, &dummy_bytes_written,
|
||||
|
|
|
@ -775,6 +775,10 @@ void z_init_thread_base(struct _thread_base *thread_base, int priority,
|
|||
|
||||
thread_base->sched_locked = 0U;
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
thread_base->is_idle = 0;
|
||||
#endif
|
||||
|
||||
/* swap_data does not need to be initialized */
|
||||
|
||||
z_init_thread_timeout(thread_base);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue