89. Circular Buffer-I

Question.8

A firmware engineer replaces a linear UART receive buffer with a circular buffer. The old code used a linear array with a write index that reset to 0 after processing:

// Old: linear buffer
if (write_idx == BUF_SIZE) {
   process_buffer(buf, write_idx);
   write_idx = 0;
}

What problem does the circular buffer solve that the linear buffer cannot?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!