Skip to content
Snippets Groups Projects
  • Kaspar Schleiser's avatar
    62bb4cc5
    cpu/native: fix race condition in thread_yield_higher() · 62bb4cc5
    Kaspar Schleiser authored
    Error case:
    1. thread_yield_higher() stores the thread's ucontext
    2. creates an "isr ucontext" for isr_thread_yield, switches to it
    
    Case 1: no signals are pending, continues in isr_thread_yield()
    3a. sched_run is called
    4a. return to sched_active_thread ucontext
    
    Case 2: signals pending (the crashing scenario), continues in native_irq_handler()
    3b. handles signals
    4b. if sched_context_switch_request is set, call sched_run
    5b. return to sched_active_thread ucontext
    
    4b misses the call to sched_run(), leading to a possible return into a
    non-ready thread.
    62bb4cc5
    History
    cpu/native: fix race condition in thread_yield_higher()
    Kaspar Schleiser authored
    Error case:
    1. thread_yield_higher() stores the thread's ucontext
    2. creates an "isr ucontext" for isr_thread_yield, switches to it
    
    Case 1: no signals are pending, continues in isr_thread_yield()
    3a. sched_run is called
    4a. return to sched_active_thread ucontext
    
    Case 2: signals pending (the crashing scenario), continues in native_irq_handler()
    3b. handles signals
    4b. if sched_context_switch_request is set, call sched_run
    5b. return to sched_active_thread ucontext
    
    4b misses the call to sched_run(), leading to a possible return into a
    non-ready thread.