3 ms·
> the lock was being acquired and released ~49,000 times and was held for, on average, less than one ms at a time. But for some reason, even though the lock was
by snaky 8y ago
> the lock was being acquired and released ~49,000 times and was held for, on average, less than one ms at a time. But for some reason, even though the lock was released 49,000 times the Chrome process was never able to acquire it.
Well, locking is hard.
> The good news is that even though there is occasional unfairness, there is unlikely to be persistent unfairness. In order for a thread to steal the lock, it needs to hit the tiny window where the lock is available. In practice, a thread is unlikely to be this lucky repeatedly.
https://blogs.msdn.microsoft.com/oldnewthing/20170705-00/?p=96535 https://blogs.msdn.microsoft.com/oldnewthing/20170705-00/?p=...
> The fact is, any time anybody makes up a new locking mechanism, THEY ALWAYS GET IT WRONG. Don't do it. Take heed. You got it wrong. Admit it. Locking is _hard_.
https://yarchive.net/comp/linux/locking.html https://yarchive.net/comp/linux/locking.html
- AstralStorm 8y agoActually this is exactly because someone in Windows used the plain old mutex. I'd call that "your granddad's lock". It's old, crotchety, unfair and shouldn't be used in situations where any concurrency can be expected. This despite the kernel having a nice RCU mechanism inside as well as waitfree queues.
- snaky 8y agoIf there was a spinlock, the problem stay. > the rule simply is that you MUST NOT release and immediately re-acquire the same spinlock on the same core, because as far as other cores are concerned, that's basically the same as never releasing it in the first place. https://yarchive.net/comp/linux/spinlocks.html https://yarchive.net/comp/linux/spinlocks.html Other mechanisms do exist of course.
- geezerjay 8y ago> I'd call that "your granddad's lock". It's old, crotchety, unfair and shouldn't be used in situations where any concurrency can be expected. What alternatives do you suggest?
- gpderetta 8y agoI guess: s/concurrency/contention/