From: mobile.parmenides@gmail.com (Parmenides)
To: kernelnewbies@lists.kernelnewbies.org
Subject: two questions about test_and_clear_bit()
Date: Fri, 6 May 2011 10:01:50 +0800 [thread overview]
Message-ID: <BANLkTinYxJTtT-QzAffvAro9XpNhBLWkEQ@mail.gmail.com> (raw)
Hi,
For the following function, I have two questions:
static inline int test_and_set_bit(int nr, volatile unsigned long * addr)
{
int oldbit;
__asm__ __volatile__( LOCK_PREFIX
"btsl %2,%1\n\tsbbl %0,%0"
:"=r" (oldbit),"+m" (ADDR)
:"Ir" (nr) : "memory");
return oldbit;
}
1. There are two instructions in the inline assemably, namely btsl and
sbbl. But, can the only one LOCK_PREFIX ensure that the operation is
atomic?
2. The clobber list of the inline assembly contains a string of
"memory". What is the meaning of this declaration and why does the
operation need it ? After all, some other operations such as
clear_bit() dose not need "memory" indeed. The declaration of "memory"
appears in source code of kernel here and there, and bothers me for a
long time. So any details about it will be appreciated.
static inline void clear_bit(int nr, volatile unsigned long * addr)
{
__asm__ __volatile__( LOCK_PREFIX
"btrl %1,%0"
:"+m" (ADDR)
:"Ir" (nr));
}
Thanks!
reply other threads:[~2011-05-06 2:01 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=BANLkTinYxJTtT-QzAffvAro9XpNhBLWkEQ@mail.gmail.com \
--to=mobile.parmenides@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).