Replies: 3 comments
-
In some cases The logic to decide when to spin and when to use the futex is quite complicated. The main idea is to use the futex as the slow blocking path, but also to try to avoid entering the kernel when a wakeup is unnecessary. |
Beta Was this translation helpful? Give feedback.
0 replies
-
You are right, I missed this. It's buried quite a few level deep and I missed it. |
Beta Was this translation helpful? Give feedback.
0 replies
This comment was marked as spam.
This comment was marked as spam.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was checking abseil's mutex implementation. When it takes too long to acquire a mutex, abseil calls sleep . Because the thread has no idea how long it'll have to wait, it has to wake up regularly, and is going to oversleep by roughly half the time it sleeps on average.
Would it be preferable to use system primitives such as futexes? This is perplexing to me, because the spinlock uses futexes so it's not like it is not available or something.
Does any one know the reason why the lock/mutex are designed in this way?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions