Re: Question on volatile functions and GCC

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

 



On 05/03/13 10:58, David Paterson wrote:
> On 5 March 2013 09:40, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> 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.

"volatile" is often part of the synchronisation, but it is seldom
sufficient on its own.  So it is "used in inter-thread communication" in
a sense.

> 
> Not always.  For very simple, non-critical uses you can just use a
> volatile flag-type variable.  Cheap and nasty, I agree, but useable.
> 

In some cases that is true - particularly on small processors and
embedded systems that don't have complications like caches, write
buffers, superscaler cpus, etc.

> Regards,
> 
> David P.
> 



[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