Improve blocking and accuracy
Summary: Blocking algorithm: Push: 1. push 2. increase the PTicket number 3. put (PTicket << 1) to the corresponding place in futex array. 4. if the original futex value & 1 == 1, wake up () Pop: 1. increase the CTicket number 2. spin if the corresponding CTicket futex is not ready 3. set the right bit of the CTicket futex to 1, wait on it. 4. pop Add additional control to improve the accuracy: For the top several levels (top 0 - 3 levels by default), it does not arbitrarily insert any node in the middle of the list. Thus guaranteeing no later coming lower priorities can be insert at the top levels (pruning strategy still valid for the top four levels). For the bottom levels (start from level 7 by default), if insertion requires to hold parent + child locks, it traverses the parent list to check whether the parent list has lower priority nodes than the new node. If the condition holds, insert the new node to the parent and get the last node in the parent list and insert it to the child list. Reviewed By: magedm Differential Revision: D9094903 fbshipit-source-id: fa4d31fb0c21da746570029e0e3b4b3fbeaa2024
Showing
This diff is collapsed.
Please register or sign in to comment