We have got a test_and_set_bit implementation as follows:
static __inline__ int
test_and_set_bit (int nr, volatile void *addr)
{
__u32 bit, old, new;
volatile __u32 *m;
m = (volatile __u32 *) addr + (nr >> 5);
bit = 1 << (nr & 31);
do {
old = *m;
new = old | bit;
} while (cmpxchg_acq(m, old, new) != old);
return (old & bit) != 0;
}
Let's assume the bit test & set is already set, why is then the
cmpxchg_acq() executed? Cannot we just return, e.g. like this?
do {
old = *m;
if (old & bit)
return 1;
new = old | bit;
} while (cmpxchg_acq(m, old, new) != old);
Thanks,
Zoltán Menyhárt
-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html