mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-05-12 11:42:57 -04:00
Batching buffers read when reaching threshold
This change reduces the differences between traditional stream/message buffers and batching stream buffers. Batching stream buffers are updated to trigger and read data when enough data is present to EQUAL the threshold rather than exceed it. Inspired by https://github.com/FreeRTOS/FreeRTOS-Kernel/issues/1375
This commit is contained in:
parent
5f2cc25b17
commit
0ab20dd78b
2 changed files with 5 additions and 9 deletions
|
|
@ -292,10 +292,8 @@ typedef void (* StreamBufferCallbackFunction_t)( StreamBufferHandle_t xStreamBuf
|
||||||
* - The task reading from a non-empty stream buffer returns immediately
|
* - The task reading from a non-empty stream buffer returns immediately
|
||||||
* regardless of the amount of data in the buffer.
|
* regardless of the amount of data in the buffer.
|
||||||
* - The task reading from a non-empty steam batching buffer blocks until the
|
* - The task reading from a non-empty steam batching buffer blocks until the
|
||||||
* amount of data in the buffer exceeds the trigger level or the block time
|
* amount of data in the buffer reaches the trigger level or the block time
|
||||||
* expires.
|
* expires.
|
||||||
*
|
|
||||||
* @param xBufferSizeBytes The total number of bytes the stream batching buffer
|
|
||||||
* will be able to hold at any one time.
|
* will be able to hold at any one time.
|
||||||
*
|
*
|
||||||
* @param xTriggerLevelBytes The number of bytes that must be in the stream
|
* @param xTriggerLevelBytes The number of bytes that must be in the stream
|
||||||
|
|
@ -380,10 +378,8 @@ typedef void (* StreamBufferCallbackFunction_t)( StreamBufferHandle_t xStreamBuf
|
||||||
* - The task reading from a non-empty stream buffer returns immediately
|
* - The task reading from a non-empty stream buffer returns immediately
|
||||||
* regardless of the amount of data in the buffer.
|
* regardless of the amount of data in the buffer.
|
||||||
* - The task reading from a non-empty steam batching buffer blocks until the
|
* - The task reading from a non-empty steam batching buffer blocks until the
|
||||||
* amount of data in the buffer exceeds the trigger level or the block time
|
* amount of data in the buffer reaches the trigger level or the block time
|
||||||
* expires.
|
* expires.
|
||||||
*
|
|
||||||
* @param xBufferSizeBytes The size, in bytes, of the buffer pointed to by the
|
|
||||||
* pucStreamBufferStorageArea parameter.
|
* pucStreamBufferStorageArea parameter.
|
||||||
*
|
*
|
||||||
* @param xTriggerLevelBytes The number of bytes that must be in the stream
|
* @param xTriggerLevelBytes The number of bytes that must be in the stream
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@
|
||||||
/* Bits stored in the ucFlags field of the stream buffer. */
|
/* Bits stored in the ucFlags field of the stream buffer. */
|
||||||
#define sbFLAGS_IS_MESSAGE_BUFFER ( ( uint8_t ) 1 ) /* Set if the stream buffer was created as a message buffer, in which case it holds discrete messages rather than a stream. */
|
#define sbFLAGS_IS_MESSAGE_BUFFER ( ( uint8_t ) 1 ) /* Set if the stream buffer was created as a message buffer, in which case it holds discrete messages rather than a stream. */
|
||||||
#define sbFLAGS_IS_STATICALLY_ALLOCATED ( ( uint8_t ) 2 ) /* Set if the stream buffer was created using statically allocated memory. */
|
#define sbFLAGS_IS_STATICALLY_ALLOCATED ( ( uint8_t ) 2 ) /* Set if the stream buffer was created using statically allocated memory. */
|
||||||
#define sbFLAGS_IS_BATCHING_BUFFER ( ( uint8_t ) 4 ) /* Set if the stream buffer was created as a batching buffer, meaning the receiver task will only unblock when the trigger level exceededs. */
|
#define sbFLAGS_IS_BATCHING_BUFFER ( ( uint8_t ) 4 ) /* Set if the stream buffer was created as a batching buffer, meaning the receiver task will only unblock when the trigger level is reached. */
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
@ -1077,9 +1077,9 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
|
||||||
}
|
}
|
||||||
else if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_BATCHING_BUFFER ) != ( uint8_t ) 0 )
|
else if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_BATCHING_BUFFER ) != ( uint8_t ) 0 )
|
||||||
{
|
{
|
||||||
/* Force task to block if the batching buffer contains less bytes than
|
/* Force task to block if the batching buffer contains fewer bytes than
|
||||||
* the trigger level. */
|
* the trigger level. */
|
||||||
xBytesToStoreMessageLength = pxStreamBuffer->xTriggerLevelBytes;
|
xBytesToStoreMessageLength = pxStreamBuffer->xTriggerLevelBytes - 1U;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue