callwheel entries and sleep queues

Hello,

I'm facing an issue in thread sleep and wake up mechanism. Please answer the query if you've idea on this. I'll explain the current implementation first and then the problem that I'm seeing.

The current implementation is: When a thread issues a timed wait/sleep on on a CV (wchan), the below three steps are taken viz.,
  1. The callout reference of the thread is first added into callwheel bucket corresponding to the timeout required
  2. The thread reference is queued in the respective wchan (wait channel) list and
  3. The thread sleeps
When the timeout happens, the below steps are performed viz.,
  1. The entries in the callwheel bucket for this tick is parsed through and selects the thread waiting to be awakened at this tick and removes from the chain
  2. The thread reference is removed from the wchan and
  3. Put into runqueue.
Now, the problem I'm seeing is: After the thread is put to sleep and when the timeout happened, the thread reference is not present in the callwheel entry, but the reference in the wchan still exists. Due to this, the thread is never woken up.

Have you ever faced such a situation where, the wake up mechanism of a thread is broken in between... especially after removing the reference from callwheel entry and before removing from the wchan entry?

Thanks you for your time.
 
Back
Top