mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 02:37:19 +02:00
Merge branch 'fix/freertos_race_cond_in_stream_buffers_send_v5.2' into 'release/v5.2'
fix(freertos): Fixed SMP race condition in xStreamBufferSend() (v5.2) See merge request espressif/esp-idf!34336
This commit is contained in:
@ -125,6 +125,8 @@ The following functions were modified to accommodate SMP behavior:
|
||||
- Added extra check to see if current blocking task has already been deleted by the other core.
|
||||
- `xStreamBufferReceive()`
|
||||
- Added a critical section for setting `xTaskWaitingToReceive` to `NULL` so that the write is SMP safe.
|
||||
- `xStreamBufferSend()`
|
||||
- Added a critical section for setting `xTaskWaitingToSend` to `NULL` so that the write is SMP safe.
|
||||
|
||||
### Critical Section Changes
|
||||
|
||||
|
@ -773,7 +773,18 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
|
||||
|
||||
traceBLOCKING_ON_STREAM_BUFFER_SEND( xStreamBuffer );
|
||||
( void ) xTaskNotifyWait( ( uint32_t ) 0, ( uint32_t ) 0, NULL, xTicksToWait );
|
||||
pxStreamBuffer->xTaskWaitingToSend = NULL;
|
||||
/* In SMP mode, the task may have been woken and scheduled on
|
||||
* another core. Hence, we must clear the xTaskWaitingToSend
|
||||
* handle in a critical section. */
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
taskENTER_CRITICAL( &( pxStreamBuffer->xStreamBufferLock ) );
|
||||
#endif /* configNUMBER_OF_CORES > 1 */
|
||||
{
|
||||
pxStreamBuffer->xTaskWaitingToSend = NULL;
|
||||
}
|
||||
#if ( configNUMBER_OF_CORES > 1 )
|
||||
taskEXIT_CRITICAL( &( pxStreamBuffer->xStreamBufferLock ) );
|
||||
#endif /* configNUMBER_OF_CORES > 1 */
|
||||
} while( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE );
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user