kernel/sched: arch/x86_64: Support synchronous k_thread_abort() in SMP

Currently thread abort doesn't work if a thread is currently scheduled
on a different CPU, because we have no way of delivering an interrupt
to the other CPU to force the issue.  This patch adds a simple
framework for an architecture to provide such an IPI, implements it
for x86_64, and uses it to implement a spin loop in abort for the case
where a thread is currently scheduled elsewhere.

On SMP architectures (xtensa) where no such IPI is implemented, we
fall back to waiting on an arbitrary interrupt to occur.  This "works"
for typical code (and all current tests), but of course it cannot be
guaranteed on such an architecture that k_thread_abort() will return
in finite time (e.g. the other thread on the other CPU might have
taken a spinlock and entered an infinite loop, so it will never
receive an interrupt to terminate itself)!

On non-SMP architectures this patch changes no code paths at all.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2019-02-19 16:03:39 -08:00 committed by Anas Nashif
commit 42ed12a387
9 changed files with 123 additions and 11 deletions

View file

@ -102,4 +102,6 @@ extern int x86_64_except_reason;
__asm__ volatile("int $5"); \
} while (false)
void z_arch_sched_ipi(void);
#endif /* _KERNEL_ARCH_FUNC_H */