I have a question about the use of lock free queues.
Suppose I have a single-producer single-consumer queue, where the producer and consumer are bound to separate cores. The queue elements are buffers of shared memory, which is mmapped by both producer and consumer at the start.
The producer gets a queue element, populates the buffer with data and enqueues it, and the consumer dequeues the element, reads it and processes it in some fashion.
Do I, as a user of the lock-free queue, have to explicitly ensure that the buffer written by the producer is visible to the user? Or does the CAS (or other similar) primitive at the heart of the algorithm automatically provide the barrier?
The couple of examples that I have seen use integers as the payload, so this question of memory synchronization does not arise.
Thanks,