From 49deb55988d873a8b8084ca75644b7d61c7a047c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 24 Aug 2011 16:21:52 -0400 Subject: [PATCH] Document prod/consumer synchro Signed-off-by: Mathieu Desnoyers --- libringbuffer/frontend_internal.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libringbuffer/frontend_internal.h b/libringbuffer/frontend_internal.h index 02cb4d4a..1fb08dfd 100644 --- a/libringbuffer/frontend_internal.h +++ b/libringbuffer/frontend_internal.h @@ -386,6 +386,20 @@ void lib_ring_buffer_check_deliver(const struct lib_ring_buffer_config *config, * Wake-up the other end by * writing a null byte in the * pipe (non-blocking). + * Important note: Because + * writing into the pipe is + * non-blocking (and therefore + * we allow dropping wakeup + * data, as long as there is + * wakeup data present in the + * pipe buffer to wake up the + * consumer), the consumer + * should perform the following + * sequence for waiting: + * 1) empty the pipe (reads). + * 2) check if there is data in + * the buffer. + * 3) wait on the pipe (poll). */ do { ret = write(wakeup_fd, "", 1); -- 2.34.1