MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / xTaskGetHandle

Function xTaskGetHandle

tasks.c:3206–3263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3204#if ( INCLUDE_xTaskGetHandle == 1 )
3205
3206 TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
3207 {
3208 UBaseType_t uxQueue = configMAX_PRIORITIES;
3209 TCB_t * pxTCB;
3210
3211 /* Task names will be truncated to configMAX_TASK_NAME_LEN - 1 bytes. */
3212 configASSERT( strlen( pcNameToQuery ) < configMAX_TASK_NAME_LEN );
3213
3214 vTaskSuspendAll();
3215 {
3216 /* Search the ready lists. */
3217 do
3218 {
3219 uxQueue--;
3220 pxTCB = prvSearchForNameWithinSingleList( ( List_t * ) &( pxReadyTasksLists[ uxQueue ] ), pcNameToQuery );
3221
3222 if( pxTCB != NULL )
3223 {
3224 /* Found the handle. */
3225 break;
3226 }
3227 } while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
3228
3229 /* Search the delayed lists. */
3230 if( pxTCB == NULL )
3231 {
3232 pxTCB = prvSearchForNameWithinSingleList( ( List_t * ) pxDelayedTaskList, pcNameToQuery );
3233 }
3234
3235 if( pxTCB == NULL )
3236 {
3237 pxTCB = prvSearchForNameWithinSingleList( ( List_t * ) pxOverflowDelayedTaskList, pcNameToQuery );
3238 }
3239
3240 #if ( INCLUDE_vTaskSuspend == 1 )
3241 {
3242 if( pxTCB == NULL )
3243 {
3244 /* Search the suspended list. */
3245 pxTCB = prvSearchForNameWithinSingleList( &xSuspendedTaskList, pcNameToQuery );
3246 }
3247 }
3248 #endif
3249
3250 #if ( INCLUDE_vTaskDelete == 1 )
3251 {
3252 if( pxTCB == NULL )
3253 {
3254 /* Search the deleted list. */
3255 pxTCB = prvSearchForNameWithinSingleList( &xTasksWaitingTermination, pcNameToQuery );
3256 }
3257 }
3258 #endif
3259 }
3260 ( void ) xTaskResumeAll();
3261
3262 return pxTCB;
3263 }

Callers 1

MPU_xTaskGetHandleFunction · 0.85

Calls 3

vTaskSuspendAllFunction · 0.85
xTaskResumeAllFunction · 0.85

Tested by

no test coverage detected