This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Question on volatile functions and GCC
On 5 March 2013 09:40, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On 5 March 2013 09:27, David Paterson wrote:
>>
>> In addition to Jonathan's answer on the use of "volatile", it's worth adding
>> that it's not only used for memory mapped hardware. There are many other
>> uses, such as inter-thread communication, or indeed the example you
>> show below.
>
> Only in broken code.
LOL - well, it depends on your definition of "broken"...
> 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.
Regards,
David P.