rwlocks revisited

Benjamin C.R. LaHaise blah en kvack.org
Sab Ene 22 14:45:35 CST 2000


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 en vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



Más información sobre la lista de distribución Ayuda