Compiler optimization breaks multi-threaded code

2010-11-14 Thread Michal Minich
There is one question on SO which seems like a serious problem for atomic ops. http://stackoverflow.com/questions/4165149/compiler-optimization-breaks- multi-threaded-code in short: shared uint cnt; void atomicInc ( ) { uint o; while ( !cas( &cnt, o, o + 1 ) ) o = cnt; } is compile with

Re: Compiler optimization breaks multi-threaded code

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 01:04:46 Michal Minich wrote: > There is one question on SO which seems like a serious problem for atomic > ops. > > http://stackoverflow.com/questions/4165149/compiler-optimization-breaks- > multi-threaded-code > > in short: > > shared