need advice to implement blocking ring buffer
Posted: Mon Sep 24, 2018 1:50 pm
Hello,
I want to implement a ring (circular) buffer of bytes, where permitted operation would be
write(const byte *from, size_t n), and read(byte *to, size_t n), in the same spirit than a mailbox, with the difference that basic
element is a byte, not a msg_t, and you can add or read a buffer of bytes instead of a single element. (workhorse for the copy will be memcpy because i want to maximize performance).
write(..., n) should block until the circular buffer can push all the «n» bytes, and read(..., n) should block until it can pop all the n bytes.
It's to be used in a context where there is only two endpoints, so that can make the problem easier than a generalised N writer / M reader.
Perhaps this kind of object already exists in chibios ?
If not, which synchronization object should i use ?, counting semaphore does not seems to be appropriate.
thanks for any idea
Alexandre
I want to implement a ring (circular) buffer of bytes, where permitted operation would be
write(const byte *from, size_t n), and read(byte *to, size_t n), in the same spirit than a mailbox, with the difference that basic
element is a byte, not a msg_t, and you can add or read a buffer of bytes instead of a single element. (workhorse for the copy will be memcpy because i want to maximize performance).
write(..., n) should block until the circular buffer can push all the «n» bytes, and read(..., n) should block until it can pop all the n bytes.
It's to be used in a context where there is only two endpoints, so that can make the problem easier than a generalised N writer / M reader.
Perhaps this kind of object already exists in chibios ?
If not, which synchronization object should i use ?, counting semaphore does not seems to be appropriate.
thanks for any idea
Alexandre