Jamie Lokier wrote:
> That's right. It's possible to use atomic_compare_and_exchange for
> unlock; it's correct. But you get that extra bit of spinning with SMP,
> so atomic_dec is better.
In fact I don't see why Ulrich did the unlock code like this:
if (atomic_dec(val) != 1 ) {
val = 0;
futex_wake(&val, 1);
};
My current implementation is
c = atomic_xchg(val, 0) {
if (c=2) { // we own the lock, so
// val can be either of 1 or 2
futex_wake(&val, 1);
};
It does work fine in my tests on a dual core.
What do you think ?
-Michael
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev