4 ms·
For your last para, I think it is actually pretty common to use a lock free ring buffer. An atomic instruction takes the place of locking for swapping out data
by kev009 13y ago
For your last para, I think it is actually pretty common to use a lock free ring buffer. An atomic instruction takes the place of locking for swapping out data pointers. In fact I think modern adapters write directly into a buffer (DMA) and atomically update the data pointer in the ring.
Not an expert on these topics, feel free to correct. But lockless programming is pretty much critical section programming, just offloading the critical part to the consistency model.
- exDM69 13y ago> For your last para, I think it is actually pretty common to use a lock free ring buffer. An atomic instruction takes the place of locking for swapping out data pointers. I think you're right, that particular use case is perhaps not the best example. Ethernet -> IP is a single producer situation where the Ethernet driver is free to drop a packet if the input buffer is full. So that can be implemented without locking.