From: "Brian J. Watson" <Brian.J.Watson@compaq.com>
To: David Howells <dhowells@redhat.com>
Cc: marcelo@conectiva.com.br, linux-kernel@vger.kernel.org, hch@caldera.de
Subject: Re: [PATCH] 2.4.18-pre9, trylock for read/write semaphores
Date: Wed, 13 Feb 2002 16:13:37 -0800 [thread overview]
Message-ID: <3C6B0131.F096F020@compaq.com> (raw)
In-Reply-To: <26130.1013588383@warthog.cambridge.redhat.com>
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.
Brian
next prev parent reply other threads:[~2002-02-14 0:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-12 22:45 [PATCH] 2.4.18-pre9, trylock for read/write semaphores bwatson
2002-02-12 23:29 ` Alan Cox
2002-02-13 1:47 ` Brian J. Watson
2002-02-13 7:47 ` David Howells
2002-02-13 8:19 ` David Howells
2002-02-14 0:13 ` Brian J. Watson [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-02-21 18:04 Kendrick M. Smith
2002-02-21 21:54 ` Brian J. Watson
2002-02-21 23:02 ` Kendrick M. Smith
2002-02-21 23:26 ` Brian J. Watson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3C6B0131.F096F020@compaq.com \
--to=brian.j.watson@compaq.com \
--cc=dhowells@redhat.com \
--cc=hch@caldera.de \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.