KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a multi-R/W lock class that keeps the read, write and pending read , pending write counters. A mutex guards them from multiple threads. My question is Do we still need the counters to be declared as volatile so that the compiler won't screw it up while doing the optimization. Or does the compiler takes into account that the counters are guarded by the mutex. I understand that the mutex is a run time mechanism to for synchronization and "volatile" keyword is a compile time indication to the compiler to do the right thing while doing the optimizations. Regards, -Jay.
Tags (comma-separated)
Save Edits
Cancel