[lkml]   [2002]   [Feb]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] 2.4.18-pre9, trylock for read/write semaphores
David Howells wrote:
> I think the following would be more elegant:
> [snip]

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.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:24    [W:0.041 / U:1.580 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site