|
|
|
@ -177,7 +177,7 @@ PRIVILEGED_DATA static portTickType xNextTaskUnblockTime = ( portTickType )
|
|
|
|
|
* The value used to fill the stack of a task when the task is created. This
|
|
|
|
|
* is used purely for checking the high water mark for tasks.
|
|
|
|
|
*/
|
|
|
|
|
#define tskSTACK_FILL_BYTE ( 0xa5 )
|
|
|
|
|
#define tskSTACK_FILL_BYTE ( 0xa5U )
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Macros used by vListTask to indicate which state a task is in.
|
|
|
|
@ -197,7 +197,7 @@ PRIVILEGED_DATA static portTickType xNextTaskUnblockTime = ( portTickType )
|
|
|
|
|
PRIVILEGED_DATA static signed char *pcTraceBufferStart;
|
|
|
|
|
PRIVILEGED_DATA static signed char *pcTraceBufferEnd;
|
|
|
|
|
PRIVILEGED_DATA static signed portBASE_TYPE xTracing = pdFALSE;
|
|
|
|
|
static unsigned portBASE_TYPE uxPreviousTask = 255;
|
|
|
|
|
static unsigned portBASE_TYPE uxPreviousTask = 255U;
|
|
|
|
|
PRIVILEGED_DATA static char pcStatusString[ 50 ];
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
@ -249,13 +249,11 @@ PRIVILEGED_DATA static portTickType xNextTaskUnblockTime = ( portTickType )
|
|
|
|
|
* executing task has been rescheduled.
|
|
|
|
|
*/
|
|
|
|
|
#define prvAddTaskToReadyQueue( pxTCB ) \
|
|
|
|
|
{ \
|
|
|
|
|
if( pxTCB->uxPriority > uxTopReadyPriority ) \
|
|
|
|
|
if( ( pxTCB )->uxPriority > uxTopReadyPriority ) \
|
|
|
|
|
{ \
|
|
|
|
|
uxTopReadyPriority = pxTCB->uxPriority; \
|
|
|
|
|
uxTopReadyPriority = ( pxTCB )->uxPriority; \
|
|
|
|
|
} \
|
|
|
|
|
vListInsertEnd( ( xList * ) &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ); \
|
|
|
|
|
}
|
|
|
|
|
vListInsertEnd( ( xList * ) &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) )
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -326,8 +324,10 @@ portTickType xItemValue; \
|
|
|
|
|
* task should be used in place of the parameter. This macro simply checks to
|
|
|
|
|
* see if the parameter is NULL and returns a pointer to the appropriate TCB.
|
|
|
|
|
*/
|
|
|
|
|
#define prvGetTCBFromHandle( pxHandle ) ( ( pxHandle == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) pxHandle )
|
|
|
|
|
#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) ( pxHandle ) )
|
|
|
|
|
|
|
|
|
|
/* Callback function prototypes. --------------------------*/
|
|
|
|
|
extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName );
|
|
|
|
|
|
|
|
|
|
/* File private functions. --------------------------------*/
|
|
|
|
|
|
|
|
|
@ -456,7 +456,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
required by the port. */
|
|
|
|
|
#if( portSTACK_GROWTH < 0 )
|
|
|
|
|
{
|
|
|
|
|
pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );
|
|
|
|
|
pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( unsigned short ) 1 );
|
|
|
|
|
pxTopOfStack = ( portSTACK_TYPE * ) ( ( ( unsigned long ) pxTopOfStack ) & ( ( unsigned long ) ~portBYTE_ALIGNMENT_MASK ) );
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
@ -497,7 +497,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
|
|
|
|
|
/* We are going to manipulate the task queues to add this task to a
|
|
|
|
|
ready list, so must make sure no interrupts occur. */
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
uxCurrentNumberOfTasks++;
|
|
|
|
|
if( pxCurrentTCB == NULL )
|
|
|
|
@ -548,7 +548,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
xReturn = pdPASS;
|
|
|
|
|
traceTASK_CREATE( pxNewTCB );
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -579,7 +579,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
{
|
|
|
|
|
tskTCB *pxTCB;
|
|
|
|
|
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
/* Ensure a yield is performed if the current task is being
|
|
|
|
|
deleted. */
|
|
|
|
@ -616,7 +616,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
|
|
|
|
|
traceTASK_DELETE( pxTCB );
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
/* Force a reschedule if we have just deleted the current task. */
|
|
|
|
|
if( xSchedulerRunning != pdFALSE )
|
|
|
|
@ -754,14 +754,14 @@ tskTCB * pxNewTCB;
|
|
|
|
|
tskTCB *pxTCB;
|
|
|
|
|
unsigned portBASE_TYPE uxReturn;
|
|
|
|
|
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
/* If null is passed in here then we are changing the
|
|
|
|
|
priority of the calling function. */
|
|
|
|
|
pxTCB = prvGetTCBFromHandle( pxTask );
|
|
|
|
|
uxReturn = pxTCB->uxPriority;
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
return uxReturn;
|
|
|
|
|
}
|
|
|
|
@ -774,15 +774,16 @@ tskTCB * pxNewTCB;
|
|
|
|
|
void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority )
|
|
|
|
|
{
|
|
|
|
|
tskTCB *pxTCB;
|
|
|
|
|
unsigned portBASE_TYPE uxCurrentPriority, xYieldRequired = pdFALSE;
|
|
|
|
|
unsigned portBASE_TYPE uxCurrentPriority;
|
|
|
|
|
portBASE_TYPE xYieldRequired = pdFALSE;
|
|
|
|
|
|
|
|
|
|
/* Ensure the new priority is valid. */
|
|
|
|
|
if( uxNewPriority >= configMAX_PRIORITIES )
|
|
|
|
|
{
|
|
|
|
|
uxNewPriority = configMAX_PRIORITIES - 1;
|
|
|
|
|
uxNewPriority = configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
if( pxTask == pxCurrentTCB )
|
|
|
|
|
{
|
|
|
|
@ -868,7 +869,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
@ -880,7 +881,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
{
|
|
|
|
|
tskTCB *pxTCB;
|
|
|
|
|
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
/* Ensure a yield is performed if the current task is being
|
|
|
|
|
suspended. */
|
|
|
|
@ -905,7 +906,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
|
|
|
|
|
vListInsertEnd( ( xList * ) &xSuspendedTaskList, &( pxTCB->xGenericListItem ) );
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
if( ( void * ) pxTaskToSuspend == NULL )
|
|
|
|
|
{
|
|
|
|
@ -919,7 +920,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
/* The scheduler is not running, but the task that was pointed
|
|
|
|
|
to by pxCurrentTCB has just been suspended and pxCurrentTCB
|
|
|
|
|
must be adjusted to point to a different task. */
|
|
|
|
|
if( uxCurrentNumberOfTasks == 1 )
|
|
|
|
|
if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1U )
|
|
|
|
|
{
|
|
|
|
|
/* No other tasks are defined, so set pxCurrentTCB back to
|
|
|
|
|
NULL so when the next task is created pxCurrentTCB will
|
|
|
|
@ -983,7 +984,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
currently executing task. */
|
|
|
|
|
if( ( pxTCB != NULL ) && ( pxTCB != pxCurrentTCB ) )
|
|
|
|
|
{
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
if( xTaskIsTaskSuspended( pxTCB ) == pdTRUE )
|
|
|
|
|
{
|
|
|
|
@ -1003,7 +1004,7 @@ tskTCB * pxNewTCB;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1123,7 +1124,7 @@ signed portBASE_TYPE xAlreadyYielded = pdFALSE;
|
|
|
|
|
removed task will have been added to the xPendingReadyList. Once the
|
|
|
|
|
scheduler has been resumed it is safe to move all the pending ready
|
|
|
|
|
tasks from this list into their appropriate ready list. */
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
--uxSchedulerSuspended;
|
|
|
|
|
|
|
|
|
@ -1180,7 +1181,7 @@ signed portBASE_TYPE xAlreadyYielded = pdFALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
return xAlreadyYielded;
|
|
|
|
|
}
|
|
|
|
@ -1201,11 +1202,11 @@ portTickType xTaskGetTickCount( void )
|
|
|
|
|
portTickType xTicks;
|
|
|
|
|
|
|
|
|
|
/* Critical section required if running on a 16 bit processor. */
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
xTicks = xTickCount;
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
return xTicks;
|
|
|
|
|
}
|
|
|
|
@ -1239,10 +1240,10 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
|
|
|
|
|
/* Run through all the lists that could potentially contain a TCB and
|
|
|
|
|
report the task name, state and stack high water mark. */
|
|
|
|
|
|
|
|
|
|
pcWriteBuffer[ 0 ] = ( signed char ) 0x00;
|
|
|
|
|
*pcWriteBuffer = ( signed char ) 0x00;
|
|
|
|
|
strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" );
|
|
|
|
|
|
|
|
|
|
uxQueue = uxTopUsedPriority + 1;
|
|
|
|
|
uxQueue = uxTopUsedPriority + ( unsigned portBASE_TYPE ) 1U;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
@ -1314,10 +1315,10 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
|
|
|
|
|
generating a table of run timer percentages in the provided
|
|
|
|
|
buffer. */
|
|
|
|
|
|
|
|
|
|
pcWriteBuffer[ 0 ] = ( signed char ) 0x00;
|
|
|
|
|
*pcWriteBuffer = ( signed char ) 0x00;
|
|
|
|
|
strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" );
|
|
|
|
|
|
|
|
|
|
uxQueue = uxTopUsedPriority + 1;
|
|
|
|
|
uxQueue = uxTopUsedPriority + ( unsigned portBASE_TYPE ) 1U;
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
@ -1367,14 +1368,14 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
|
|
|
|
|
|
|
|
|
|
void vTaskStartTrace( signed char * pcBuffer, unsigned long ulBufferSize )
|
|
|
|
|
{
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
pcTraceBuffer = ( signed char * )pcBuffer;
|
|
|
|
|
pcTraceBufferStart = pcBuffer;
|
|
|
|
|
pcTraceBufferEnd = pcBuffer + ( ulBufferSize - tskSIZE_OF_EACH_TRACE_LINE );
|
|
|
|
|
xTracing = pdTRUE;
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
@ -1386,9 +1387,9 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
|
|
|
|
|
{
|
|
|
|
|
unsigned long ulBufferLength;
|
|
|
|
|
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
xTracing = pdFALSE;
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
ulBufferLength = ( unsigned long ) ( pcTraceBuffer - pcTraceBufferStart );
|
|
|
|
|
|
|
|
|
@ -1551,9 +1552,9 @@ void vTaskIncrementTick( void )
|
|
|
|
|
|
|
|
|
|
/* Save the hook function in the TCB. A critical section is required as
|
|
|
|
|
the value can be accessed from an interrupt. */
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
xTCB->pxTaskTag = pxTagValue;
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
@ -1578,9 +1579,9 @@ void vTaskIncrementTick( void )
|
|
|
|
|
|
|
|
|
|
/* Save the hook function in the TCB. A critical section is required as
|
|
|
|
|
the value can be accessed from an interrupt. */
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
xReturn = xTCB->pxTaskTag;
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
return xReturn;
|
|
|
|
|
}
|
|
|
|
@ -1627,9 +1628,9 @@ void vTaskSwitchContext( void )
|
|
|
|
|
/* The scheduler is currently suspended - do not allow a context
|
|
|
|
|
switch. */
|
|
|
|
|
xMissedYield = pdTRUE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
traceTASK_SWITCHED_OUT();
|
|
|
|
|
|
|
|
|
|
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
|
|
|
@ -1667,6 +1668,7 @@ void vTaskSwitchContext( void )
|
|
|
|
|
|
|
|
|
|
traceTASK_SWITCHED_IN();
|
|
|
|
|
vWriteTraceToBuffer();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*-----------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
@ -1777,7 +1779,7 @@ portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType
|
|
|
|
|
{
|
|
|
|
|
portBASE_TYPE xReturn;
|
|
|
|
|
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
#if ( INCLUDE_vTaskSuspend == 1 )
|
|
|
|
|
/* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is
|
|
|
|
@ -1810,7 +1812,7 @@ portBASE_TYPE xReturn;
|
|
|
|
|
xReturn = pdTRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
return xReturn;
|
|
|
|
|
}
|
|
|
|
@ -1906,13 +1908,13 @@ static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const
|
|
|
|
|
strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned short ) configMAX_TASK_NAME_LEN );
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
pxTCB->pcTaskName[ ( unsigned short ) configMAX_TASK_NAME_LEN - ( unsigned short ) 1 ] = '\0';
|
|
|
|
|
pxTCB->pcTaskName[ ( unsigned short ) configMAX_TASK_NAME_LEN - ( unsigned short ) 1 ] = ( signed char ) '\0';
|
|
|
|
|
|
|
|
|
|
/* This is used as an array index so must ensure it's not too large. First
|
|
|
|
|
remove the privilege bit if one is present. */
|
|
|
|
|
if( uxPriority >= configMAX_PRIORITIES )
|
|
|
|
|
{
|
|
|
|
|
uxPriority = configMAX_PRIORITIES - 1;
|
|
|
|
|
uxPriority = configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pxTCB->uxPriority = uxPriority;
|
|
|
|
@ -1987,7 +1989,7 @@ static void prvInitialiseTaskLists( void )
|
|
|
|
|
{
|
|
|
|
|
unsigned portBASE_TYPE uxPriority;
|
|
|
|
|
|
|
|
|
|
for( uxPriority = 0; uxPriority < configMAX_PRIORITIES; uxPriority++ )
|
|
|
|
|
for( uxPriority = ( unsigned portBASE_TYPE ) 0U; uxPriority < configMAX_PRIORITIES; uxPriority++ )
|
|
|
|
|
{
|
|
|
|
|
vListInitialise( ( xList * ) &( pxReadyTasksLists[ uxPriority ] ) );
|
|
|
|
|
}
|
|
|
|
@ -2033,14 +2035,14 @@ static void prvCheckTasksWaitingTermination( void )
|
|
|
|
|
{
|
|
|
|
|
tskTCB *pxTCB;
|
|
|
|
|
|
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
|
{
|
|
|
|
|
pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xTasksWaitingTermination ) );
|
|
|
|
|
vListRemove( &( pxTCB->xGenericListItem ) );
|
|
|
|
|
--uxCurrentNumberOfTasks;
|
|
|
|
|
--uxTasksDeleted;
|
|
|
|
|
}
|
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
prvDeleteTCB( pxTCB );
|
|
|
|
|
}
|
|
|
|
|