89. Circular Buffer-I

Question.7

A UART ISR pushes received bytes, and the main loop pops them. Both access the same circular buffer:

// ISR (runs on UART interrupt)
void UART_ISR() {
   buffer_push(&rx_buf, UART_DR);
}

// Main loop
while (1) {
   if (!buffer_is_empty(&rx_buf)) {
       buffer_pop(&rx_buf, &byte);
       process(byte);
   }
}

What concurrency problem can occur?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!