News for hackers. Stuff that matters.
Re:Measuring mutexes, spinlocks and how bad the Linux schedu... by p0nce on Thursday January 02, 2020 @11:35AM (#21936822)
Interesting! Now I'm interested if there has been one usage case for the single bit spinlock in practice. It seems appropriate if writes aren't too numerous (well leaving aside speed concerns). Or a case where std::mutex was too large?

I've always wondered how the wait list was implemented.

Re:Measuring mutexes, spinlocks and how bad the Linux schedu... by gpderetta on Thursday January 02, 2020 @11:58AM (#21937066)
Think about a concurrent hashtable using chaining for collision resolution; distinct bucket chains can be updated concurrently, so you need a per bucket lock but you do not want a full std::mutex as it would increase the size of the bucket table by a large integer multiple. Instead, borrowing one bit from the chain pointer (you can easily arrange the least significant bit of the pointer to be always zero) is pretty much free.

Note: I wrote the above from the top of my head, I haven't actually had the need to implement a concurrent hashtable yet.