will it be re-order?

will it be re-order?

softarts's picture

inline void free (volatile void *doomed)//volatile needed?

{

volatile MemoryPoolV2 *newhead =(volatile MemoryPoolV2 *) doomed;

volatile MemoryPoolV2 *oldhead;

do

{

oldhead = next; //L1

newhead->next = next; //L2 may re-order?

asm volatile("mfence":::"memory");

}while( CAS((unsigned long*)&next,(unsigned long)newhead,(unsigned long)oldhead) != (int)oldhead);

}

if CAS done successfully,the L2 must be done also?just observe in other thread that "next" changed,but next->next is wrong(means the newhead->next=next doesn't work)

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.