Re: rwlocks revisited

From: Benjamin C.R. LaHaise (blah@kvack.org)
Date: Fri Jan 21 2000 - 22:01:39 EST


On Thu, 20 Jan 2000, David Howells wrote:

> I've just come across an i386 instruction I didn't realise existed (it's not
> in my i386 assembly book), and while I hesitate to reopen the old rwlock
> debate, I think its worth mentioning.
>
> This instruction (or perhaps I should say intruction family) is
> "cmpxchg*". I've known about a similar one on the m68k ("cas" & "cas2") for a
> while. I was wondering why the writelock code was done using "subl" rather
> than "cmpxchgl":

The reasons are as follows: I chose subl because it sets the condition
codes in such a way as to determine which of 3 states the lock was in
(unlocked, locked for reading but uncontended for writing and contended
for writing), which is used to decide which action to take for rwsems. In
addition, subl is faster than cmpxchgl for the typically uncontended case.

                -ben

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jan 23 2000 - 21:00:26 EST