Re: [PATCH RFC] 'spinlock/rwlock fixes' V3 [1/1]

From: Linus Torvalds <>
Date: 2005-01-21 02:51:08
On Thu, 20 Jan 2005, Peter Chubb wrote:
> I suggest reversing the sense of the macros, and having read_can_lock()
> and write_can_lock()
> Meaning:
> 	read_can_lock() --- a read_lock() would have succeeded
> 	write_can_lock() --- a write_lock() would have succeeded.

Yes. This has the advantage of being readable, and the "sense" of the test 
always being obvious.

We have a sense problem with the "trylock()" cases - some return "it was
locked" (semaphores), and some return "I succeeded" (spinlocks), so not
only is the sense not immediately obvious from the usage, it's actually
_different_ for semaphores and for spinlocks.

So I like "read_can_lock()", since it's also obvious what it returns.

(And yes, we should fix the semaphore trylock return code, dammit.)

To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to
More majordomo info at
Received on Thu Jan 20 10:57:15 2005

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:34 EST