public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: Zoltan Menyhart <Zoltan.Menyhart@bull.net>
To: linux-ia64@vger.kernel.org
Subject: atomic_ops.txt vs. test_and_set_bit()
Date: Mon, 27 Mar 2006 12:56:22 +0000	[thread overview]
Message-ID: <4427E0F6.20308@bull.net> (raw)

I had a look at the atomic_ops.txt:

"      int test_and_set_bit(unsigned long nr, volatils unsigned long *addr);
       int test_and_clear_bit(unsigned long nr, volatils unsigned long *addr);
       int test_and_change_bit(unsigned long nr, volatils unsigned long *addr);
[...]

These routines, like the atomic_t counter operations returning values,
require explicit memory barrier semantics around their execution.  All
memory operations before the atomic bit operation call must be made
visible globally before the atomic bit operation is made visible.
Likewise, the atomic bit operation must be visible globally before any
subsequent memory operation is made visible.  For example:

       obj->dead = 1;
       if (test_and_set_bit(0, &obj->flags))
               /* ... */;
       obj->killed = 1;

The implementation of test_and_set_bit() must guarentee that
"obj->dead = 1;" is visible to cpus before the atomic memory operation
done by test_and_set_bit() becomes visible.  Likewise, the atomic
memory operation done by test_and_set_bit() must become visible before
"obj->killed = 1;" is visible."

The implementation of "test_and_set_bit()" does not meet this
requirement. It's a bad news.
If the description in atomic_ops.txt were not quite up to date... :-)

Regards,

Zoltan 

                 reply	other threads:[~2006-03-27 12:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4427E0F6.20308@bull.net \
    --to=zoltan.menyhart@bull.net \
    --cc=linux-ia64@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox