How do I tell GCC that a variable will be modified by multiple threads?
I am getting problems with compiler optimizations.
How do I tell GCC that a variable will be modified by multiple threads?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here is rather old article in Dobbs about volatile and threads http://drdobbs.com/cpp/184403766 This one is bit c++ish but it describe how volatile may be used.
But also, there are some people (including from Intel) who says “Volatile: Almost Useless for Multi-Threaded Programming” and shows why http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/ They says that direct using of atomic operations ( “load-with-acquire and store-with-release” ) and memory barriers are the solution of multi-threaded data sharing.