rwlocks revisited

David Howells David.Howells en nexor.co.uk
Vie Ene 21 02:08:44 CST 2000


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":

> #define RW_LOCK_BIAS_STR	"0x01000000"
>...
> #define __build_write_lock_ptr(rw, helper) \
>	asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
>		     "jnz 2f\n" \

I'm sure that this'd be a lot easier if it used "cmpxchgl", as it would not
have to depend on RW_LOCK_BIAS_STR being a compromise, and no change would be
made to the lock variable if no write lock was actually obtained.

David Howells

-
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