/*\r
- FreeRTOS V8.0.0:rc1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+ FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
the terms of the GNU General Public License (version 2) as published by the\r
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
\r
- >>! NOTE: The modification to the GPL is included to allow you to distribute\r
- >>! a combined work that includes FreeRTOS without being obliged to provide\r
- >>! the source code for proprietary components outside of the FreeRTOS\r
- >>! kernel.\r
+ >>! NOTE: The modification to the GPL is included to allow you to !<<\r
+ >>! distribute a combined work that includes FreeRTOS without being !<<\r
+ >>! obliged to provide the source code for proprietary components !<<\r
+ >>! outside of the FreeRTOS kernel. !<<\r
\r
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
\r
#if ( configUSE_MUTEXES == 1 )\r
UBaseType_t uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */\r
+ UBaseType_t uxMutexesHeld;\r
#endif\r
\r
#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
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
PRIVILEGED_DATA static volatile TickType_t xTickCount = ( TickType_t ) 0U;\r
PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority = tskIDLE_PRIORITY;\r
PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning = pdFALSE;\r
-PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) pdFALSE;\r
PRIVILEGED_DATA static volatile UBaseType_t uxPendedTicks = ( UBaseType_t ) 0U;\r
PRIVILEGED_DATA static volatile BaseType_t xYieldPending = pdFALSE;\r
PRIVILEGED_DATA static volatile BaseType_t xNumOfOverflows = ( BaseType_t ) 0;\r
PRIVILEGED_DATA static UBaseType_t uxTaskNumber = ( UBaseType_t ) 0U;\r
PRIVILEGED_DATA static volatile TickType_t xNextTaskUnblockTime = portMAX_DELAY;\r
\r
+/* Context switches are held pending while the scheduler is suspended. Also,\r
+interrupts must not manipulate the xStateListItem of a TCB, or any of the\r
+lists the xStateListItem can be referenced from, if the scheduler is suspended.\r
+If an interrupt needs to unblock a task while the scheduler is suspended then it\r
+moves the task's event list item into the xPendingReadyList, ready for the\r
+kernel to move the task from the pending ready list into the real ready list\r
+when the scheduler is unsuspended. The pending ready list itself can only be\r
+accessed from a critical section. */\r
+PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t ) pdFALSE;\r
+\r
#if ( configGENERATE_RUN_TIME_STATS == 1 )\r
\r
PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */\r
*/\r
static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const pcName, UBaseType_t uxPriority, const MemoryRegion_t * const xRegions, const uint16_t usStackDepth ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
\r
+/**\r
+ * Utility task that simply returns pdTRUE if the task referenced by xTask is\r
+ * currently in the Suspended state, or pdFALSE if the task referenced by xTask\r
+ * is in any other state.\r
+ */\r
+static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+\r
/*\r
* Utility to ready all the lists used by the scheduler. This is called\r
* automatically upon the creation of the first task.\r
{\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
{\r
traceTASK_DELAY_UNTIL();\r
\r
- /* We must remove ourselves from the ready list before adding\r
- ourselves to the blocked list as the same list item is used for\r
- both lists. */\r
+ /* Remove the task from the ready list before adding it to the\r
+ blocked list as the same list item is used for both lists. */\r
if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
{\r
/* The current task must be in a ready list, so there is\r
/* 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
\r
#if ( INCLUDE_vTaskSuspend == 1 )\r
\r
- BaseType_t xTaskIsTaskSuspended( const TaskHandle_t xTask )\r
+ static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask )\r
{\r
BaseType_t xReturn = pdFALSE;\r
const TCB_t * const pxTCB = ( TCB_t * ) xTask;\r
\r
+ /* Accesses xPendingReadyList so must be called from a critical\r
+ section. */\r
+\r
/* It does not make sense to check if the calling task is suspended. */\r
configASSERT( xTask );\r
\r
- /* Is the task we are attempting to resume actually in the\r
- suspended list? */\r
+ /* Is the task being resumed actually in the suspended list? */\r
if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
{\r
/* 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\r
- Suspended state? It is possible to be in the suspended\r
- list because it is blocked on a task with no timeout\r
- specified. */\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
xReturn = pdTRUE;\r
{\r
taskENTER_CRITICAL();\r
{\r
- if( xTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
+ if( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
{\r
traceTASK_RESUME( pxTCB );\r
\r
\r
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
{\r
- if( xTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
+ if( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
{\r
traceTASK_RESUME_FROM_ISR( pxTCB );\r
\r
+ /* Check the ready lists can be accessed. */\r
if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
{\r
+ /* Ready lists can be accessed so move the task from the\r
+ suspended list to the ready list directly. */\r
if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
{\r
xYieldRequired = pdTRUE;\r
}\r
else\r
{\r
- /* We cannot access the delayed or ready lists, so will hold this\r
- task pending until the scheduler is resumed, at which point a\r
- yield will be performed if necessary. */\r
+ /* The delayed or ready lists cannot be accessed so the task\r
+ is held in the pending ready list until the scheduler is\r
+ unsuspended. */\r
vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) );\r
}\r
}\r
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
\r
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
- xReturn = xTickCount;\r
+ {\r
+ xReturn = xTickCount;\r
+ }\r
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
\r
return xReturn;\r
\r
configASSERT( pxEventList );\r
\r
- /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE\r
- SCHEDULER SUSPENDED. */\r
+ /* THIS FUNCTION MUST BE CALLED WITH EITHER INTERRUPTS DISABLED OR THE\r
+ SCHEDULER SUSPENDED AND THE QUEUE BEING ACCESSED LOCKED. */\r
\r
/* Place the event list item of the TCB in the appropriate event list.\r
This is placed in the list in priority order so the highest priority task\r
- is the first to be woken by the event. */\r
+ is the first to be woken by the event. The queue that contains the event\r
+ list is locked, preventing simultaneous access from interrupts. */\r
vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
\r
- /* We must remove ourselves from the ready list before adding ourselves\r
- to the blocked list as the same list item is used for both lists. We have\r
- exclusive access to the ready lists as the scheduler is locked. */\r
+ /* The task must be removed from from the ready list before it is added to\r
+ the blocked list as the same list item is used for both lists. Exclusive\r
+ access to the ready lists guaranteed because the scheduler is locked. */\r
if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
{\r
/* The current task must be in a ready list, so there is no need to\r
{\r
if( xTicksToWait == portMAX_DELAY )\r
{\r
- /* Add ourselves to the suspended task list instead of a delayed task\r
- list to ensure we are not woken by a timing event. We will block\r
- indefinitely. */\r
+ /* Add the task to the suspended task list instead of a delayed task\r
+ list to ensure the task is not woken by a timing event. It will\r
+ block indefinitely. */\r
vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
}\r
else\r
{\r
- /* Calculate the time at which the task should be woken if the event does\r
- not occur. This may overflow but this doesn't matter. */\r
+ /* Calculate the time at which the task should be woken if the event\r
+ does not occur. This may overflow but this doesn't matter, the\r
+ scheduler will handle it. */\r
xTimeToWake = xTickCount + xTicksToWait;\r
prvAddCurrentTaskToDelayedList( xTimeToWake );\r
}\r
#else /* INCLUDE_vTaskSuspend */\r
{\r
/* Calculate the time at which the task should be woken if the event does\r
- not occur. This may overflow but this doesn't matter. */\r
+ not occur. This may overflow but this doesn't matter, the scheduler\r
+ will handle it. */\r
xTimeToWake = xTickCount + xTicksToWait;\r
prvAddCurrentTaskToDelayedList( xTimeToWake );\r
}\r
\r
configASSERT( pxEventList );\r
\r
- /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE\r
- SCHEDULER SUSPENDED. */\r
+ /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by\r
+ the event groups implementation. */\r
+ configASSERT( uxSchedulerSuspended != 0 );\r
\r
- /* Store the item value in the event list item. */\r
+ /* Store the item value in the event list item. It is safe to access the\r
+ event list item here as interrupts won't access the event list item of a\r
+ task that is not in the Blocked state. */\r
listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );\r
\r
/* Place the event list item of the TCB at the end of the appropriate event\r
- list. */\r
+ list. It is safe to access the event list here because it is part of an\r
+ event group implementation - and interrupts don't access event groups\r
+ directly (instead they access them indirectly by pending function calls to\r
+ the task level). */\r
vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
\r
/* The task must be removed from the ready list before it is added to the\r
}\r
else\r
{\r
- /* Calculate the time at which the task should be woken if the event does\r
- not occur. This may overflow but this doesn't matter. */\r
+ /* Calculate the time at which the task should be woken if the event\r
+ does not occur. This may overflow but this doesn't matter, the\r
+ kernel will manage it correctly. */\r
xTimeToWake = xTickCount + xTicksToWait;\r
prvAddCurrentTaskToDelayedList( xTimeToWake );\r
}\r
#else /* INCLUDE_vTaskSuspend */\r
{\r
/* Calculate the time at which the task should be woken if the event does\r
- not occur. This may overflow but this doesn't matter. */\r
+ not occur. This may overflow but this doesn't matter, the kernel\r
+ will manage it correctly. */\r
xTimeToWake = xTickCount + xTicksToWait;\r
prvAddCurrentTaskToDelayedList( xTimeToWake );\r
}\r
TCB_t *pxUnblockedTCB;\r
BaseType_t xReturn;\r
\r
- /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE\r
- SCHEDULER SUSPENDED. It can also be called from within an ISR. */\r
+ /* THIS FUNCTION MUST BE CALLED FROM A CRITICAL SECTION. It can also be\r
+ called from a critical section within an ISR. */\r
\r
- /* The event list is sorted in priority order, so we can remove the\r
- first in the list, remove the TCB from the delayed list, and add\r
- it to the ready list.\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
+ 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
get called - the lock count on the queue will get modified instead. This\r
- means we can always expect exclusive access to the event list here.\r
+ means exclusive access to the event list is guaranteed here.\r
\r
This function assumes that a check has already been made to ensure that\r
pxEventList is not empty. */\r
\r
if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority )\r
{\r
- /* Return true if the task removed from the event list has\r
- a higher priority than the calling task. This allows\r
- the calling task to know if it should force a context\r
- switch now. */\r
+ /* Return true if the task removed from the event list has a higher\r
+ priority than the calling task. This allows the calling task to know if\r
+ it should force a context switch now. */\r
xReturn = pdTRUE;\r
\r
/* Mark that a yield is pending in case the user is not using the\r
TCB_t *pxUnblockedTCB;\r
BaseType_t xReturn;\r
\r
- /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE\r
- SCHEDULER SUSPENDED. It can also be called from within an ISR. */\r
+ /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED. It is used by\r
+ the event flags implementation. */\r
+ configASSERT( uxSchedulerSuspended != pdFALSE );\r
\r
/* Store the new item value in the event list. */\r
listSET_LIST_ITEM_VALUE( pxEventListItem, xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );\r
\r
- /* Remove the TCB from the delayed list, and add it to the ready list. */\r
-\r
+ /* Remove the event list form the event flag. Interrupts do not access\r
+ event flags. */\r
pxUnblockedTCB = ( TCB_t * ) listGET_LIST_ITEM_OWNER( pxEventListItem );\r
configASSERT( pxUnblockedTCB );\r
( void ) uxListRemove( pxEventListItem );\r
\r
- if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
- {\r
- ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
- prvAddTaskToReadyList( pxUnblockedTCB );\r
- }\r
- else\r
- {\r
- /* Cannot access the delayed or ready lists, so will hold this task\r
- pending until the scheduler is resumed. */\r
- vListInsertEnd( &( xPendingReadyList ), pxEventListItem );\r
- }\r
+ /* Remove the task from the delayed list and add it to the ready list. The\r
+ scheduler is suspended so interrupts will not be accessing the ready\r
+ lists. */\r
+ ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
+ prvAddTaskToReadyList( pxUnblockedTCB );\r
\r
if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority )\r
{\r
#if ( configUSE_MUTEXES == 1 )\r
{\r
pxTCB->uxBasePriority = uxPriority;\r
+ pxTCB->uxMutexesHeld = 0;\r
}\r
#endif /* configUSE_MUTEXES */\r
\r
while( uxTasksDeleted > ( UBaseType_t ) 0U )\r
{\r
vTaskSuspendAll();\r
+ {\r
xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );\r
+ }\r
( void ) xTaskResumeAll();\r
\r
if( xListIsEmpty == pdFALSE )\r
pxTaskStatusArray[ uxTask ].eCurrentState = eState;\r
pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority;\r
\r
+ #if ( INCLUDE_vTaskSuspend == 1 )\r
+ {\r
+ /* If the task is in the suspended list then there is a chance\r
+ it is actually just blocked indefinitely - so really it should\r
+ be reported as being in the Blocked state. */\r
+ if( eState == eSuspended )\r
+ {\r
+ if( listLIST_ITEM_CONTAINER( &( pxNextTCB->xEventListItem ) ) != NULL )\r
+ {\r
+ pxTaskStatusArray[ uxTask ].eCurrentState = eBlocked;\r
+ }\r
+ }\r
+ }\r
+ #endif /* INCLUDE_vTaskSuspend */\r
+\r
#if ( configUSE_MUTEXES == 1 )\r
{\r
pxTaskStatusArray[ uxTask ].uxBasePriority = pxNextTCB->uxBasePriority;\r
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
\r
#if ( configUSE_MUTEXES == 1 )\r
\r
- void vTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder )\r
+ BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder )\r
{\r
TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder;\r
+ BaseType_t xReturn = pdFALSE;\r
\r
if( pxMutexHolder != NULL )\r
{\r
if( pxTCB->uxPriority != pxTCB->uxBasePriority )\r
{\r
- /* We must be the running task to be able to give the mutex back.\r
- Remove ourselves from the ready list we currently appear in. */\r
- if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+ /* Only disinherit if no other mutexes are held. */\r
+ if( pxTCB->uxMutexesHeld == 0 )\r
{\r
- taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
+ /* The holding task must be the running task to be able to give\r
+ the mutex back. Remove the holding task from the ready list. */\r
+ if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+ {\r
+ taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
\r
- /* Disinherit the priority before adding the task into the new\r
- ready list. */\r
- traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority );\r
- pxTCB->uxPriority = pxTCB->uxBasePriority;\r
+ /* Disinherit the priority before adding the task into the new\r
+ ready list. */\r
+ traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority );\r
+ pxTCB->uxPriority = pxTCB->uxBasePriority;\r
\r
- /* Only reset the event list item value if the value is not\r
- being used for anything else. */\r
- if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL )\r
- {\r
+ /* Reset the event list item value. It cannot be in use for\r
+ any other purpose if this task is running, and it must be\r
+ running to give back the mutex. */\r
listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+ prvAddTaskToReadyList( pxTCB );\r
+\r
+ /* Return true to indicate that a context switch is required.\r
+ This is only actually required in the corner case whereby\r
+ multiple mutexes were held and the mutexes were given back\r
+ in an order different to that in which they were taken. */\r
+ xReturn = pdTRUE;\r
}\r
else\r
{\r
mtCOVERAGE_TEST_MARKER();\r
}\r
- prvAddTaskToReadyList( pxTCB );\r
}\r
else\r
{\r
{\r
mtCOVERAGE_TEST_MARKER();\r
}\r
+\r
+ return xReturn;\r
}\r
\r
#endif /* configUSE_MUTEXES */\r
if( xSchedulerRunning != pdFALSE )\r
{\r
( pxCurrentTCB->uxCriticalNesting )++;\r
+\r
+ /* This is not the interrupt safe version of the enter critical\r
+ function so assert() if it is being called from an interrupt\r
+ context. Only API functions that end in "FromISR" can be used in an\r
+ interrupt. Only assert if the critical nesting count is 1 to\r
+ protect against recursive calls if the assert function also uses a\r
+ critical section. */\r
+ if( pxCurrentTCB->uxCriticalNesting == 1 )\r
+ {\r
+ portASSERT_IF_IN_ISR();\r
+ }\r
+\r
}\r
else\r
{\r
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
}\r
/*-----------------------------------------------------------*/\r
\r
+void vTaskIncrementMutexHeldCount( void )\r
+{\r
+ /* If xSemaphoreCreateMutex() is called before any tasks have been created\r
+ then pxCurrentTCB will be NULL. */\r
+ if( pxCurrentTCB != NULL )\r
+ {\r
+ ( pxCurrentTCB->uxMutexesHeld )++;\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTaskDecrementMutexHeldCount( void )\r
+{\r
+ /* If xSemaphoreCreateMutex() is called before any tasks have been created\r
+ then pxCurrentTCB will be NULL. */\r
+ if( pxCurrentTCB != NULL )\r
+ {\r
+ configASSERT( pxCurrentTCB->uxMutexesHeld );\r
+ ( pxCurrentTCB->uxMutexesHeld )--;\r
+ }\r
+}\r
+\r
#ifdef FREERTOS_MODULE_TEST\r
#include "tasks_test_access_functions.h"\r
#endif\r