vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );\r
vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );\r
\r
+ traceQUEUE_CREATE( pxNewQueue );\r
+\r
return pxNewQueue;\r
}\r
else\r
{\r
+ traceQUEUE_CREATE_FAILED();\r
vPortFree( pxNewQueue );\r
}\r
}\r
\r
/* Start with the semaphore in the expected state. */\r
xQueueGenericSend( pxNewQueue, NULL, 0, queueSEND_TO_BACK );\r
+\r
+ traceCREATE_MUTEX( pxNewQueue );\r
+ }\r
+ else\r
+ {\r
+ traceCREATE_MUTEX_FAILED();\r
}\r
\r
return pxNewQueue;\r
}\r
\r
xReturn = pdPASS;\r
+\r
+ traceGIVE_MUTEX_RECURSIVE( pxMutex );\r
}\r
else\r
{\r
/* We cannot give the mutex because we are not the holder. */\r
xReturn = pdFAIL;\r
+\r
+ traceGIVE_MUTEX_RECURSIVE_FAILED( pxMutex );\r
}\r
\r
return xReturn;\r
}\r
}\r
\r
+ traceTAKE_MUTEX_RECURSIVE( pxMutex );\r
+\r
return xReturn;\r
}\r
\r
if( pxHandle != NULL )\r
{\r
pxHandle->uxMessagesWaiting = uxInitialCount;\r
+\r
+ traceCREATE_COUNTING_SEMAPHORE();\r
+ }\r
+ else\r
+ {\r
+ traceCREATE_COUNTING_SEMAPHORE_FAILED();\r
}\r
\r
return pxHandle;\r
list. */\r
taskENTER_CRITICAL();\r
{\r
+ traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
+\r
/* We can safely unlock the queue and scheduler here as\r
interrupts are disabled. We must not yield with anything\r
locked, but we can yield from within a critical section.\r
{\r
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
{\r
+ traceQUEUE_SEND( pxQueue );\r
+\r
/* There is room in the queue, copy the data into the queue. */ \r
prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
xReturn = pdPASS;\r
{\r
xReturn = queueERRONEOUS_UNBLOCK;\r
}\r
+ else\r
+ {\r
+ traceQUEUE_SEND_FAILED( pxQueue );\r
+ }\r
+ }\r
+ else\r
+ {\r
+ traceQUEUE_SEND_FAILED( pxQueue );\r
}\r
}\r
}\r
posting? */\r
if( xTicksToWait > ( portTickType ) 0 )\r
{\r
+ traceBLOCKING_ON_QUEUE_SEND( pxQueue );\r
+\r
/* We are going to place ourselves on the xTasksWaitingToSend \r
event list, and will get woken should the delay expire, or \r
space become available on the queue. */\r
\r
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
{\r
+ traceQUEUE_SEND( pxQueue );\r
+\r
/* There is room in the queue, copy the data into the queue. */ \r
prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
xReturn = pdPASS;\r
this task unblocking and actually executing. */\r
xReturn = queueERRONEOUS_UNBLOCK;\r
}\r
+ else\r
+ {\r
+ traceQUEUE_SEND_FAILED( pxQueue );\r
+ }\r
+ }\r
+ else\r
+ {\r
+ traceQUEUE_SEND_FAILED( pxQueue );\r
}\r
}\r
}\r
leave with nothing? */ \r
if( xTicksToWait > ( portTickType ) 0 )\r
{\r
+ traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );\r
+\r
#if ( configUSE_MUTEXES == 1 )\r
{\r
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
\r
if( xJustPeeking == pdFALSE )\r
{\r
+ traceQUEUE_RECEIVE( pxQueue );\r
+\r
/* We are actually removing data. */\r
--( pxQueue->uxMessagesWaiting );\r
\r
}\r
else\r
{\r
+ traceQUEUE_PEEK( pxQueue );\r
+\r
/* We are not removing the data, so reset our read\r
pointer. */\r
pxQueue->pcReadFrom = pcOriginalReadPosition;\r
{\r
xReturn = queueERRONEOUS_UNBLOCK;\r
}\r
+ else\r
+ {\r
+ traceQUEUE_RECEIVE_FAILED( pxQueue );\r
+ }\r
+ }\r
+ else\r
+ {\r
+ traceQUEUE_RECEIVE_FAILED( pxQueue );\r
}\r
}\r
\r
by this post). */\r
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )\r
{\r
+ traceQUEUE_SEND_FROM_ISR( pxQueue );\r
+\r
prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
\r
/* If the queue is locked we do not alter the event list. This will\r
++( pxQueue->xTxLock );\r
}\r
}\r
+ else\r
+ {\r
+ traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );\r
+ }\r
\r
return xTaskPreviouslyWoken;\r
}\r
leave with nothing? */ \r
if( xTicksToWait > ( portTickType ) 0 )\r
{\r
+ traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );\r
+\r
#if ( configUSE_MUTEXES == 1 )\r
{\r
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )\r
\r
if( xJustPeeking == pdFALSE )\r
{\r
+ traceQUEUE_RECEIVE( pxQueue );\r
+\r
/* We are actually removing data. */\r
--( pxQueue->uxMessagesWaiting );\r
\r
}\r
else\r
{\r
+ traceQUEUE_PEEK( pxQueue );\r
+\r
/* We are not removing the data, so reset our read\r
pointer. */\r
pxQueue->pcReadFrom = pcOriginalReadPosition;\r
{\r
xReturn = queueERRONEOUS_UNBLOCK;\r
}\r
+ else\r
+ {\r
+ traceQUEUE_RECEIVE_FAILED( pxQueue );\r
+ }\r
+ }\r
+ else\r
+ {\r
+ traceQUEUE_RECEIVE_FAILED( pxQueue );\r
}\r
}\r
} while( xReturn == queueERRONEOUS_UNBLOCK );\r
/* We cannot block from an ISR, so check there is data available. */\r
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
{\r
+ traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
+\r
prvCopyDataFromQueue( pxQueue, pvBuffer );\r
--( pxQueue->uxMessagesWaiting );\r
\r
else\r
{\r
xReturn = pdFAIL;\r
+ traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue );\r
}\r
\r
return xReturn;\r
\r
void vQueueDelete( xQueueHandle pxQueue )\r
{\r
+ traceQUEUE_DELETE( pxQueue );\r
+\r
vPortFree( pxQueue->pcHead );\r
vPortFree( pxQueue );\r
}\r
* This function determines the 'high water mark' of the task stack by\r
* determining how much of the stack remains at the original preset value.\r
*/\r
-#if ( configUSE_TRACE_FACILITY == 1 )\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxGetStackHighWaterMark == 1 ) )\r
\r
unsigned portSHORT usTaskCheckFreeStackSpace( const unsigned portCHAR * pucStackByte );\r
\r
prvAddTaskToReadyQueue( pxNewTCB );\r
\r
xReturn = pdPASS;\r
+ traceTASK_CREATE( pxNewTCB );\r
}\r
portEXIT_CRITICAL();\r
}\r
else\r
{\r
xReturn = errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY;\r
+ traceTASK_CREATE_FAILED( pxNewTCB );\r
}\r
\r
if( xReturn == pdPASS )\r
/* If null is passed in here then we are deleting ourselves. */\r
pxTCB = prvGetTCBFromHandle( pxTaskToDelete );\r
\r
+ traceTASK_DELETE( pxTCB );\r
+\r
/* Remove task from the ready list and place in the termination list.\r
This will stop the task from be scheduled. The idle task will check\r
the termination list and free up any memory allocated by the\r
\r
if( xShouldDelay )\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
{\r
vTaskSuspendAll();\r
{\r
+ traceTASK_DELAY();\r
+\r
/* A task that is removed from the event list while the\r
scheduler is suspended will not get placed in the ready\r
list or removed from the blocked list until the scheduler\r
priority of the calling function. */\r
pxTCB = prvGetTCBFromHandle( pxTask );\r
\r
+ traceTASK_PRIORITY_SET( pxTask, uxNewPriority );\r
+\r
#if ( configUSE_MUTEXES == 1 )\r
{\r
uxCurrentPriority = pxTCB->uxBasePriority;\r
/* If null is passed in here then we are suspending ourselves. */\r
pxTCB = prvGetTCBFromHandle( pxTaskToSuspend );\r
\r
+ traceTASK_SUSPEND( pxTaskToSuspend );\r
+\r
/* Remove task from the ready/delayed list and place in the suspended list. */\r
vListRemove( &( pxTCB->xGenericListItem ) );\r
\r
{\r
if( prvIsTaskSuspended( pxTCB ) == pdTRUE )\r
{\r
+ traceTASK_RESUME( pxTCB );\r
+\r
/* As we are in a critical section we can access the ready\r
lists even if the scheduler is suspended. */\r
vListRemove( &( pxTCB->xGenericListItem ) );\r
\r
if( prvIsTaskSuspended( pxTCB ) == pdTRUE )\r
{\r
+ traceTASK_RESUME_FROM_ISR( pxTCB );\r
+\r
if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
{\r
xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );\r
}\r
}\r
#endif\r
+\r
+ traceTASK_INCREMENT_TICK( xTickCount );\r
}\r
/*-----------------------------------------------------------*/\r
\r
/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the\r
same priority get an equal share of the processor time. */\r
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );\r
+\r
+ traceTASK_SWITCHED_IN();\r
vWriteTraceToBuffer();\r
}\r
/*-----------------------------------------------------------*/\r
#endif\r
/*-----------------------------------------------------------*/\r
\r
-#if ( configUSE_TRACE_FACILITY == 1 )\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxGetStackHighWaterMark == 1 ) )\r
unsigned portSHORT usTaskCheckFreeStackSpace( const unsigned portCHAR * pucStackByte )\r
{\r
register unsigned portSHORT usCount = 0;\r
#endif\r
/*-----------------------------------------------------------*/\r
\r
-\r
+#if ( INCLUDE_uxGetStackHighWaterMark == 1 )\r
+ unsigned portBASE_TYPE uxGetStackHighWaterMark( void )\r
+ {\r
+ return usTaskCheckFreeStackSpace( pxCurrentTCB->pxStack );\r
+ }\r
+#endif\r
+/*-----------------------------------------------------------*/\r
\r
#if ( ( INCLUDE_vTaskDelete == 1 ) || ( INCLUDE_vTaskCleanUpResources == 1 ) )\r
\r