logoalt Hacker News

tiffanyhyesterday at 2:13 PM2 repliesview on HN

> 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


Replies

sanxiynyesterday at 2:18 PM

"Parking" lock is a reference to this:

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

show 1 reply
packetlostyesterday at 2:42 PM

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.