Stream buffers are an RTOS task to RTOS task, and interrupt to task
communication primitives. Unlike most other FreeRTOS communications primitives, they
are optimised for single reader single writer scenarios, such as passing data
from an interrupt service routine to a task, or from one microcontroller core to
another on dual core CPUs. Data is passed by copy – the data is copied into the
buffer by the sender and out of the buffer by the read.
Stream buffers pass a continuous stream of bytes. Message buffers pass
variable sized but discrete messages. Message
buffers use stream buffers for data transfer.
IMPORTANT NOTE: Uniquely among FreeRTOS objects, the
implementation (so also the message buffer implementation, as message buffers
are built on top of stream buffers) assumes there is only one task or
interrupt that will write to the buffer (the writer), and only one task or
interrupt that will read from the buffer (the reader). It is safe for the
writer and reader to be different tasks or interrupts, but, unlike other
FreeRTOS objects, it is not safe to have multiple different writers or
multiple different readers. If there are to be multiple different writers
then the application writer must place each call to a writing API function
(such as xStreamBufferSend()) inside a
critical section and use a send block time of 0. Likewise, if there
are to be multiple different readers then the application writer must place
each call to a reading API function (such as xStreamBufferReceive()) inside a
critical section and use a receive block time of 0.
The following pages describe stream buffers and message buffers in more detail,
and provide examples of their use to implement interrupt to task and processor core
to processor core communications respectively.
More about Stream Buffers…
More about Message Buffers…
Blog on using message buffers for core to core communication…
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.