Search code examples
assemblysynchronizationx86powerpcmemory-barriers

order and barrier:what is the equivalent instruction on x86 for 'lwsync' on PowerPC?


My code is simple as below.I found rmb and wmb for read and write,but found no general one.lwsync is available on PowerPC,but what is the replacement for x86?Thanks in advance.

#define barrier() __asm__ volatile ("lwsync")
...
    lock()
    if(!pInst);
    {
        T* temp=new T;
        barrier();
        pInst=temp;
    }
    unlock();

Solution

  • rmb() and wmb() are the Linux kernel functions. There is also mb().

    The x86 instructions are lfence, sfence, and mfence, IIRC.