I agree.
> I'm also not sure that the cast has any effect in the following excerpt from
> the above:
>
> old = (volatile signed long)sem->count;
>
You're right. I looked at the generated assembly, and the volatile cast
makes no difference.
> What you may actually want is:
> [snip]
Although you're right that a volatile pointer is the proper way to do
it, it turns out that a volatile declaration isn't necessary at all. The
cmpxchg() function is a memory barrier that forces the count to be
refetched the next time through the loop.
> Using this inline assembly has three advantages over mixing lots of C into it:
> [snip]
I'm not much of an assembly programmer, so implementing it this way
never crossed my mind. It looks much more efficient than the code
generated from the C version. A drawback is that it is not as easy to
port to other architectures, particularly those that already have a
cmpxchg() function.
It's up to you whether you prefer C or assembly. Let me know, and I'll
test that version and regenerate the patch.
Brian
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/