title: Do I need Read-Write lock here
body: <p>I have writing a multi threaded code. I am not sure, whether I would need a read and write lock mechanism. Could you please go through the usecase and tell me do I have to use read-write lock or just normal mutex will do.</p>
  
  <p>Use case:
  1) Class having two variables. These are accessed by every thread before doing operation.
  2) When something goes wrong, these variables are updated to reflect the error scenarios.
  Thus threads reading these variables can take different decisions (including abort)</p>
  
  <p>Here, in second point, I need to update the data. And in first point, every thread will use the data. So, my question is do I have to use write lock while updating data and read lock while reading the data. (Note: Both variables are in memory. Just a boolean flag &amp; string)</p>
  
  <p>I am confused because as my both vars are in memory. So does OS take care when integrity. I mean I can live with 1 or 2 threads missing the updated value when some thread is writing the data in mutex.</p>
  
  <p>Please tell if I am right or wrong? Also please tell If I have to use read-write lock or just normal mutex would do.</p>
  
  <p><strong>Update:</strong> I am sorry that I did not give platform and compiler name. I am on RHEL 5.0 and using gcc 4.6. My platform is x86_64. But I don not want my code to be OS specific because we are going to port the code shortly to Solaris 10.</p>