[Jack-Devel] Volatile vs memory fences

Xavier Mendez me at jmendeth.com
Sat Dec 5 12:18:31 CET 2015


I was reviewing the code for `jack_ringbuffer` and I saw it uses 
`volatile` for the pointers. This confused me, since my teachers have 
long insisted that `volatile` isn't for use on multithreaded code.

Take i.e. `jack_ringbuffer_write`: the hardware could reorder the writes 
so that the pointer is updated before the buffer has been written. 
Wouldn't a memory fence be required?

I appreciate your responses, I'm quite a noob when it comes to lock-free 
programming...

Thank you,
Xavi



More information about the Jackaudio mailing list