Skip to content
Snippets Groups Projects
  • Tomasz Grabiec's avatar
    bd179712
    core: introduce serial_timer_task · bd179712
    Tomasz Grabiec authored
    This is a wrapper of timer_task which should be used if atomicity of
    callback tasks and timer operations is required. The class accepts
    external lock to serialize all operations. It provides sufficient
    abstraction to replace callouts in the network stack.
    
    Unfortunately, it requires some cooperation from the callback code
    (see try_fire()). That's because I couldn't extract in_pcb lock
    acquisition out of the callback code in TCP stack because there are
    other locks taken before it and doing so _could_ result in lock order
    inversion problems and hence deadlocks. If we can prove these to be
    safe then the API could be simplified.
    
    It may be also worthwhile to propagate the lock passed to
    serial_timer_task down to timer_task to save extra CAS.
    bd179712
    History
    core: introduce serial_timer_task
    Tomasz Grabiec authored
    This is a wrapper of timer_task which should be used if atomicity of
    callback tasks and timer operations is required. The class accepts
    external lock to serialize all operations. It provides sufficient
    abstraction to replace callouts in the network stack.
    
    Unfortunately, it requires some cooperation from the callback code
    (see try_fire()). That's because I couldn't extract in_pcb lock
    acquisition out of the callback code in TCP stack because there are
    other locks taken before it and doing so _could_ result in lock order
    inversion problems and hence deadlocks. If we can prove these to be
    safe then the API could be simplified.
    
    It may be also worthwhile to propagate the lock passed to
    serial_timer_task down to timer_task to save extra CAS.