-4 karma · joined Jan 4, 2014 (12y ago) · 5 submissions
comment 12y ago · link · parent
Data races don't mean data corruption. It simply means the result is dependent on the scheduler or something else out of your control.
Two threads set a shared variable to different values. They both lock it before the set it. But that's still a data race, as which thread write first is dependent on the scheduler.
comment 12y ago · link · parent
"A race condition or race hazard is the behavior of an electronic or software system where the output is dependent on the sequence or timing of other uncontrollable events."
"It becomes a bug when events do not happen in the order the programmer intended."
http://en.wikipedia.org/wiki/Race_condition
If I thought that the message A would definitely get there first - who knows why but that's what I thought when I wrote the code - this is a race condition and a bug.
Please explain to me - how does the compiler prevent this race condition and bug?
comment 12y ago · link · parent
Lol what? Unless tasks cannot communicate at all, or they are scheduled entirely deterministically, how can the compiler eliminate race conditions? How can a compiler even determine what is a race conditions and what is intended non-determinstic behaviour.