Re: Question on volatile functions and GCC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 5, 2013 at 1:58 AM, David Paterson <dnpaterson@xxxxxxxxx> wrote:
> On 5 March 2013 09:40, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
>
>> volatile is not for multithreading, you need proper synchronization
>> for interthread communication.
>
> Not always.  For very simple, non-critical uses you can just use a
> volatile flag-type variable.  Cheap and nasty, I agree, but useable.

If your code has a race condition before you add a volatile qualifier,
it will still have a race condition after you add the qualifier.

If you want a simple flag variable, don't use volatile; use
__atomic_load and __atomic_store.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux