IT lexicon › Programming › Bip buffer

Bip buffer

Programming På svenska → Updated: 2026-11-04

A ring buffer that never splits a block down the middle, so the reader always gets a contiguous stretch of memory.

The ordinary ring buffer has an awkward corner: when the write index wraps, a message ends up half at the end of the array and half at the start. Anyone who wants to hand that block to a DMA channel or parse it in place has to stitch it together first. Simon Cooke described a fix in 2003 using two regions, A and B. Writes keep extending A while there's room; once the end is reached, region B starts at the beginning of the buffer while A is still draining. The reader always takes from A, and when A runs dry, B becomes the new A.

The cost is some wasted space at the end when a block doesn't fit, and an implementation that's fiddlier to get right. In return, both the copy and the special case disappear.

← Back to the lexicon