Subj : Re: What does Memory Barriers mean ?? To : comp.programming.threads From : Marcin 'Qrczak' Kowalczyk Date : Sat Jan 08 2005 11:01 am "SenderX" writes: > I have had some compiler reordering issues a while ago when I was testing > and developing the RCU algorithm that my library uses. I disassembled some > key stuff and found that a hazards reference was being performed before the > RCU quiescent state changed to active. MSVC++ did not reorder the > instructions, but GCC on linux did. I bet the error was on your side. > extern void assembly_routine_1( void** ); > extern void assembly_routine_2( void** ); > > > /* code */ > > void *p1, *p2; > > 1: assembly_routine_1( &p1 ); > 2: assembly_routine_2( &p2 ); > > > Since call 2 dosen't rely on anything from call 1, could the compiler could > execute call 2 before call 1? No. The functions may e.g. global variables or do I/O, so the compiler will not reorder them. > 1: assembly_routine_1( &p1 ); > 2: p2 = p1; > 3: assembly_routine_2( &p2 ); Same here. 1 must be executed before 2, because 1 may change p1. 2 must be executed before 3, because 3 depends on 2. -- __("< Marcin Kowalczyk \__/ qrczak@knm.org.pl ^^ http://qrnik.knm.org.pl/~qrczak/ .