Equivalent function of membarrier on Apple Silicon Mac

Hi, I am looking for the way to achieve the same effect as Linux system call membarrier [1] on Apple Silicon Mac. The syscall issues memory barriers on the other threads. Windows has the similar function FlushProcessWriteBuffers [2]. Is there an equivalent function?

  • [1] https://man7.org/linux/man-pages/man2/membarrier.2.html
  • [2] https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-flushprocesswritebuffers

On Intel machines, changing the memory page settings by mprotect system calls makes write buffers of other processors flushed, but it does not seem to work on Apple Silicon.

Equivalent function of membarrier on Apple Silicon Mac
 
 
Q