LWN.net Logo

The Big Kernel Lock lives on

The Big Kernel Lock lives on

Posted May 27, 2004 17:54 UTC (Thu) by stuart2048 (subscriber, #6241)
Parent article: The Big Kernel Lock lives on

OK, so the BKL is a big ugly spin lock (or small and simple, depending on your perspective ;-). What about the thousands of smaller grained locks in the kernel (thousands -- really???). I'm curious how they are implemented.


(Log in to post comments)

The Big Kernel Lock lives on

Posted May 28, 2004 0:13 UTC (Fri) by giraffedata (subscriber, #1954) [Link]

They're the same kind of spin lock. But because they're small, and consequently not ugly, they are preferable. Small just means only a few things use each one.

There's no reason that one CPU shouldn't access a proc file while another CPU accesses a sound card. But today that can't happen because they both use the BKL. The proc file access uses it to serialize proc file accesses and the sound card uses it to serialize sound card accesses, and as a byproduct they also mutually exclude each other.

The only reason they both use the BKL is programmer laziness. If we find the energy, we can make one lock for proc files and another for sound cards and remove the ugliness. (Actually, I'm sure we would go much finer grained than that).

I guess I should admit that the BKL isn't really the same as the fine-grained locks because of the BKL's unique property that it gets automatically released across sleeps. It would be even uglier if it didn't do that.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds