Volatile example: Circular Buffer
Lock free circular buffer is based on the shared variables updates, visible from all threads
#define next(a) (((a)+1)%nEntries)
volatile int writeptr, readptr;
buffer[writeptr] = new stuff;
while (next(writeptr) == readptr);
writeptr = next(writeptr);
while (writeptr == readptr);