rwlocks revisited

From: David Howells (David.Howells@nexor.co.uk)
Date: Thu Jan 20 2000 - 09:12:43 EST


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@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:22 EST