do we need a read lock for reading an integer other than if the variable is less than memalign and during some caching situation ?
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.
The analyser assumes that because the address of
f1()has been taken, it could be called through that function pointer from any context. If, for example, you have one thread updatingx:and another thread calls
f1()simultaneously through the function pointer, the access tof1()in that second thread won’t be protected by the lock. It could therefore see a partial update ofx, or see the update incorrectly ordered with respect to other updates.The reason why the function pointer matters is that if the address of
f1()is never taken, then the analyser can determine exactly where the function is called from. When the address has been taken, it has to assume the worst case.