mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-02 03:35:19 +00:00
It's possible for a thread to abort itself simultaneously with an external abort from another thread. In fact in our test suite this is a common thing, as ztest will abort its own spawend threads at the end of a test, as they tend to be exiting on their own. When that happens, the thread marks itself DEAD and does all its scheduler bookeeping, but it is STILL RUNNING on its own stack until it makes its way to its final swap. The external context would see that "dead" metadata and return from k_thread_abort(), allowing the next test to reuse and spawn the same thread struct while the old context was still running. Obviously that's bad. Unfortunately, this is impossible to address completely without modifying every SMP architecture to add a API-visible hook to every swap that signals completion. In practice the best we can do is add a delay. But note the optimization: almost always, the scheduler IPI catches the running thread and kills it from interrupt context (i.e. on a different stack). When that happens, we know that the interrupted thread will never be resumed (because it's dead) and can elide the delay. We only pay the cost when we actually detect a race. Signed-off-by: Andy Ross <andrew.j.ross@intel.com> |
||
---|---|---|
.. | ||
app_memory | ||
arch | ||
audio | ||
bluetooth | ||
canbus | ||
cmsis_rtos_v1 | ||
cmsis_rtos_v2 | ||
console | ||
crypto | ||
data | ||
debug | ||
dfu | ||
disk | ||
display | ||
drivers | ||
dt-bindings | ||
fs | ||
linker | ||
logging | ||
mgmt | ||
net | ||
posix | ||
power | ||
random | ||
settings | ||
shell | ||
stats | ||
storage | ||
sys | ||
toolchain | ||
usb | ||
zephyr | ||
cache.h | ||
device.h | ||
devicetree.h | ||
exc_handle.h | ||
fatal.h | ||
generated_dts_board.h | ||
init.h | ||
irq_nextlevel.h | ||
irq_offload.h | ||
irq.h | ||
kernel_includes.h | ||
kernel_structs.h | ||
kernel_version.h | ||
kernel.h | ||
ptp_clock.h | ||
sched_priq.h | ||
shared_irq.h | ||
spinlock.h | ||
sw_isr_table.h | ||
sys_clock.h | ||
syscall_handler.h | ||
syscall.h | ||
timeout_q.h | ||
toolchain.h | ||
wait_q.h | ||
zephyr.h |