- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)
Link Copied
0 Replies
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page