10 ms·
> But ring buffer requirement says “lock free” which only make sense inside a single process. No, "lock free" is a thing that's nice to have when you've got tw
by rstuart4133 2y ago
> But ring buffer requirement says “lock free” which only make sense inside a single process.
No, "lock free" is a thing that's nice to have when you've got two threads accessing the same memory. It doesn't matter if those two threads are in the same process or it's two different processes accessing the same memory. It's almost certainly two different processes in this case, and the shared memory is probably memory mapped file.
Whatever it is, the shared memory approach is going to be much faster using the kernel to ship the data between the two processes. Via the kernel means two copies, and probably two syscalls as well.
- kikimora 2y agoI understand you can setup a data structure in shared memory and use lock free instructions to access it. However, I have never seen this is done in practice due to complexity. One particularly complicated scenario that comes to mind is dealing with unexpected process failures. This is quite different to dealing with exceptions in a thread.