3 ms·
One valid scenario for mutexes timing out is stealing: 1. Each CPU first attempts to take an allocated object from its own pool, using a 1ms timeout to acquire
by zamalek 7y ago
One valid scenario for mutexes timing out is stealing:
1. Each CPU first attempts to take an allocated object from its own pool, using a 1ms timeout to acquire the mutex on the pool.
2. If that fails, the CPU attempts to steal from the other CPU pools, using a zero timeout (immediately return if the mutex can't be taken).
3. If that fails, acquire the mutex on its own pool with an infinite timeout.
This is definitely correct and is much faster than any of the lock-free approaches I could come up with. I guess the general class of problems where mutex timeouts help is when you have "many valid options, some of which are being used by others."
- swiley 7y agoThat totally makes sense, thanks for correcting me. :)