LWN.net Logo

Documenting and enforcing locking requirements

Documenting and enforcing locking requirements

Posted Jul 20, 2002 14:53 UTC (Sat) by corbet (editor, #1)
In reply to: Documenting and enforcing locking requirements by Lorenzo
Parent article: Documenting and enforcing locking requirements

I hate to say it, but your author is not entirely clueless.

In this case, there are many kernel functions that expect to be called with specific locks already held. Yes, the lock is protecting data (or hardware resources, etc.), but the function needs to have access to said data. If a function tries to take out a lock that the thread already holds, it will spin for, shall we say, a very long time. There could also be a problem with lock ordering requirements.

Thus, "locks held" is part of the interface to a Linux kernel function whether you like it or not.


(Log in to post comments)

Documenting and enforcing locking requirements

Posted Jul 21, 2002 23:40 UTC (Sun) by Lorenzo (guest, #260) [Link]

Good programming practice also suggests that you should never leave a function while holding a lock. ... but, you do what you have to do.

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