From 1bf0f0161afd8244c68189d411a7e9079389b556 Mon Sep 17 00:00:00 2001 From: Ching-Hsin Lee Date: Fri, 27 Jan 2023 21:15:06 +0800 Subject: [PATCH] Update soak test for SMP * Use configNUMBER_OF_CORES to separate the changes --- FreeRTOS/Demo/Common/Minimal/BlockQ.c | 21 +++++++++++++++++++-- FreeRTOS/Demo/Common/Minimal/IntQueue.c | 8 ++++---- FreeRTOS/Demo/Common/Minimal/dynamic.c | 11 ++++++++++- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/FreeRTOS/Demo/Common/Minimal/BlockQ.c b/FreeRTOS/Demo/Common/Minimal/BlockQ.c index 3383e75780d..358e093bfc7 100644 --- a/FreeRTOS/Demo/Common/Minimal/BlockQ.c +++ b/FreeRTOS/Demo/Common/Minimal/BlockQ.c @@ -61,6 +61,7 @@ #define blckqSTACK_SIZE configMINIMAL_STACK_SIZE #define blckqNUM_TASK_SETS ( 3 ) +#define blckqSHORT_DELAY ( 5 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) #error This example cannot be used if dynamic allocation is not allowed. #endif @@ -200,8 +201,17 @@ static portTASK_FUNCTION( vBlockingQueueProducer, pvParameters ) * consumer will expect the numbers to follow in numerical order. */ ++usValue; - #if configUSE_PREEMPTION == 0 + #if ( configNUMBER_OF_CORES > 1 ) + { + if( pxQueueParameters->xBlockTime == 0 ) + { + vTaskDelay( blckqSHORT_DELAY ); + } + } + #elif configUSE_PREEMPTION == 0 + { taskYIELD(); + } #endif } } @@ -241,7 +251,14 @@ static portTASK_FUNCTION( vBlockingQueueConsumer, pvParameters ) ++usExpectedValue; } - #if configUSE_PREEMPTION == 0 + #if ( configNUMBER_OF_CORES > 1 ) + { + if( pxQueueParameters->xBlockTime == 0 ) + { + vTaskDelay( blckqSHORT_DELAY ); + } + } + #elif configUSE_PREEMPTION == 0 { if( pxQueueParameters->xBlockTime == 0 ) { diff --git a/FreeRTOS/Demo/Common/Minimal/IntQueue.c b/FreeRTOS/Demo/Common/Minimal/IntQueue.c index 952deac1c1e..88f4a587884 100644 --- a/FreeRTOS/Demo/Common/Minimal/IntQueue.c +++ b/FreeRTOS/Demo/Common/Minimal/IntQueue.c @@ -97,7 +97,7 @@ if( xQueueIsQueueFullFromISR( xNormallyEmptyQueue ) != pdTRUE ) \ { \ UBaseType_t uxSavedInterruptStatus; \ - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); \ + uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR(); \ { \ uxValueForNormallyEmptyQueue++; \ if( xQueueSendFromISR( xNormallyEmptyQueue, ( void * ) &uxValueForNormallyEmptyQueue, &xHigherPriorityTaskWoken ) != pdPASS ) \ @@ -105,7 +105,7 @@ uxValueForNormallyEmptyQueue--; \ } \ } \ - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \ + taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus ); \ } \ @@ -115,7 +115,7 @@ if( xQueueIsQueueFullFromISR( xNormallyFullQueue ) != pdTRUE ) \ { \ UBaseType_t uxSavedInterruptStatus; \ - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); \ + uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR(); \ { \ uxValueForNormallyFullQueue++; \ if( xQueueSendFromISR( xNormallyFullQueue, ( void * ) &uxValueForNormallyFullQueue, &xHigherPriorityTaskWoken ) != pdPASS ) \ @@ -123,7 +123,7 @@ uxValueForNormallyFullQueue--; \ } \ } \ - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); \ + taskEXIT_CRITICAL_FROM_ISR( uxSavedInterruptStatus ); \ } \ diff --git a/FreeRTOS/Demo/Common/Minimal/dynamic.c b/FreeRTOS/Demo/Common/Minimal/dynamic.c index bb7851141e9..1ca41731383 100644 --- a/FreeRTOS/Demo/Common/Minimal/dynamic.c +++ b/FreeRTOS/Demo/Common/Minimal/dynamic.c @@ -279,7 +279,16 @@ static portTASK_FUNCTION( vCounterControlTask, pvParameters ) #if ( INCLUDE_eTaskGetState == 1 ) { - configASSERT( eTaskGetState( xContinuousIncrementHandle ) == eReady ); + #if( configNUMBER_OF_CORES > 1 ) + { + eTaskState eState = eTaskGetState( xContinuousIncrementHandle ); + configASSERT( ( eState == eReady ) || ( eState == eRunning ) ); + } + #else + { + configASSERT( eTaskGetState( xContinuousIncrementHandle ) == eReady ); + } + #endif } #endif /* INCLUDE_eTaskGetState */