volatile in struct

Angelo Fraietta afraiett at bigpond.net.au
Mon Feb 16 19:46:10 UTC 2004



Sergei Organov wrote:

>2. Using volatile is almost never a good idea. If you use RTOS primitives for
>   mutual exclusion correctly, you don't need volatile for your protected
>   data.
>  
>
I would have to dissagree with that. If I had a loop eg

while (x)
    {
       do something
    }

And x is decremented in another thread, the compiler can optimise x so 
it will never appear changed without volatile

-- 
Angelo Fraietta

PO Box 859
Hamilton NSW 2303

Home Page


http://www.users.bigpond.com/angelo_f/

There are those who seek knowledge for the sake of knowledge - that is CURIOSITY
There are those who seek knowledge to be known by others - that is VANITY
There are those who seek knowledge in order to serve - that is LOVE
    Bernard of Clairvaux (1090 - 1153)






More information about the users mailing list