• lost-wakeup

  • consider two processes A and B:

      1. A checks condition
      1. B satisfies condition, wakes up A
      1. A goes to sleep (because it already checked the condition before)
  • and so is a form of TOCTOU

  • a way to solve it is

    • set a "wakeup waiting" bit which tracks the time a process is in the state between 2 and 3

      • when a wakeup is sent to a process, set this bit

      • when a process tries to sleep, if the bit is set, clear it and do not go to sleep

      • consumer process clears this bit on every loop iteration (i.e., when done processing an event)

    • however, the waking process needs to know which process is going to be woken up when setting the bit

    • additionally, a wakeup waiting bit (WW bit) intended for an earlier wait can prevent a later sleep

        1. A is waiting for event 1 on channel chan; sleeps because event is not there yet
        1. B wakes up A, A's WW bit is set
        1. A handles event 1, clears A's WW bit
        1. A is now waiting for event 2 on channel chan; sleeps because event is not there yet (and A's WW bit is not set)
  • refs

Snapshot: 46e0f23e024e359a37813988dca59f4400591c4b5c8cd9c10cd19faa77ff4f7c504e48634463ceda882f05a3f0214dbebe1f866ecee13614599b9cdf41576272 list?snapshot=46e0f23e024e359a37813988dca59f4400591c4b5c8cd9c10cd19faa77ff4f7c504e48634463ceda882f05a3f0214dbebe1f866ecee13614599b9cdf41576272