This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimization of conditional access to globals: thread-unsafe?


On Mon, Oct 29, 2007 at 10:43:13 +0300, Tomash Brechko wrote:
> I think most pro-volatile people didn't understood the meaning of
> several papers in the Internet that say you have to use volatile.

And some don't understand the true purposes of volatile itself.  In
the code below


  volatile int *v = (int *) 0xdeadbeef;

  void
  f()
  {
    int i;
    for (i = 0; i < N; ++i)
      *v = 1;
  }


_all_ N stores matter.  Why?  Because v may point to the device I/O
port, and the device may _count_ those writes among other things.

But if *v is simply shared, do all stores to it matter?  No, only the
final value is relevant.

That's why -fno-speculative-store will never be equal to volatile, and
that's why it is needed to replace current volatile hammer.


-- 
   Tomash Brechko


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]