From: Will D. <wy...@ca...> - 2013-03-22 22:47:57
|
You are right. How about one thread writes, but the other thread only reads? From: David Chapman [mailto:dcc...@ac...] Sent: Friday, March 22, 2013 3:46 PM To: Will Deng Cc: val...@li... 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 dcc...@ac...<mailto:dcc...@ac...> Chapman Consulting -- San Jose, CA Software Development Done Right. www.chapman-consulting-sj.com<http://www.chapman-consulting-sj.com> |