X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=Source%2Ftasks.c;h=16914978cb84b29ce511f37efcae967a26d7e8b9;hb=4fd10f25c4043639f2dd072be1c842be4115d906;hp=020443d31e45790d7e0f9fe1f2921140ad39ae44;hpb=a2f9ef937b63d9ffbf33143b66611a97bfcb4c26;p=freertos diff --git a/Source/tasks.c b/Source/tasks.c index 020443d31..16914978c 100644 --- a/Source/tasks.c +++ b/Source/tasks.c @@ -157,6 +157,12 @@ PRIVILEGED_DATA static xList xPendingReadyList; /*< Tasks that have been r #endif +#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) + + PRIVILEGED_DATA static xTaskHandle xIdleTaskHandle = NULL; + +#endif + /* File private variables. --------------------------------*/ PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxCurrentNumberOfTasks = ( unsigned portBASE_TYPE ) 0; PRIVILEGED_DATA static volatile portTickType xTickCount = ( portTickType ) 0; @@ -1090,7 +1096,18 @@ void vTaskStartScheduler( void ) portBASE_TYPE xReturn; /* Add the idle task at the lowest priority. */ - xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), ( xTaskHandle * ) NULL ); + #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) + { + /* Create the idle task, storing its handle in xIdleTaskHandle so it can + be returned by the xTaskGetIdleTaskHandle() function. */ + xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), &xIdleTaskHandle ); + } + #else + { + /* Create the idle task without storing its handle. */ + xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), NULL ); + } + #endif #if ( configUSE_TIMERS == 1 ) { @@ -1281,6 +1298,17 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) } /*-----------------------------------------------------------*/ +signed char *pcTaskGetTaskName( xTaskHandle xTaskToQuery ) +{ +tskTCB *pxTCB; + + /* If null is passed in here then the name of the calling task is being queried. */ + pxTCB = prvGetTCBFromHandle( xTaskToQuery ); + configASSERT( pxTCB ); + return &( pxTCB->pcTaskName[ 0 ] ); +} +/*-----------------------------------------------------------*/ + #if ( configUSE_TRACE_FACILITY == 1 ) void vTaskList( signed char *pcWriteBuffer ) @@ -1455,8 +1483,19 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) } #endif +/*----------------------------------------------------------*/ +#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) + xTaskHandle xTaskGetIdleTaskHandle( void ) + { + /* If xTaskGetIdleTaskHandle() is called before the scheduler has been + started, then xIdleTaskHandle will be NULL. */ + configASSERT( ( xIdleTaskHandle != NULL ) ); + return xIdleTaskHandle; + } + +#endif /*----------------------------------------------------------- * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES