RE: [Linux-ia64] spin_unlock() problem

Van Maren, Kevin
2003-04-04T14:49:09Z

Bleh. I should have _looked at_ the code:

=
Consider the following example:

cpu1()
{
spin_lock(&bleh);
*a = foo;
*b = bar;
spin_unlock(&bleh);
}

cpu2()
{
if (*b = bar)
boink(*a);
}

=
No, this will not work: if you need it to work, you need to add a wmb
between the store to a and the store to b -- because cpu2 is NOT
acquiring "bleh", so it CAN see the writes out of order. If you
were using "bleh" "properly" (ie, always acquiring it to access a/b)
then yes, it should work because the lock/unlock enforce memory
consistency.

Kevin