inline void free (volatile void *doomed)//volatile needed?
volatile MemoryPoolV2 *newhead =(volatile MemoryPoolV2 *) doomed;
volatile MemoryPoolV2 *oldhead;
oldhead = next; //L1
newhead->next = next; //L2 may re-order?
}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)
For more complete information about compiler optimizations, see our Optimization Notice.