Compiler ordering barriers in C++0x
  Home FAQ Contact Sign in
comp.lang.c++.moderated only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.c++.moderated Profile…
 Up
Re: Compiler ordering barriers in C++0x         


Author: Chris Thomasson
Date: May 5, 2008 05:49

"Szabolcs Ferenczi" gmail.com> wrote in message
news:e97bdaf4-5f8a-40bd-b058-46b30b1eb01a@x35g2000hsb.googlegroups.com...
> On May 3, 2:13 pm, Anthony Williams yahoo.com> wrote:
>> Szabolcs Ferenczi gmail.com> writes:
>>> On May 2, 12:43 pm, Anthony Williams yahoo.com> wrote:
>>>> [...]
>>>> All accesses to shared data MUST be synchronized with atomics: [...]
>>
>>> Can you elaborate this point please. How can you generally synchronise
>>> N processes with help of atomics? Do you mean only two processes under
>>> certain circumstances?
>>
>> If any thread modifies shared data that is not of type atomic_xxx, the
>> developer must ensure appropriate synchronization with any other thread
>> that
>> accesses that shared data in order to avoid a data race (and the
>> undefined
>> behaviour that comes with that).
>
> It is clear that you must synchronise access to shared variable. ...
Show full article (3.14Kb)
no comments
Re: Compiler ordering barriers in C++0x         


Author: Anthony Williams
Date: May 5, 2008 05:49

Szabolcs Ferenczi gmail.com> writes:
> On May 3, 2:13 pm, Anthony Williams yahoo.com> wrote:
>> Szabolcs Ferenczi gmail.com> writes:
>>> On May 2, 12:43 pm, Anthony Williams yahoo.com> wrote...
Show full article (3.39Kb)
no comments
Re: Compiler ordering barriers in C++0x         


Author: Dmitriy Vyukov
Date: May 5, 2008 05:49

On 5 п╪п╟п╧, 03:15, "Chris Thomasson" comcast.net> wrote:
> [this is in response to msg #13688, which has not been processed yet... I
> made a mistake, here is correction...]
>
>
>
>> "Dmitriy V'jukov" gmail.com> wrote in message
>>news:c5199756-8669-419e-84e9-1de582eff02e@y38g2000hsy.googlegroups.com...
>> [...]
>>> I can prove that I have happens-before relation if I can enforce
>>> correct compiler ordering. Consider following code:
>
>>> std::vector g_nonatomic_user_data;
>>> std::atomic_int g_atomic1;
>>> std::atomic_int g_atomic2;
>
>>> std::vector thread()
>>> {
>>> g_atomic1.store(1, std::memory_order_relaxed);
>>> // compiler store-load fence ...
Show full article (1.34Kb)
no comments
Re: Compiler ordering barriers in C++0x         


Author: James Kanze
Date: May 5, 2008 06:58

On May 5, 3:09 pm, "Chris Thomasson" comcast.net> wrote:
> "Szabolcs Ferenczi" gmail.com> wrote in message
> news:e97bdaf4-5f8a-40bd-b058-46b30b1eb01a@x35g2000hsb.googlegroups.com...
>> On May 3, 2:13 pm, Anthony Williams yahoo.com> wrote:
>>> Szabolcs Ferenczi gmail.com> writes:
>>>> On May 2, 12:43 pm, Anthony Williams yahoo.com> wrote:
>>>>> [...]
>>>>> All accesses to shared data MUST be synchronized with atomics: [...]
>>>> Can you elaborate this point please. How can you
>>>> generally synchronise N processes with help of atomics?
>>>> Do you mean only two processes under certain
>>>> circumstances?
>>> If any thread modifies shared data that is not of type
>>> atomic_xxx, the developer must ensure appropriate
>>> synchronization with any other thread that accesses that
>>> shared data in order to avoid a data race (and the
>>> undefined behaviour that comes with that).
>> It is clear that you must synchronise access to shared
>> variable. Normally you must use a Critical Region for that.
Show full article (2.42Kb)
no comments
Re: Compiler ordering barriers in C++0x         


Author: Szabolcs Ferenczi
Date: May 5, 2008 10:40

On May 5, 3:08 pm, Anthony Williams yahoo.com> wrote:
> Szabolcs Ferenczi gmail.com> writes:
>> On May 3, 2:13 pm, Anthony Williams yahoo.com> wrote:
>>> Szabolcs Ferenczi gmail.com> writes:
>>>> On May 2, 12:43 pm, Anthony Williams yahoo.com> wrote:
>>>>> [...]
>>>>> All accesses to shared data MUST be synchronized with atomics: [...]
>
>>>> Can you elaborate this point please. How can you generally synchronise
>>>> N processes with help of atomics? Do you mean only two processes under
>>>> certain circumstances?
>
>>> If any thread modifies shared data that is not of type atomic_xxx, the
>>> developer must ensure appropriate synchronization with any other thread that
>>> accesses that shared data in order to avoid a data race (and the undefined
>>> behaviour that comes with that).
>
>> It is clear that you must synchronise access to shared variable.
>> Normally you must use a Critical Region for that.
> ...
Show full article (4.56Kb)
no comments
 
1 2