Hacker News new | ask | show | jobs
by tiffanyh 28 days ago
> Replaced the cas spinlock in kernel mutexes with a "parking" lock.

Anyone know what a "parking lock" is (and how it works)?

I couldn't find anything on the man pages about it.

https://man.openbsd.org/OpenBSD-5.5/lock.9

https://man.openbsd.org/OpenBSD-5.9/mutex.9

2 comments

"Parking" lock is a reference to this:

https://webkit.org/blog/6161/locking-in-webkit/

Thanks!

Wow, this is from 10-years ago.

It's a lock/mutex implementation that puts the blocked thread to sleep, usually via cooperative yielding to the scheduler instead of continuing to perform CAS operations on the lock continuously. Spinlocks have great performance when they're not heavily contended and the locks are held for short periods of time, but if either of those things are true the blocked thread can easily consume an entire CPU core while it's blocked.