Skip to content
Snippets Groups Projects
  • Ludwig Knüpfer's avatar
    9d4a9200
    core/hwtimer: disable interrupts in hwtimer_remove · 9d4a9200
    Ludwig Knüpfer authored
    Before only the hardware timer's own interrupt was being disabled.
    This led to a race condition in the following scenario:
    
    ```
    Thread1:
        hwtimer_remove()
        hwtimer_arch_disable_interrupt();
    
    // INTERRUPT -> Thread2 (which has a higher priority than Thread1) gets scheduled
    
    Thread2:
        ...
        hwtimer_remove()
        hwtimer_arch_disable_interrupt(); // hwtimer interrupt is already disabled
        ...
        hwtimer_arch_enable_interrupt();
        ...
       // yield | terminate -> Thread1 gets scheduled again
    
    Thread1:
        ... // these instructions are being run with the hwtimer interrupt enabled
        hwtimer_arch_enable_interrupt(); // hwtimer interrupt is already enabled
    ```
    
    Fixes #924
    9d4a9200
    History
    core/hwtimer: disable interrupts in hwtimer_remove
    Ludwig Knüpfer authored
    Before only the hardware timer's own interrupt was being disabled.
    This led to a race condition in the following scenario:
    
    ```
    Thread1:
        hwtimer_remove()
        hwtimer_arch_disable_interrupt();
    
    // INTERRUPT -> Thread2 (which has a higher priority than Thread1) gets scheduled
    
    Thread2:
        ...
        hwtimer_remove()
        hwtimer_arch_disable_interrupt(); // hwtimer interrupt is already disabled
        ...
        hwtimer_arch_enable_interrupt();
        ...
       // yield | terminate -> Thread1 gets scheduled again
    
    Thread1:
        ... // these instructions are being run with the hwtimer interrupt enabled
        hwtimer_arch_enable_interrupt(); // hwtimer interrupt is already enabled
    ```
    
    Fixes #924