The use of spinlocks is avoided in the combination of mutex and condition
variables by using any suitable atomic compare and swap functionality to
add a thread to a list of waiting threads that waits for a data event to
occur. Various embodiments of the present invention also provide an
organization scheme of data, which describes an access bit, an awaken
count, and a pointer to the list of waiting threads. This organization
scheme of data helps to optimize the list of waiting threads so as to
better awaken a waiting thread or all waiting threads at once.