Calling vTaskEndScheduler in application created task (#1187)

pull/1167/head^2
chinglee-iot 12 months ago committed by GitHub
parent 7cd180d914
commit d1ef345165
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -405,6 +405,16 @@ static void prvCheckTask( void * pvParameters )
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvEndSchedulerTask( void * pvParameters )
{
( void ) pvParameters;
/* Calling vTaskEndScheduler in an application created task. */
vTaskEndScheduler();
}
/*-----------------------------------------------------------*/
static void prvTestTask( void * pvParameters ) static void prvTestTask( void * pvParameters )
{ {
const unsigned long ulMSToSleep = 5; const unsigned long ulMSToSleep = 5;
@ -428,6 +438,7 @@ void vFullDemoIdleFunction( void )
{ {
const unsigned long ulMSToSleep = 15; const unsigned long ulMSToSleep = 15;
void * pvAllocated; void * pvAllocated;
BaseType_t xReturn;
/* Sleep to reduce CPU load, but don't sleep indefinitely in case there are /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
* tasks waiting to be terminated by the idle task. */ * tasks waiting to be terminated by the idle task. */
@ -484,7 +495,10 @@ void vFullDemoIdleFunction( void )
if( ( xTaskGetTickCount() - configINITIAL_TICK_COUNT ) >= xMaxRunTime ) if( ( xTaskGetTickCount() - configINITIAL_TICK_COUNT ) >= xMaxRunTime )
{ {
vTaskEndScheduler(); /* Creating another task to end the scheduler to prevent deleting idle
* task itself in vTaskEndScheduler. */
xReturn = xTaskCreate( prvEndSchedulerTask, "TestEnd", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );
configASSERT( xReturn == pdPASS );
} }
} }
#endif /* if ( projCOVERAGE_TEST == 1 ) */ #endif /* if ( projCOVERAGE_TEST == 1 ) */

Loading…
Cancel
Save