zephyr/kernel
Andy Ross 7fb8eb57e8 kernel/sched: SWAP_NONATOMIC workaround for timeslicing
Timeslicing works by removing the _current thread from the run queue
and re-adding it at the end of its priority.  On systems with a
_Swap() that can be preempted by a timer interrupt, that means it's
possible for the timeslice to try to slice out a thread that had
already pended itself!

This behavior used to be benign (or at least undetectable) as the
duplicated list operations were idempotent.  But now the dlist code is
stricter about correctness and has exposed the bug -- it will blow up
if you try to remove an already-removed list node.

Fix (on affected platforms) by stashing the _current pointer in
_pend_current_thread() that is checked and cleared in the timer
interrupt.  If we discover we're trying to interrupt a thread that's
already interrupted itself, we can safely exit z_time_slice() as a
noop.  The timeslicing bookeeping was already done for us underneath
the pend code.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2019-01-15 13:06:35 +01:00
..
include kernel/swap: Simply/robustify return value handling 2019-01-11 15:18:52 -05:00
alert.c
atomic_c.c
CMakeLists.txt
compiler_stack_protect.c
device.c
errno.c
idle.c power: rename api sys_soc -> sys_ 2018-12-28 16:16:28 -05:00
init.c kernel: init: Add nop instruction in main 2018-12-14 13:17:36 +01:00
int_latency_bench.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
Kconfig kernel: Add CONFIG_SWAP_NONATOMIC flag 2019-01-15 13:06:35 +01:00
Kconfig.power_mgmt
mailbox.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
mem_domain.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
mem_slab.c
mempool.c
msg_q.c kernel: Add missing include 2019-01-11 15:18:52 -05:00
mutex.c
pipes.c kernel: Add missing include 2019-01-11 15:18:52 -05:00
poll.c kernel: Fix asynchronous event polling interface 2019-01-09 17:06:08 -05:00
queue.c kernel: Add missing include 2019-01-11 15:18:52 -05:00
sched.c kernel/sched: SWAP_NONATOMIC workaround for timeslicing 2019-01-15 13:06:35 +01:00
sem.c
smp.c
stack.c kernel: Add missing include 2019-01-11 15:18:52 -05:00
system_work_q.c
thread_abort.c
thread.c kernel: Change k_is_in_isr to return bool 2019-01-07 08:52:07 -05:00
timeout.c kernel/timeout: Don't reset imminent timeouts 2019-01-03 12:29:02 -05:00
timer.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
userspace_handler.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
userspace.c kernel: Make statements evaluate boolean expressions 2019-01-07 08:52:07 -05:00
version.c doc: add kernel version API to doxygen 2018-12-08 17:24:53 -05:00
work_q.c kernel: Use NULL instead of 0 2018-12-11 14:37:10 -08:00