Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

will it be re-order?

softarts
Beginner
248 Views

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)

0 Kudos
0 Replies
Reply