My initial thoughts were that it'd be a simple thing to implement (designed for a single provider and single consumer). And it seems like it is... with the little assumption that your memory read/writes execute as coded.
However, you can't make that assumption. Seems like compilers and CPUs both like to reorder read/writes, hell, even invent them.
At this point I'm thinking that I'm probably best off going ahead and using a locking data-transfer implementation for simplicity until it's proven that it's a bottleneck. But while that may be what I put into source control, this seems like a really interesting problem that I'd still like to toy with on my own time.
So, my question comes down to are volatile pointers and careful use of mb() enough to solve this problem? i.e., am I attempting an unsolvable task?
However, you can't make that assumption. Seems like compilers and CPUs both like to reorder read/writes, hell, even invent them.
At this point I'm thinking that I'm probably best off going ahead and using a locking data-transfer implementation for simplicity until it's proven that it's a bottleneck. But while that may be what I put into source control, this seems like a really interesting problem that I'd still like to toy with on my own time.
So, my question comes down to are volatile pointers and careful use of mb() enough to solve this problem? i.e., am I attempting an unsolvable task?