@ -73,7 +73,6 @@
*/
/* Standard includes. */
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
@ -88,7 +87,19 @@ task.h is included from an application file. */
# include "timers.h"
# include "StackMacros.h"
# undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
/* Lint e961 and e750 are suppressed as a MISRA exception justified because the
MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
header files above , but not in this file , in order to generate the correct
privileged Vs unprivileged linkage and placement . */
# undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
# if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configINCLUDE_STATS_FORMATTING_FUNCTIONS == 1 ) )
/* At the bottom of this file are two optional functions that can be used
to generate human readable text from the raw data generated by the
xTaskGetSystemState ( ) function . Note the formatting functions are provided
for convenience only , and are NOT considered part of the kernel . */
# include <stdio.h>
# endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configINCLUDE_STATS_FORMATTING_FUNCTIONS == 1 ) ) */
/* Sanity check the configuration. */
# if configUSE_TICKLESS_IDLE != 0
@ -168,6 +179,9 @@ typedef struct tskTaskControlBlock
# define static
# endif
/*lint -e956 A manual analysis and inspection has been used to determine which
static variables must be declared volatile . */
PRIVILEGED_DATA tskTCB * volatile pxCurrentTCB = NULL ;
/* Lists for ready and blocked tasks. --------------------*/
@ -204,10 +218,10 @@ PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxTopReadyPriority = ts
PRIVILEGED_DATA static volatile signed portBASE_TYPE xSchedulerRunning = pdFALSE ;
PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxSchedulerSuspended = ( unsigned portBASE_TYPE ) pdFALSE ;
PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxPendedTicks = ( unsigned portBASE_TYPE ) 0U ;
PRIVILEGED_DATA static volatile portBASE_TYPE xYieldPending = ( portBASE_TYPE ) pdFALSE ;
PRIVILEGED_DATA static volatile portBASE_TYPE xYieldPending = pdFALSE ;
PRIVILEGED_DATA static volatile portBASE_TYPE xNumOfOverflows = ( portBASE_TYPE ) 0 ;
PRIVILEGED_DATA static unsigned portBASE_TYPE uxTaskNumber = ( unsigned portBASE_TYPE ) 0U ;
PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime = ( portTickType ) portMAX_DELAY ;
PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime = portMAX_DELAY ;
# if ( configGENERATE_RUN_TIME_STATS == 1 )
@ -216,6 +230,8 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime = ( portTic
# endif
/*lint +e956 */
/* Debugging and trace facilities private variables and macros. ------------*/
/*
@ -355,7 +371,7 @@ count overflows. */
# define prvAddTaskToReadyList( pxTCB ) \
traceMOVED_TASK_TO_READY_STATE ( pxTCB ) \
taskRECORD_READY_PRIORITY ( ( pxTCB ) - > uxPriority ) ; \
vListInsertEnd ( ( xList * ) & ( pxReadyTasksLists [ ( pxTCB ) - > uxPriority ] ) , & ( ( pxTCB ) - > xGenericListItem ) )
vListInsertEnd ( & ( pxReadyTasksLists [ ( pxTCB ) - > uxPriority ] ) , & ( ( pxTCB ) - > xGenericListItem ) )
/*-----------------------------------------------------------*/
/*
@ -506,7 +522,7 @@ tskTCB * pxNewTCB;
# if( portSTACK_GROWTH < 0 )
{
pxTopOfStack = pxNewTCB - > pxStack + ( usStackDepth - ( unsigned short ) 1 ) ;
pxTopOfStack = ( portSTACK_TYPE * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ( portPOINTER_SIZE_TYPE ) ~ portBYTE_ALIGNMENT_MASK ) ) ;
pxTopOfStack = ( portSTACK_TYPE * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ( portPOINTER_SIZE_TYPE ) ~ portBYTE_ALIGNMENT_MASK ) ) ; /*lint !e923 MISRA exception. Avoiding casts between pointers and integers is not practical. Size differences accounted for using portPOINTER_SIZE_TYPE type. */
/* Check the alignment of the calculated top of stack is correct. */
configASSERT ( ( ( ( unsigned long ) pxTopOfStack & ( unsigned long ) portBYTE_ALIGNMENT_MASK ) = = 0UL ) ) ;
@ -645,7 +661,7 @@ tskTCB * pxNewTCB;
This will stop the task from be scheduled . The idle task will check
the termination list and free up any memory allocated by the
scheduler for the TCB and stack . */
if ( uxListRemove ( ( xListItem * ) & ( pxTCB - > xGenericListItem ) ) = = 0 )
if ( uxListRemove ( & ( pxTCB - > xGenericListItem ) ) = = ( unsigned portBASE_TYPE ) 0 )
{
taskRESET_READY_PRIORITY ( pxTCB - > uxPriority ) ;
}
@ -653,10 +669,10 @@ tskTCB * pxNewTCB;
/* Is the task waiting on an event also? */
if ( listLIST_ITEM_CONTAINER ( & ( pxTCB - > xEventListItem ) ) ! = NULL )
{
uxListRemove ( & ( pxTCB - > xEventListItem ) ) ;
( void ) uxListRemove ( & ( pxTCB - > xEventListItem ) ) ;
}
vListInsertEnd ( ( xList * ) & xTasksWaitingTermination , & ( pxTCB - > xGenericListItem ) ) ;
vListInsertEnd ( & xTasksWaitingTermination , & ( pxTCB - > xGenericListItem ) ) ;
/* Increment the ucTasksDeleted variable so the idle task knows
there is a task that has been deleted and that it should therefore
@ -674,7 +690,7 @@ tskTCB * pxNewTCB;
/* Force a reschedule if we have just deleted the current task. */
if ( xSchedulerRunning ! = pdFALSE )
{
if ( ( void * ) xTaskToDelete = = NULL )
if ( ( void * ) xTaskToDelete = = NULL ) /*lint !e961 MISRA exception as this is not a redundant cast when used with some supported compilers. */
{
portYIELD_WITHIN_API ( ) ;
}
@ -736,7 +752,7 @@ tskTCB * pxNewTCB;
/* We must remove ourselves from the ready list before adding
ourselves to the blocked list as the same list item is used for
both lists . */
if ( uxListRemove ( ( xListItem * ) & ( pxCurrentTCB - > xGenericListItem ) ) = = 0 )
if ( uxListRemove ( & ( pxCurrentTCB - > xGenericListItem ) ) = = ( unsigned portBASE_TYPE ) 0 )
{
/* The current task must be in a ready list, so there is
no need to check , and the port reset macro can be called
@ -789,7 +805,7 @@ tskTCB * pxNewTCB;
/* We must remove ourselves from the ready list before adding
ourselves to the blocked list as the same list item is used for
both lists . */
if ( uxListRemove ( ( xListItem * ) & ( pxCurrentTCB - > xGenericListItem ) ) = = 0 )
if ( uxListRemove ( & ( pxCurrentTCB - > xGenericListItem ) ) = = ( unsigned portBASE_TYPE ) 0 )
{
/* The current task must be in a ready list, so there is
no need to check , and the port reset macro can be called
@ -905,9 +921,9 @@ tskTCB * pxNewTCB;
configASSERT ( ( uxNewPriority < configMAX_PRIORITIES ) ) ;
/* Ensure the new priority is valid. */
if ( uxNewPriority > = configMAX_PRIORITIES )
if ( uxNewPriority > = ( unsigned portBASE_TYPE ) configMAX_PRIORITIES )
{
uxNewPriority = configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U ;
uxNewPriority = ( unsigned portBASE_TYPE ) configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U ;
}
taskENTER_CRITICAL ( ) ;
@ -954,6 +970,10 @@ tskTCB * pxNewTCB;
task of higher priority that is ready to execute . */
xYieldRequired = pdTRUE ;
}
else
{
/* Yield not required. */
}
/* Remember the ready list the task might be referenced from
before its uxPriority member is changed so the
@ -978,18 +998,18 @@ tskTCB * pxNewTCB;
}
# endif
listSET_LIST_ITEM_VALUE ( & ( pxTCB - > xEventListItem ) , ( configMAX_PRIORITIES - ( portTickType ) uxNewPriority ) ) ;
listSET_LIST_ITEM_VALUE ( & ( pxTCB - > xEventListItem ) , ( ( portTickType ) configMAX_PRIORITIES - ( portTickType ) uxNewPriority ) ) ; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
/* If the task is in the blocked or suspended list we need do
nothing more than change it ' s priority variable . However , if
the task is in a ready list it needs to be removed and placed
in the queue appropriate to its new priority . */
if ( listIS_CONTAINED_WITHIN ( & ( pxReadyTasksLists [ uxCurrentPriority ] ) , & ( pxTCB - > xGenericListItem ) ) )
if ( listIS_CONTAINED_WITHIN ( & ( pxReadyTasksLists [ uxCurrentPriority ] ) , & ( pxTCB - > xGenericListItem ) ) ! = pdFALSE )
{
/* The task is currently in its ready list - remove before adding
it to it ' s new ready list . As we are in a critical section we
can do this even if the scheduler is suspended . */
if ( uxListRemove ( ( xListItem * ) & ( pxTCB - > xGenericListItem ) ) = = 0 )
if ( uxListRemove ( & ( pxTCB - > xGenericListItem ) ) = = ( unsigned portBASE_TYPE ) 0 )
{
taskRESET_READY_PRIORITY ( uxPriorityUsedOnEntry ) ;
}
@ -1033,7 +1053,7 @@ tskTCB * pxNewTCB;
traceTASK_SUSPEND ( pxTCB ) ;
/* Remove task from the ready/delayed list and place in the suspended list. */
if ( uxListRemove ( ( xListItem * ) & ( pxTCB - > xGenericListItem ) ) = = 0 )
if ( uxListRemove ( & ( pxTCB - > xGenericListItem ) ) = = ( unsigned portBASE_TYPE ) 0 )
{
taskRESET_READY_PRIORITY ( pxTCB - > uxPriority ) ;
}
@ -1041,14 +1061,14 @@ tskTCB * pxNewTCB;
/* Is the task waiting on an event also? */
if ( listLIST_ITEM_CONTAINER ( & ( pxTCB - > xEventListItem ) ) ! = NULL )
{
uxListRemove ( & ( pxTCB - > xEventListItem ) ) ;
( void ) uxListRemove ( & ( pxTCB - > xEventListItem ) ) ;
}
vListInsertEnd ( ( xList * ) & xSuspendedTaskList , & ( pxTCB - > xGenericListItem ) ) ;
vListInsertEnd ( & xSuspendedTaskList , & ( pxTCB - > xGenericListItem ) ) ;
}
taskEXIT_CRITICAL ( ) ;
if ( ( void * ) xTaskToSuspend = = NULL )
if ( ( void * ) xTaskToSuspend = = NULL ) /*lint !e961 MISRA exception justified because it is not a redundant cast for some supported compilers. */
{
if ( xSchedulerRunning ! = pdFALSE )
{
@ -1094,13 +1114,13 @@ tskTCB * pxNewTCB;
if ( listIS_CONTAINED_WITHIN ( & xSuspendedTaskList , & ( pxTCB - > xGenericListItem ) ) ! = pdFALSE )
{
/* Has the task already been resumed from within an ISR? */
if ( listIS_CONTAINED_WITHIN ( & xPendingReadyList , & ( pxTCB - > xEventListItem ) ) != pdTRU E )
if ( listIS_CONTAINED_WITHIN ( & xPendingReadyList , & ( pxTCB - > xEventListItem ) ) == pdFALS E )
{
/* Is it in the suspended list because it is in the
Suspended state ? It is possible to be in the suspended
list because it is blocked on a task with no timeout
specified . */
if ( listIS_CONTAINED_WITHIN ( NULL , & ( pxTCB - > xEventListItem ) ) == pdTRU E )
if ( listIS_CONTAINED_WITHIN ( NULL , & ( pxTCB - > xEventListItem ) ) != pdFALS E )
{
xReturn = pdTRUE ;
}
@ -1108,7 +1128,7 @@ tskTCB * pxNewTCB;
}
return xReturn ;
}
} /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */
# endif /* INCLUDE_vTaskSuspend */
/*-----------------------------------------------------------*/
@ -1134,7 +1154,7 @@ tskTCB * pxNewTCB;
/* As we are in a critical section we can access the ready
lists even if the scheduler is suspended . */
uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
( void ) uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
prvAddTaskToReadyList ( pxTCB ) ;
/* We may have just resumed a higher priority task. */
@ -1191,7 +1211,7 @@ tskTCB * pxNewTCB;
if ( uxSchedulerSuspended = = ( unsigned portBASE_TYPE ) pdFALSE )
{
xYieldRequired = ( pxTCB - > uxPriority > = pxCurrentTCB - > uxPriority ) ;
uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
( void ) uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
prvAddTaskToReadyList ( pxTCB ) ;
}
else
@ -1199,7 +1219,7 @@ tskTCB * pxNewTCB;
/* We cannot access the delayed or ready lists, so will hold this
task pending until the scheduler is resumed , at which point a
yield will be performed if necessary . */
vListInsertEnd ( ( xList * ) & ( xPendingReadyList ) , & ( pxTCB - > xEventListItem ) ) ;
vListInsertEnd ( & ( xPendingReadyList ) , & ( pxTCB - > xEventListItem ) ) ;
}
}
}
@ -1220,12 +1240,12 @@ portBASE_TYPE xReturn;
{
/* Create the idle task, storing its handle in xIdleTaskHandle so it can
be returned by the xTaskGetIdleTaskHandle ( ) function . */
xReturn = xTaskCreate ( prvIdleTask , ( signed char * ) " IDLE " , tskIDLE_STACK_SIZE , ( void * ) NULL , ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ) , & xIdleTaskHandle ) ;
xReturn = xTaskCreate ( prvIdleTask , ( signed char * ) " IDLE " , tskIDLE_STACK_SIZE , ( void * ) NULL , ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ) , & xIdleTaskHandle ) ; /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
}
# else
{
/* Create the idle task without storing its handle. */
xReturn = xTaskCreate ( prvIdleTask , ( signed char * ) " IDLE " , tskIDLE_STACK_SIZE , ( void * ) NULL , ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ) , NULL ) ;
xReturn = xTaskCreate ( prvIdleTask , ( signed char * ) " IDLE " , tskIDLE_STACK_SIZE , ( void * ) NULL , ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ) , NULL ) ; /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
}
# endif /* INCLUDE_xTaskGetIdleTaskHandle */
@ -1329,8 +1349,8 @@ void vTaskSuspendAll( void )
signed portBASE_TYPE xTaskResumeAll ( void )
{
register tskTCB * pxTCB ;
signed portBASE_TYPE xAlreadyYielded = pdFALSE ;
tskTCB * pxTCB ;
portBASE_TYPE xAlreadyYielded = pdFALSE ;
portBASE_TYPE xYieldRequired = pdFALSE ;
/* If uxSchedulerSuspended is zero then this function does not match a
@ -1352,11 +1372,11 @@ portBASE_TYPE xYieldRequired = pdFALSE;
{
/* Move any readied tasks from the pending list into the
appropriate ready list . */
while ( listLIST_IS_EMPTY ( ( xList * ) & xPendingReadyList ) = = pdFALSE )
while ( listLIST_IS_EMPTY ( & xPendingReadyList ) = = pdFALSE )
{
pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY ( ( ( xList * ) & xPendingReadyList ) ) ;
uxListRemove ( & ( pxTCB - > xEventListItem ) ) ;
uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY ( ( & xPendingReadyList ) ) ;
( void ) uxListRemove ( & ( pxTCB - > xEventListItem ) ) ;
( void ) uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
prvAddTaskToReadyList ( pxTCB ) ;
/* If we have moved a task that has a priority higher than
@ -1480,9 +1500,9 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
do
{
uxQueue - - ;
uxTask + = prvListTaskWithinSingleList ( & ( pxTaskStatusArray [ uxTask ] ) , ( xList * ) & ( pxReadyTasksLists [ uxQueue ] ) , eReady ) ;
uxTask + = prvListTaskWithinSingleList ( & ( pxTaskStatusArray [ uxTask ] ) , & ( pxReadyTasksLists [ uxQueue ] ) , eReady ) ;
} while ( uxQueue > ( unsigned short ) tskIDLE_PRIORITY ) ;
} while ( uxQueue > ( unsigned portBASE_TYPE ) tskIDLE_PRIORITY ) ; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
/* Fill in an xTaskStatusType structure with information on each
task in the Blocked state . */
@ -1522,7 +1542,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
# endif
}
}
xTaskResumeAll ( ) ;
( void ) xTaskResumeAll ( ) ;
return uxTask ;
}
@ -1624,13 +1644,13 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
}
/* It is time to remove the item from the Blocked state. */
uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
( void ) uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
/* Is the task waiting on an event also? If so remove it
from the event list . */
if ( listLIST_ITEM_CONTAINER ( & ( pxTCB - > xEventListItem ) ) ! = NULL )
{
uxListRemove ( & ( pxTCB - > xEventListItem ) ) ;
( void ) uxListRemove ( & ( pxTCB - > xEventListItem ) ) ;
}
/* Place the unblocked task into the appropriate ready
@ -1661,7 +1681,7 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
writer has not explicitly turned time slicing off . */
# if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) )
{
if ( listCURRENT_LIST_LENGTH ( & ( pxReadyTasksLists [ pxCurrentTCB - > uxPriority ] ) ) > 1 )
if ( listCURRENT_LIST_LENGTH ( & ( pxReadyTasksLists [ pxCurrentTCB - > uxPriority ] ) ) > ( unsigned portBASE_TYPE ) 1 )
{
xSwitchRequired = pdTRUE ;
}
@ -1836,7 +1856,7 @@ void vTaskSwitchContext( void )
}
/*-----------------------------------------------------------*/
void vTaskPlaceOnEventList ( const xList * const pxEventList , portTickType xTicksToWait )
void vTaskPlaceOnEventList ( xList * const pxEventList , portTickType xTicksToWait )
{
portTickType xTimeToWake ;
@ -1848,12 +1868,12 @@ portTickType xTimeToWake;
/* Place the event list item of the TCB in the appropriate event list.
This is placed in the list in priority order so the highest priority task
is the first to be woken by the event . */
vListInsert ( ( xList * ) pxEventList , ( xListItem * ) & ( pxCurrentTCB - > xEventListItem ) ) ;
vListInsert ( pxEventList , & ( pxCurrentTCB - > xEventListItem ) ) ;
/* We must remove ourselves from the ready list before adding ourselves
to the blocked list as the same list item is used for both lists . We have
exclusive access to the ready lists as the scheduler is locked . */
if ( uxListRemove ( ( xListItem * ) & ( pxCurrentTCB - > xGenericListItem ) ) = = 0 )
if ( uxListRemove ( & ( pxCurrentTCB - > xGenericListItem ) ) = = ( unsigned portBASE_TYPE ) 0 )
{
/* The current task must be in a ready list, so there is no need to
check , and the port reset macro can be called directly . */
@ -1867,7 +1887,7 @@ portTickType xTimeToWake;
/* Add ourselves to the suspended task list instead of a delayed task
list to ensure we are not woken by a timing event . We will block
indefinitely . */
vListInsertEnd ( ( xList * ) & xSuspendedTaskList , ( xListItem * ) & ( pxCurrentTCB - > xGenericListItem ) ) ;
vListInsertEnd ( & xSuspendedTaskList , & ( pxCurrentTCB - > xGenericListItem ) ) ;
}
else
{
@ -1890,7 +1910,7 @@ portTickType xTimeToWake;
# if configUSE_TIMERS == 1
void vTaskPlaceOnEventListRestricted ( const xList * const pxEventList , portTickType xTicksToWait )
void vTaskPlaceOnEventListRestricted ( xList * const pxEventList , portTickType xTicksToWait )
{
portTickType xTimeToWake ;
@ -1906,12 +1926,12 @@ portTickType xTimeToWake;
In this case it is assume that this is the only task that is going to
be waiting on this event list , so the faster vListInsertEnd ( ) function
can be used in place of vListInsert . */
vListInsertEnd ( ( xList * ) pxEventList , ( xListItem * ) & ( pxCurrentTCB - > xEventListItem ) ) ;
vListInsertEnd ( pxEventList , & ( pxCurrentTCB - > xEventListItem ) ) ;
/* We must remove this task from the ready list before adding it to the
blocked list as the same list item is used for both lists . This
function is called form a critical section . */
if ( uxListRemove ( ( xListItem * ) & ( pxCurrentTCB - > xGenericListItem ) ) = = 0 )
if ( uxListRemove ( & ( pxCurrentTCB - > xGenericListItem ) ) = = ( unsigned portBASE_TYPE ) 0 )
{
/* The current task must be in a ready list, so there is no need to
check , and the port reset macro can be called directly . */
@ -1949,18 +1969,18 @@ portBASE_TYPE xReturn;
pxEventList is not empty . */
pxUnblockedTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY ( pxEventList ) ;
configASSERT ( pxUnblockedTCB ) ;
uxListRemove ( & ( pxUnblockedTCB - > xEventListItem ) ) ;
( void ) uxListRemove ( & ( pxUnblockedTCB - > xEventListItem ) ) ;
if ( uxSchedulerSuspended = = ( unsigned portBASE_TYPE ) pdFALSE )
{
uxListRemove ( & ( pxUnblockedTCB - > xGenericListItem ) ) ;
( void ) uxListRemove ( & ( pxUnblockedTCB - > xGenericListItem ) ) ;
prvAddTaskToReadyList ( pxUnblockedTCB ) ;
}
else
{
/* We cannot access the delayed or ready lists, so will hold this
task pending until the scheduler is resumed . */
vListInsertEnd ( ( xList * ) & ( xPendingReadyList ) , & ( pxUnblockedTCB - > xEventListItem ) ) ;
vListInsertEnd ( & ( xPendingReadyList ) , & ( pxUnblockedTCB - > xEventListItem ) ) ;
}
if ( pxUnblockedTCB - > uxPriority > = pxCurrentTCB - > uxPriority )
@ -2011,7 +2031,7 @@ portBASE_TYPE xReturn;
else /* We are not blocking indefinitely, perform the checks below. */
# endif
if ( ( xNumOfOverflows ! = pxTimeOut - > xOverflowCount ) & & ( ( portTickType ) xConstTickCount > = ( portTickType ) pxTimeOut - > xTimeOnEntering ) )
if ( ( xNumOfOverflows ! = pxTimeOut - > xOverflowCount ) & & ( xConstTickCount > = pxTimeOut - > xTimeOnEntering ) ) /*lint !e525 Indentation preferred as is to make code within pre-processor directives clearer. */
{
/* The tick count is greater than the time at which vTaskSetTimeout()
was called , but has also overflowed since vTaskSetTimeOut ( ) was called .
@ -2019,10 +2039,10 @@ portBASE_TYPE xReturn;
passed since vTaskSetTimeout ( ) was called . */
xReturn = pdTRUE ;
}
else if ( ( ( portTickType ) ( ( portTickType ) xConstTickCount - ( portTickType ) pxTimeOut - > xTimeOnEntering ) ) < ( portTickType ) * pxTicksToWait )
else if ( ( xConstTickCount - pxTimeOut - > xTimeOnEntering ) < * pxTicksToWait )
{
/* Not a genuine timeout. Adjust parameters for time remaining. */
* pxTicksToWait - = ( ( portTickType ) xConstTickCount - ( portTickType ) pxTimeOut - > xTimeOnEntering ) ;
* pxTicksToWait - = ( xConstTickCount - pxTimeOut - > xTimeOnEntering ) ;
vTaskSetTimeOutState ( pxTimeOut ) ;
xReturn = pdFALSE ;
}
@ -2223,10 +2243,10 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
static void prvInitialiseTCBVariables ( tskTCB * pxTCB , const signed char * const pcName , unsigned portBASE_TYPE uxPriority , const xMemoryRegion * const xRegions , unsigned short usStackDepth )
{
portBASE_TYPE x ;
unsigned portBASE_TYPE x ;
/* Store the task name in the TCB. */
for ( x = 0 ; x < configMAX_TASK_NAME_LEN ; x + + )
for ( x = ( unsigned portBASE_TYPE ) 0 ; x < ( unsigned portBASE_TYPE ) configMAX_TASK_NAME_LEN ; x + + )
{
pxTCB - > pcTaskName [ x ] = pcName [ x ] ;
@ -2245,9 +2265,9 @@ portBASE_TYPE x;
/* 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 )
if ( uxPriority > = ( unsigned portBASE_TYPE ) configMAX_PRIORITIES )
{
uxPriority = configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U ;
uxPriority = ( unsigned portBASE_TYPE ) configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U ;
}
pxTCB - > uxPriority = uxPriority ;
@ -2265,7 +2285,7 @@ portBASE_TYPE x;
listSET_LIST_ITEM_OWNER ( & ( pxTCB - > xGenericListItem ) , pxTCB ) ;
/* Event lists are always in priority order. */
listSET_LIST_ITEM_VALUE ( & ( pxTCB - > xEventListItem ) , configMAX_PRIORITIES - ( portTickType ) uxPriority ) ;
listSET_LIST_ITEM_VALUE ( & ( pxTCB - > xEventListItem ) , ( portTickType ) configMAX_PRIORITIES - ( portTickType ) uxPriority ) ; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
listSET_LIST_ITEM_OWNER ( & ( pxTCB - > xEventListItem ) , pxTCB ) ;
# if ( portCRITICAL_NESTING_IN_TCB == 1 )
@ -2330,24 +2350,24 @@ static void prvInitialiseTaskLists( void )
{
unsigned portBASE_TYPE uxPriority ;
for ( uxPriority = ( unsigned portBASE_TYPE ) 0U ; uxPriority < configMAX_PRIORITIES ; uxPriority + + )
for ( uxPriority = ( unsigned portBASE_TYPE ) 0U ; uxPriority < ( unsigned portBASE_TYPE ) configMAX_PRIORITIES ; uxPriority + + )
{
vListInitialise ( ( xList * ) & ( pxReadyTasksLists [ uxPriority ] ) ) ;
vListInitialise ( & ( pxReadyTasksLists [ uxPriority ] ) ) ;
}
vListInitialise ( ( xList * ) & xDelayedTaskList1 ) ;
vListInitialise ( ( xList * ) & xDelayedTaskList2 ) ;
vListInitialise ( ( xList * ) & xPendingReadyList ) ;
vListInitialise ( & xDelayedTaskList1 ) ;
vListInitialise ( & xDelayedTaskList2 ) ;
vListInitialise ( & xPendingReadyList ) ;
# if ( INCLUDE_vTaskDelete == 1 )
{
vListInitialise ( ( xList * ) & xTasksWaitingTermination ) ;
vListInitialise ( & xTasksWaitingTermination ) ;
}
# endif /* INCLUDE_vTaskDelete */
# if ( INCLUDE_vTaskSuspend == 1 )
{
vListInitialise ( ( xList * ) & xSuspendedTaskList ) ;
vListInitialise ( & xSuspendedTaskList ) ;
}
# endif /* INCLUDE_vTaskSuspend */
@ -2370,7 +2390,7 @@ static void prvCheckTasksWaitingTermination( void )
{
vTaskSuspendAll ( ) ;
xListIsEmpty = listLIST_IS_EMPTY ( & xTasksWaitingTermination ) ;
xTaskResumeAll ( ) ;
( void ) xTaskResumeAll ( ) ;
if ( xListIsEmpty = = pdFALSE )
{
@ -2378,8 +2398,8 @@ static void prvCheckTasksWaitingTermination( void )
taskENTER_CRITICAL ( ) ;
{
pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY ( ( ( xList * ) & xTasksWaitingTermination ) ) ;
uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY ( ( & xTasksWaitingTermination ) ) ;
( void ) uxListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
- - uxCurrentNumberOfTasks ;
- - uxTasksDeleted ;
}
@ -2401,12 +2421,12 @@ static void prvAddCurrentTaskToDelayedList( portTickType xTimeToWake )
if ( xTimeToWake < xTickCount )
{
/* Wake time has overflowed. Place this item in the overflow list. */
vListInsert ( ( xList * ) pxOverflowDelayedTaskList , ( xListItem * ) & ( pxCurrentTCB - > xGenericListItem ) ) ;
vListInsert ( pxOverflowDelayedTaskList , & ( pxCurrentTCB - > xGenericListItem ) ) ;
}
else
{
/* The wake time has not overflowed, so we can use the current block list. */
vListInsert ( ( xList * ) pxDelayedTaskList , ( xListItem * ) & ( pxCurrentTCB - > xGenericListItem ) ) ;
vListInsert ( pxDelayedTaskList , & ( pxCurrentTCB - > xGenericListItem ) ) ;
/* If the task entering the blocked state was placed at the head of the
list of blocked tasks then xNextTaskUnblockTime needs to be updated
@ -2432,7 +2452,7 @@ tskTCB *pxNewTCB;
/* Allocate space for the stack used by the task being created.
The base of the stack memory stored in the TCB so the task can
be deleted later if required . */
pxNewTCB - > pxStack = ( portSTACK_TYPE * ) pvPortMallocAligned ( ( ( ( size_t ) usStackDepth ) * sizeof ( portSTACK_TYPE ) ) , puxStackBuffer ) ;
pxNewTCB - > pxStack = ( portSTACK_TYPE * ) pvPortMallocAligned ( ( ( ( size_t ) usStackDepth ) * sizeof ( portSTACK_TYPE ) ) , puxStackBuffer ) ; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
if ( pxNewTCB - > pxStack = = NULL )
{
@ -2443,7 +2463,7 @@ tskTCB *pxNewTCB;
else
{
/* Just to help debugging. */
memset ( pxNewTCB - > pxStack , ( int ) tskSTACK_FILL_BYTE , ( size_t ) usStackDepth * sizeof ( portSTACK_TYPE ) ) ;
( void ) memset ( pxNewTCB - > pxStack , ( int ) tskSTACK_FILL_BYTE , ( size_t ) usStackDepth * sizeof ( portSTACK_TYPE ) ) ;
}
}
@ -2458,7 +2478,7 @@ tskTCB *pxNewTCB;
volatile tskTCB * pxNextTCB , * pxFirstTCB ;
unsigned portBASE_TYPE uxTask = 0 ;
if ( listCURRENT_LIST_LENGTH ( pxList ) > 0 )
if ( listCURRENT_LIST_LENGTH ( pxList ) > ( unsigned portBASE_TYPE ) 0 )
{
listGET_OWNER_OF_NEXT_ENTRY ( pxFirstTCB , pxList ) ;
@ -2630,7 +2650,7 @@ tskTCB *pxNewTCB;
# if ( configUSE_MUTEXES == 1 )
void vTaskPriorityInherit ( xTaskHandle * const pxMutexHolder )
void vTaskPriorityInherit ( xTaskHandle const pxMutexHolder )
{
tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder ;
@ -2641,13 +2661,13 @@ tskTCB *pxNewTCB;
if ( pxTCB - > uxPriority < pxCurrentTCB - > uxPriority )
{
/* Adjust the mutex holder state to account for its new priority. */
listSET_LIST_ITEM_VALUE ( & ( pxTCB - > xEventListItem ) , configMAX_PRIORITIES - ( portTickType ) pxCurrentTCB - > uxPriority ) ;
listSET_LIST_ITEM_VALUE ( & ( pxTCB - > xEventListItem ) , ( portTickType ) configMAX_PRIORITIES - ( portTickType ) pxCurrentTCB - > uxPriority ) ; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
/* If the task being modified is in the ready state it will need to
be moved into a new list . */
if ( listIS_CONTAINED_WITHIN ( & ( pxReadyTasksLists [ pxTCB - > uxPriority ] ) , & ( pxTCB - > xGenericListItem ) ) ! = pdFALSE )
{
if ( uxListRemove ( ( xListItem * ) & ( pxTCB - > xGenericListItem ) ) = = 0 )
if ( uxListRemove ( & ( pxTCB - > xGenericListItem ) ) = = ( unsigned portBASE_TYPE ) 0 )
{
taskRESET_READY_PRIORITY ( pxTCB - > uxPriority ) ;
}
@ -2672,7 +2692,7 @@ tskTCB *pxNewTCB;
# if ( configUSE_MUTEXES == 1 )
void vTaskPriorityDisinherit ( xTaskHandle * const pxMutexHolder )
void vTaskPriorityDisinherit ( xTaskHandle const pxMutexHolder )
{
tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder ;
@ -2682,7 +2702,7 @@ tskTCB *pxNewTCB;
{
/* We must be the running task to be able to give the mutex back.
Remove ourselves from the ready list we currently appear in . */
if ( uxListRemove ( ( xListItem * ) & ( pxTCB - > xGenericListItem ) ) = = 0 )
if ( uxListRemove ( & ( pxTCB - > xGenericListItem ) ) = = ( unsigned portBASE_TYPE ) 0 )
{
taskRESET_READY_PRIORITY ( pxTCB - > uxPriority ) ;
}
@ -2691,7 +2711,7 @@ tskTCB *pxNewTCB;
ready list . */
traceTASK_PRIORITY_DISINHERIT ( pxTCB , pxTCB - > uxBasePriority ) ;
pxTCB - > uxPriority = pxTCB - > uxBasePriority ;
listSET_LIST_ITEM_VALUE ( & ( pxTCB - > xEventListItem ) , configMAX_PRIORITIES - ( portTickType ) pxTCB - > uxPriority ) ;
listSET_LIST_ITEM_VALUE ( & ( pxTCB - > xEventListItem ) , ( portTickType ) configMAX_PRIORITIES - ( portTickType ) pxTCB - > uxPriority ) ; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
prvAddTaskToReadyList ( pxTCB ) ;
}
}