]> git.sur5r.net Git - freertos/commitdiff
Added xTaskGetApplicationTaskTag() function.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sat, 30 May 2009 13:30:40 +0000 (13:30 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sat, 30 May 2009 13:30:40 +0000 (13:30 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@754 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/tasks.c

index 64417e11af294981c6ac7741786980aa492958fe..447dff48f48620361660282da040cd3657facfa6 100644 (file)
@@ -1451,6 +1451,35 @@ void vTaskIncrementTick( void )
 #endif\r
 /*-----------------------------------------------------------*/\r
 \r
+#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
+\r
+       pdTASK_HOOK_CODE xTaskGetApplicationTaskTag( xTaskHandle xTask )\r
+       {\r
+       tskTCB *xTCB;\r
+       pdTASK_HOOK_CODE xReturn;\r
+\r
+               /* If xTask is NULL then we are setting our own task hook. */\r
+               if( xTask == NULL )\r
+               {\r
+                       xTCB = ( tskTCB * ) pxCurrentTCB;\r
+               }\r
+               else\r
+               {\r
+                       xTCB = ( tskTCB * ) xTask;\r
+               }\r
+\r
+               /* Save the hook function in the TCB.  A critical section is required as\r
+               the value can be accessed from an interrupt. */\r
+               portENTER_CRITICAL();\r
+                       xReturn = xTCB->pxTaskTag;\r
+               portEXIT_CRITICAL();\r
+               \r
+               return xReturn;\r
+       }\r
+\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
 #if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
 \r
        portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter )\r
@@ -1778,7 +1807,12 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
 static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed portCHAR * const pcName, unsigned portBASE_TYPE uxPriority )\r
 {\r
        /* Store the function name in the TCB. */\r
-       strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned portSHORT ) configMAX_TASK_NAME_LEN );\r
+       #if configMAX_TASK_NAME_LEN > 1\r
+       {\r
+               /* Don't bring strncpy into the build unnecessarily. */\r
+               strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned portSHORT ) configMAX_TASK_NAME_LEN );\r
+       }\r
+       #endif\r
        pxTCB->pcTaskName[ ( unsigned portSHORT ) configMAX_TASK_NAME_LEN - ( unsigned portSHORT ) 1 ] = '\0';\r
 \r
        /* This is used as an array index so must ensure it's not too large. */\r