]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/tasks.c
Ensure xNewLib_reent is reclaimed when a task is deleted.
[freertos] / FreeRTOS / Source / tasks.c
index 12f16d674498a65ef04cb9cffaf95029ca24cbab..60d62b09a33600c5a3ea6876ed73a307ef3da3d9 100644 (file)
@@ -167,7 +167,11 @@ typedef struct tskTaskControlBlock
                struct  _reent xNewLib_reent;\r
        #endif\r
 \r
-} TCB_t;\r
+} tskTCB;\r
+\r
+/* The old tskTCB name is maintained above then typedefed to the new TCB_t name\r
+below to enable the use of older kernel aware debuggers. */\r
+typedef tskTCB TCB_t;\r
 \r
 /*\r
  * Some kernel aware debuggers require the data the debugger needs access to to\r
@@ -756,7 +760,11 @@ TCB_t * pxNewTCB;
                        {\r
                                /* Reset the next expected unblock time in case it referred to\r
                                the task that has just been deleted. */\r
-                               prvResetNextTaskUnblockTime();\r
+                               taskENTER_CRITICAL();\r
+                               {\r
+                                       prvResetNextTaskUnblockTime();\r
+                               }\r
+                               taskEXIT_CRITICAL();\r
                        }\r
                }\r
        }\r
@@ -1255,7 +1263,11 @@ TCB_t * pxNewTCB;
                                /* A task other than the currently running task was suspended,\r
                                reset the next expected unblock time in case it referred to the\r
                                task that is now in the Suspended state. */\r
-                               prvResetNextTaskUnblockTime();\r
+                               taskENTER_CRITICAL();\r
+                               {\r
+                                       prvResetNextTaskUnblockTime();\r
+                               }\r
+                               taskEXIT_CRITICAL();\r
                        }\r
                        else\r
                        {\r
@@ -1286,7 +1298,7 @@ TCB_t * pxNewTCB;
                        /* Has the task already been resumed from within an ISR? */\r
                        if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) == pdFALSE )\r
                        {\r
-                               /* Is it in the suspended list because it is in the     Suspended \r
+                               /* Is it in the suspended list because it is in the     Suspended\r
                                state, or because is is blocked with no timeout? */\r
                                if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) != pdFALSE )\r
                                {\r
@@ -2335,7 +2347,7 @@ BaseType_t xReturn;
        called from a critical section within an ISR. */\r
 \r
        /* The event list is sorted in priority order, so the first in the list can\r
-       be removed as it is known to be the highest priority.  Remove the TCB from \r
+       be removed as it is known to be the highest priority.  Remove the TCB from\r
        the delayed list, and add it to the ready list.\r
 \r
        If an event is for a queue that is locked then this function will never\r
@@ -3074,8 +3086,13 @@ TCB_t *pxNewTCB;
                want to allocate and clean RAM statically. */\r
                portCLEAN_UP_TCB( pxTCB );\r
 \r
-               /* Free up the memory allocated by the scheduler for the task.  It is up to\r
-               the task to free any memory allocated at the application level. */\r
+               /* Free up the memory allocated by the scheduler for the task.  It is up\r
+               to the task to free any memory allocated at the application level. */\r
+               #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
+               {\r
+                       _reclaim_reent( &( pxTCB->xNewLib_reent ) );\r
+               }\r
+               #endif /* configUSE_NEWLIB_REENTRANT */\r
                vPortFreeAligned( pxTCB->pxStack );\r
                vPortFree( pxTCB );\r
        }\r
@@ -3415,6 +3432,12 @@ TCB_t *pxTCB;
        volatile UBaseType_t uxArraySize, x;\r
        uint32_t ulTotalTime, ulStatsAsPercentage;\r
 \r
+               #if( configUSE_TRACE_FACILITY != 1 )\r
+               {\r
+                       #error configUSE_TRACE_FACILITY must also be set to 1 in FreeRTOSConfig.h to use vTaskGetRunTimeStats().\r
+               }\r
+               #endif\r
+\r
                /*\r
                 * PLEASE NOTE:\r
                 *\r