Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

race condition in ring buffer #24

Open
nerdralph opened this issue Aug 15, 2020 · 0 comments
Open

race condition in ring buffer #24

nerdralph opened this issue Aug 15, 2020 · 0 comments

Comments

@nerdralph
Copy link
Contributor

UartByteCount is modified in the UART1 ISR and in main. If the UART1 interrupt occurs between lines 590 and 598, the received byte will be dropped.
https://github.com/Blinkinlabs/ch554_sdcc/blob/master/examples/usb_device_cdc/main.c#L598

I don't see a simple fix. I think it would be best to replace the ring buffer code with a thread-safe version. I recently published a tiny ring buffer that would be a good fit.
https://github.com/nerdralph/RingBuffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant