User: Password:
|
|
Subscribe / Log in / New account

Declaring it volatile

Declaring it volatile

Posted Aug 7, 2012 14:37 UTC (Tue) by PaulMcKenney (subscriber, #9624)
In reply to: Declaring it volatile by daglwn
Parent article: ACCESS_ONCE()

And one of the corresponding bugs for your suggested approach of marking the variable volatile and caching the value in a temporary is failure to update the temporary when updating the underlying variable. So I remain unconvinced.


(Log in to post comments)

Declaring it volatile

Posted Aug 7, 2012 19:44 UTC (Tue) by daglwn (guest, #65432) [Link]

If the programmmer is optimizing by using a temporary, the assumption is that the programmer knows what he or she is doing. The optimization is explicit and is an immediate flag to the reader to carefully examine the (existing or new) code for bugs.

I'm not trying to convince you, simply stating what I believe is good programming practice. Maybe I'm wrong. But it's worked for me so far. :)

Declaring it volatile

Posted Aug 8, 2012 15:26 UTC (Wed) by PaulMcKenney (subscriber, #9624) [Link]

To each their own, I guess.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds