Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Compiler or...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 13 of 15 Topic 9538 of 9823
Post > Topic >>

Re: Compiler ordering barriers in C++0x

by Dmitriy Vyukov <dvyukov@[EMAIL PROTECTED] > May 5, 2008 at 07:08 AM

On 5 май, 03:15, "Chris Thomasson" <cris...@[EMAIL PROTECTED]
> wrote:
> [this is in response to msg #13688, which has not been processed yet...
I
> made a mistake, here is correction...]
>
>
>
> > "Dmitriy V'jukov" <dvyu...@[EMAIL PROTECTED]
> wrote in message
>
>news:c5199756-8669-419e-84e9-1de582eff02e@[EMAIL PROTECTED]
> > [...]
> >> I can prove that I have happens-before relation if I can enforce
> >> correct compiler ordering. Consider following code:
>
> >> std::vector<int> g_nonatomic_user_data;
> >> std::atomic_int g_atomic1;
> >> std::atomic_int g_atomic2;
>
> >> std::vector<int> thread()
> >> {
> >> g_atomic1.store(1, std::memory_order_relaxed);
> >> // compiler store-load fence
> >> if (g_atomic2.load(std::memory_order_relaxed))
> > [...]
>
> > Are you sure that atomic store with 'memory_order_relaxed' semantics
> > injects
> > a #StoreLoad after the operation?
>
> Whoops! I did not read the word COMPILER! Sorry about that. Anyway, I
think
> that
> 'g_atomic2.load()' can rise above 'g_atomic1.store()'...

.... if you don't use system_wide_synchronize() on "the other side" ;)
It's a sketch of reader-side of asymmetric reader-writer mutex.

Dmitriy V'jukov


-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 15 Posts in Topic:
Compiler ordering barriers in C++0x
Dmitriy Vyukov <dvyuko  2008-04-24 01:04:20 
Re: Compiler ordering barriers in C++0x
nickf3 <nickf3@[EMAIL   2008-04-28 01:59:21 
Re: Compiler ordering barriers in C++0x
Anthony Williams <anth  2008-05-02 04:43:58 
Re: Compiler ordering barriers in C++0x
Szabolcs Ferenczi <sza  2008-05-02 12:48:39 
Re: Compiler ordering barriers in C++0x
Anthony Williams <anth  2008-05-03 06:13:29 
Re: Compiler ordering barriers in C++0x
"Dmitriy V'jukov&quo  2008-05-03 06:13:29 
Re: Compiler ordering barriers in C++0x
Anthony Williams <anth  2008-05-03 16:12:38 
Re: Compiler ordering barriers in C++0x
"Chris Thomasson&quo  2008-05-04 17:15:28 
Re: Compiler ordering barriers in C++0x
"Chris Thomasson&quo  2008-05-04 17:15:07 
Re: Compiler ordering barriers in C++0x
Szabolcs Ferenczi <sza  2008-05-04 17:17:14 
Re: Compiler ordering barriers in C++0x
"Chris Thomasson&quo  2008-05-05 07:09:38 
Re: Compiler ordering barriers in C++0x
Anthony Williams <anth  2008-05-05 07:08:05 
Re: Compiler ordering barriers in C++0x
Dmitriy Vyukov <dvyuko  2008-05-05 07:08:12 
Re: Compiler ordering barriers in C++0x
James Kanze <james.kan  2008-05-05 08:32:47 
Re: Compiler ordering barriers in C++0x
Szabolcs Ferenczi <sza  2008-05-05 12:35:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 1:47:06 CDT 2008.