issue #156: fix several more races
* Don't need to sleep if queue>sleepers, can just pop the right queue element and return it. * If queue>sleeping and waking==sleeping, no mechanism existed to ensure a thread newly added to sleeping would ever be woken. Above change fixes that. * Cannot trust select() return value, scheduler might sleep us indefinitely while put() writes a byte. * Sleeping threads didn't pop FIFO, they popped in whatever order scheduler woke them up. Must recover index and use it to pick the pop index.
Showing
Please register or sign in to comment