You are right. How about one thread writes, but the other thread only reads?

From: David Chapman [mailto:[email protected]]
Sent: Friday, March 22, 2013 3:46 PM
To: Will Deng
Cc: [email protected]
Subject: Re: [Valgrind-users] Helgrind doesn't handle bit field correctly

On 3/22/2013 3:35 PM, Will Deng wrote:
Even if two threads are writing to the same word, as long as thread 1 doesn't 
modify thread_2_data, it should be ok, right?

Nope:  the usual way for a processor to do this is to read the entire word, 
modify the appropriate bits, and then write the entire word.  This is very 
definitely a race in your situation.  Thread 1 would write the old value of 
thread_2_data with the new value of thread_1_data, or vice versa.


--

    David Chapman      [email protected]<mailto:[email protected]>

    Chapman Consulting -- San Jose, CA

    Software Development Done Right.

    www.chapman-consulting-sj.com<http://www.chapman-consulting-sj.com>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to