public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Joseph Seigh" <jseigh_02@xemaps.com>
To: linux-kernel@vger.kernel.org
Subject: Re: What does atomic_read actually do?
Date: Sun, 19 Dec 2004 18:50:54 -0500	[thread overview]
Message-ID: <opsi94i4z0s29e3l@grunion> (raw)
In-Reply-To: 1103494866.6052.354.camel@localhost

On Sun, 19 Dec 2004 17:21:06 -0500, Robert Love <rml@novell.com> wrote:

> On Sat, 2004-12-18 at 15:43 -0500, Joseph Seigh wrote:
>
>> > it does so on *x86
>>
>> Is this documented for gcc anywhere?  Just because it does so doesn't
>> mean it's guaranteed.
>
> Listen to what Arjan is saying: It is not a compiler feature.  x86
> already guarantees that an aligned word-size read is atomic in the
> nothing-can-interleave sense.
>
I'm aware of that.  I'm not asking a question about x86 architecture.  I'm
asking what guarantees that the compiler will load the int using one MOV
instruction since there's nothing in the C standard that requires that,  
even
for volatile.   I think it's unlikely the compiler would use multiple loads
a byte at a time but it really requires a compiler person to  
authoritatively
make that statement.

It's a big problem getting support for threaded programming in C since the
C standard doesn't acknowlege threads.  For Posix threads, Posix had to  
come
up with a separate compliance certification for C compilers.  So when you  
use
posix pthreads, you have to use a posix compliant compiler to ensure your
program will work correctly.

It's the same issue here.  The atomic functions are another thread api.   
What's
the assurance that gcc supports this api correctly?   There was the  
possibility
since the C standard leaves it implementation dependent what constitutes
volatile access, that gcc did something special there.  But the gcc  
documentation
says this for volatile, "There is no guarantee that these reads and writes  
are atomic,
especially for objects larger than int."

http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Volatiles.html#Volatiles

Joe Seigh


  reply	other threads:[~2004-12-19 23:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-18 16:23 What does atomic_read actually do? Joseph Seigh
2004-12-18 17:11 ` Paolo Ornati
2004-12-18 18:14   ` Joseph Seigh
2004-12-18 18:34 ` Arjan van de Ven
2004-12-18 19:20   ` Joseph Seigh
2004-12-18 19:39     ` Joe Korty
2004-12-18 19:54     ` Arjan van de Ven
2004-12-18 20:43       ` Joseph Seigh
2004-12-18 21:03         ` Brian Gerst
2004-12-19 22:21         ` Robert Love
2004-12-19 23:50           ` Joseph Seigh [this message]
2004-12-20 11:51             ` Arjan van de Ven
2004-12-20 12:52             ` Andrea Arcangeli
2004-12-20 20:51               ` Joseph Seigh
2004-12-18 20:47 ` Brian Gerst

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=opsi94i4z0s29e3l@grunion \
    --to=jseigh_02@xemaps.com \
    --cc=linux-kernel@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