freertos(IDF): Use common macros for SMP specific critical sections

In IDF FreeRTOS, when building for SMP, there are numerous functions
which require different critical sections when compared to single-core. This
commit encapsulates those difference into a common set of macros whose
behavior depends on "configNUM_CORES > 1". As such...

- Vanilla behavior has been restored for some functions when building for
  single core (i.e., used to call taskENTER_CRITICAL, now disables interrupts
  mactching vanilla behavior).
- Reduces number of "#ifdef (configNUM_CORES > 1)" in functions
- Any SMP only critical sections are now wrapped by
  "#ifdef (configNUM_CORES > 1)" and properly documented via comments.
This commit is contained in:
Darian Leung
2022-11-14 15:27:00 +08:00
parent 4c1ff6016a
commit 087e4318a6
7 changed files with 372 additions and 367 deletions

View File

@@ -606,11 +606,7 @@
TickType_t xTimeNow;
BaseType_t xTimerListsWereSwitched;
#ifdef ESP_PLATFORM
taskENTER_CRITICAL( &xTimerLock );
#else
vTaskSuspendAll();
#endif // ESP_PLATFORM
prvENTER_CRITICAL_OR_SUSPEND_ALL( &xTimerLock );
{
/* Obtain the time now to make an assessment as to whether the timer
* has expired or not. If obtaining the time causes the lists to switch
@@ -624,11 +620,7 @@
/* The tick count has not overflowed, has the timer expired? */
if( ( xListWasEmpty == pdFALSE ) && ( xNextExpireTime <= xTimeNow ) )
{
#ifdef ESP_PLATFORM
taskEXIT_CRITICAL( &xTimerLock );
#else
( void ) xTaskResumeAll();
#endif // ESP_PLATFORM
( void ) prvEXIT_CRITICAL_OR_RESUME_ALL( &xTimerLock );
prvProcessExpiredTimer( xNextExpireTime, xTimeNow );
}
else
@@ -648,11 +640,7 @@
vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ), xListWasEmpty );
#ifdef ESP_PLATFORM /* IDF-3755 */
taskEXIT_CRITICAL( &xTimerLock );
#else
if( xTaskResumeAll() == pdFALSE )
#endif // ESP_PLATFORM
if( prvEXIT_CRITICAL_OR_RESUME_ALL( &xTimerLock ) == pdFALSE )
{
/* Yield to wait for either a command to arrive, or the
* block time to expire. If a command arrived between the
@@ -660,22 +648,15 @@
* will not cause the task to block. */
portYIELD_WITHIN_API();
}
#ifndef ESP_PLATFORM /* IDF-3755 */
else
{
mtCOVERAGE_TEST_MARKER();
}
#endif // ESP_PLATFORM
else
{
mtCOVERAGE_TEST_MARKER();
}
}
}
else
{
#ifdef ESP_PLATFORM /* IDF-3755 */
taskEXIT_CRITICAL( &xTimerLock );
#else
( void ) xTaskResumeAll();
#endif // ESP_PLATFORM
( void ) prvEXIT_CRITICAL_OR_RESUME_ALL( &xTimerLock );
}
}
}