Next revision of queue set implementation.

Make conditional compilation syntax and commenting consistent.
Add common demo tasks to demonstrate queue sets.
This commit is contained in:
Richard Barry 2013-02-07 15:10:25 +00:00
parent b5b518571e
commit 4e5090e061
12 changed files with 997 additions and 386 deletions

View file

@ -214,7 +214,7 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime = ( portTic
/*-----------------------------------------------------------*/
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 0
#if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 )
/* If configUSE_PORT_OPTIMISED_TASK_SELECTION is 0 then task selection is
performed in a generic way that is not optimised to any particular
@ -478,12 +478,6 @@ static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TY
/*lint +e956 */
/*-----------------------------------------------------------
* TASK CREATION API documented in task.h
*----------------------------------------------------------*/
signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions )
{
signed portBASE_TYPE xReturn;
@ -526,7 +520,7 @@ tskTCB * pxNewTCB;
/* Check the alignment of the calculated top of stack is correct. */
configASSERT( ( ( ( unsigned long ) pxTopOfStack & ( unsigned long ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );
}
#else
#else /* portSTACK_GROWTH */
{
pxTopOfStack = pxNewTCB->pxStack;
@ -538,7 +532,7 @@ tskTCB * pxNewTCB;
other extreme of the stack space. */
pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );
}
#endif
#endif /* portSTACK_GROWTH */
/* Setup the newly allocated TCB with the initial state of the task. */
prvInitialiseTCBVariables( pxNewTCB, pcName, uxPriority, xRegions, usStackDepth );
@ -551,11 +545,11 @@ tskTCB * pxNewTCB;
{
pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters, xRunPrivileged );
}
#else
#else /* portUSING_MPU_WRAPPERS */
{
pxNewTCB->pxTopOfStack = pxPortInitialiseStack( pxTopOfStack, pxTaskCode, pvParameters );
}
#endif
#endif /* portUSING_MPU_WRAPPERS */
/* Check the alignment of the initialised stack. */
portALIGNMENT_ASSERT_pxCurrentTCB( ( ( ( unsigned long ) pxNewTCB->pxTopOfStack & ( unsigned long ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );
@ -613,7 +607,7 @@ tskTCB * pxNewTCB;
/* Add a counter into the TCB for tracing only. */
pxNewTCB->uxTCBNumber = uxTaskNumber;
}
#endif
#endif /* configUSE_TRACE_FACILITY */
uxTaskNumber++;
traceTASK_CREATE( pxNewTCB );
@ -705,16 +699,8 @@ tskTCB * pxNewTCB;
}
}
#endif
/*-----------------------------------------------------------
* TASK CONTROL API documented in task.h
*----------------------------------------------------------*/
#endif /* INCLUDE_vTaskDelete */
/*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskDelayUntil == 1 )
@ -785,7 +771,7 @@ tskTCB * pxNewTCB;
}
}
#endif
#endif /* INCLUDE_vTaskDelayUntil */
/*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskDelay == 1 )
@ -837,7 +823,7 @@ tskTCB * pxNewTCB;
}
}
#endif
#endif /* INCLUDE_vTaskDelay */
/*-----------------------------------------------------------*/
#if ( INCLUDE_eTaskGetState == 1 )
@ -899,7 +885,7 @@ tskTCB * pxNewTCB;
return eReturn;
}
#endif
#endif /* INCLUDE_eTaskGetState */
/*-----------------------------------------------------------*/
#if ( INCLUDE_uxTaskPriorityGet == 1 )
@ -921,7 +907,7 @@ tskTCB * pxNewTCB;
return uxReturn;
}
#endif
#endif /* INCLUDE_uxTaskPriorityGet */
/*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskPrioritySet == 1 )
@ -1039,7 +1025,7 @@ tskTCB * pxNewTCB;
( void ) uxPriorityUsedOnEntry;
}
#endif
#endif /* INCLUDE_vTaskPrioritySet */
/*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskSuspend == 1 )
@ -1106,7 +1092,7 @@ tskTCB * pxNewTCB;
}
}
#endif
#endif /* INCLUDE_vTaskSuspend */
/*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskSuspend == 1 )
@ -1140,7 +1126,7 @@ tskTCB * pxNewTCB;
return xReturn;
}
#endif
#endif /* INCLUDE_vTaskSuspend */
/*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskSuspend == 1 )
@ -1184,7 +1170,7 @@ tskTCB * pxNewTCB;
}
}
#endif
#endif /* INCLUDE_vTaskSuspend */
/*-----------------------------------------------------------*/
@ -1226,15 +1212,8 @@ tskTCB * pxNewTCB;
return xYieldRequired;
}
#endif
/*-----------------------------------------------------------
* PUBLIC SCHEDULER CONTROL documented in task.h
*----------------------------------------------------------*/
#endif /* ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) */
/*-----------------------------------------------------------*/
void vTaskStartScheduler( void )
{
@ -1252,7 +1231,7 @@ portBASE_TYPE xReturn;
/* Create the idle task without storing its handle. */
xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), NULL );
}
#endif
#endif /* INCLUDE_xTaskGetIdleTaskHandle */
#if ( configUSE_TIMERS == 1 )
{
@ -1261,7 +1240,7 @@ portBASE_TYPE xReturn;
xReturn = xTimerCreateTimerTask();
}
}
#endif
#endif /* configUSE_TIMERS */
if( xReturn == pdPASS )
{
@ -1296,7 +1275,9 @@ portBASE_TYPE xReturn;
}
}
/* This line will only be reached if the kernel could not be started. */
/* This line will only be reached if the kernel could not be started, or
vTaskEndScheduler() was called (vTaskEndScheduler() is not implemented for
most ports). */
configASSERT( xReturn );
}
/*-----------------------------------------------------------*/
@ -1345,7 +1326,7 @@ void vTaskSuspendAll( void )
return xReturn;
}
#endif /* configUSE_TICKLESS_IDLE != 0 */
#endif /* configUSE_TICKLESS_IDLE */
/*----------------------------------------------------------*/
signed portBASE_TYPE xTaskResumeAll( void )
@ -1423,17 +1404,7 @@ signed portBASE_TYPE xAlreadyYielded = pdFALSE;
return xAlreadyYielded;
}
/*-----------------------------------------------------------
* PUBLIC TASK UTILITIES documented in task.h
*----------------------------------------------------------*/
/*-----------------------------------------------------------*/
portTickType xTaskGetTickCount( void )
{
@ -1483,7 +1454,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
return &( pxTCB->pcTaskName[ 0 ] );
}
#endif
#endif /* INCLUDE_pcTaskGetTaskName */
/*-----------------------------------------------------------*/
#if ( configUSE_TRACE_FACILITY == 1 )
@ -1546,7 +1517,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
xTaskResumeAll();
}
#endif
#endif /* configUSE_TRACE_FACILITY */
/*----------------------------------------------------------*/
#if ( configGENERATE_RUN_TIME_STATS == 1 )
@ -1621,7 +1592,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
xTaskResumeAll();
}
#endif
#endif /* configGENERATE_RUN_TIME_STATS */
/*----------------------------------------------------------*/
#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
@ -1634,7 +1605,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
return xIdleTaskHandle;
}
#endif
#endif /* INCLUDE_xTaskGetIdleTaskHandle */
/*----------------------------------------------------------*/
/* This conditional compilation should use inequality to 0, not equality to 1.
@ -1649,12 +1620,8 @@ implementations require configUSE_TICKLESS_IDLE to be set to a value other than
xTickCount += xTicksToJump;
}
#endif
/*-----------------------------------------------------------
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
* documented in task.h
*----------------------------------------------------------*/
#endif /* configUSE_TICKLESS_IDLE */
/*----------------------------------------------------------*/
void vTaskIncrementTick( void )
{
@ -1726,7 +1693,7 @@ tskTCB * pxTCB;
vApplicationTickHook();
}
}
#endif
#endif /* configUSE_TICK_HOOK */
}
/*-----------------------------------------------------------*/
@ -1753,7 +1720,7 @@ tskTCB * pxTCB;
taskEXIT_CRITICAL();
}
#endif
#endif /* configUSE_APPLICATION_TASK_TAG */
/*-----------------------------------------------------------*/
#if ( configUSE_APPLICATION_TASK_TAG == 1 )
@ -1782,7 +1749,7 @@ tskTCB * pxTCB;
return xReturn;
}
#endif
#endif /* configUSE_APPLICATION_TASK_TAG */
/*-----------------------------------------------------------*/
#if ( configUSE_APPLICATION_TASK_TAG == 1 )
@ -1814,7 +1781,7 @@ tskTCB * pxTCB;
return xReturn;
}
#endif
#endif /* configUSE_APPLICATION_TASK_TAG */
/*-----------------------------------------------------------*/
void vTaskSwitchContext( void )
@ -1845,7 +1812,7 @@ void vTaskSwitchContext( void )
pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );
ulTaskSwitchedInTime = ulTotalRunTime;
}
#endif
#endif /* configGENERATE_RUN_TIME_STATS */
taskFIRST_CHECK_FOR_STACK_OVERFLOW();
taskSECOND_CHECK_FOR_STACK_OVERFLOW();
@ -1898,14 +1865,14 @@ portTickType xTimeToWake;
prvAddCurrentTaskToDelayedList( xTimeToWake );
}
}
#else
#else /* INCLUDE_vTaskSuspend */
{
/* Calculate the time at which the task should be woken if the event does
not occur. This may overflow but this doesn't matter. */
xTimeToWake = xTickCount + xTicksToWait;
prvAddCurrentTaskToDelayedList( xTimeToWake );
}
#endif
#endif /* INCLUDE_vTaskSuspend */
}
/*-----------------------------------------------------------*/
@ -2062,6 +2029,7 @@ void vTaskMissedYield( void )
/*-----------------------------------------------------------*/
#if ( configUSE_TRACE_FACILITY == 1 )
unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask )
{
unsigned portBASE_TYPE uxReturn;
@ -2079,10 +2047,12 @@ void vTaskMissedYield( void )
return uxReturn;
}
#endif
#endif /* configUSE_TRACE_FACILITY */
/*-----------------------------------------------------------*/
#if ( configUSE_TRACE_FACILITY == 1 )
void vTaskSetTaskNumber( xTaskHandle xTask, unsigned portBASE_TYPE uxHandle )
{
tskTCB *pxTCB;
@ -2093,8 +2063,8 @@ void vTaskMissedYield( void )
pxTCB->uxTaskNumber = uxHandle;
}
}
#endif
#endif /* configUSE_TRACE_FACILITY */
/*
* -----------------------------------------------------------
@ -2125,7 +2095,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
will automatically get the processor anyway. */
taskYIELD();
}
#endif
#endif /* configUSE_PREEMPTION */
#if ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) )
{
@ -2143,7 +2113,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
taskYIELD();
}
}
#endif
#endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) */
#if ( configUSE_IDLE_HOOK == 1 )
{
@ -2156,7 +2126,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
CALL A FUNCTION THAT MIGHT BLOCK. */
vApplicationIdleHook();
}
#endif
#endif /* configUSE_IDLE_HOOK */
/* This conditional compilation should use inequality to 0, not equality
to 1. This is to ensure portSUPPRESS_TICKS_AND_SLEEP() is called when
@ -2190,21 +2160,10 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
xTaskResumeAll();
}
}
#endif
#endif /* configUSE_TICKLESS_IDLE */
}
} /*lint !e715 pvParameters is not accessed but all task functions require the same prototype. */
/*-----------------------------------------------------------
* File private functions documented at the top of the file.
*----------------------------------------------------------*/
/*-----------------------------------------------------------*/
static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const pcName, unsigned portBASE_TYPE uxPriority, const xMemoryRegion * const xRegions, unsigned short usStackDepth )
{
@ -2214,7 +2173,7 @@ static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const
/* Don't bring strncpy into the build unnecessarily. */
strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned short ) configMAX_TASK_NAME_LEN );
}
#endif
#endif /* configMAX_TASK_NAME_LEN */
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
@ -2229,7 +2188,7 @@ static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const
{
pxTCB->uxBasePriority = uxPriority;
}
#endif
#endif /* configUSE_MUTEXES */
vListInitialiseItem( &( pxTCB->xGenericListItem ) );
vListInitialiseItem( &( pxTCB->xEventListItem ) );
@ -2246,30 +2205,30 @@ static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const
{
pxTCB->uxCriticalNesting = ( unsigned portBASE_TYPE ) 0U;
}
#endif
#endif /* portCRITICAL_NESTING_IN_TCB */
#if ( configUSE_APPLICATION_TASK_TAG == 1 )
{
pxTCB->pxTaskTag = NULL;
}
#endif
#endif /* configUSE_APPLICATION_TASK_TAG */
#if ( configGENERATE_RUN_TIME_STATS == 1 )
{
pxTCB->ulRunTimeCounter = 0UL;
}
#endif
#endif /* configGENERATE_RUN_TIME_STATS */
#if ( portUSING_MPU_WRAPPERS == 1 )
{
vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, pxTCB->pxStack, usStackDepth );
}
#else
#else /* portUSING_MPU_WRAPPERS */
{
( void ) xRegions;
( void ) usStackDepth;
}
#endif
#endif /* portUSING_MPU_WRAPPERS */
}
/*-----------------------------------------------------------*/
@ -2289,8 +2248,9 @@ static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const
vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, NULL, 0 );
}
/*-----------------------------------------------------------*/
#endif
#endif /* portUSING_MPU_WRAPPERS */
/*-----------------------------------------------------------*/
static void prvInitialiseTaskLists( void )
{
@ -2309,13 +2269,13 @@ unsigned portBASE_TYPE uxPriority;
{
vListInitialise( ( xList * ) &xTasksWaitingTermination );
}
#endif
#endif /* INCLUDE_vTaskDelete */
#if ( INCLUDE_vTaskSuspend == 1 )
{
vListInitialise( ( xList * ) &xSuspendedTaskList );
}
#endif
#endif /* INCLUDE_vTaskSuspend */
/* Start with pxDelayedTaskList using list1 and the pxOverflowDelayedTaskList
using list2. */
@ -2355,7 +2315,7 @@ static void prvCheckTasksWaitingTermination( void )
}
}
}
#endif
#endif /* vTaskDelete */
}
/*-----------------------------------------------------------*/
@ -2446,7 +2406,7 @@ tskTCB *pxNewTCB;
} while( pxNextTCB != pxFirstTCB );
}
#endif
#endif /* configUSE_TRACE_FACILITY */
/*-----------------------------------------------------------*/
#if ( configGENERATE_RUN_TIME_STATS == 1 )
@ -2517,7 +2477,7 @@ tskTCB *pxNewTCB;
} while( pxNextTCB != pxFirstTCB );
}
#endif
#endif /* configGENERATE_RUN_TIME_STATS */
/*-----------------------------------------------------------*/
#if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )
@ -2537,7 +2497,7 @@ tskTCB *pxNewTCB;
return usCount;
}
#endif
#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) */
/*-----------------------------------------------------------*/
#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
@ -2565,7 +2525,7 @@ tskTCB *pxNewTCB;
return uxReturn;
}
#endif
#endif /* INCLUDE_uxTaskGetStackHighWaterMark */
/*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskDelete == 1 )
@ -2583,9 +2543,7 @@ tskTCB *pxNewTCB;
vPortFree( pxTCB );
}
#endif
#endif /* INCLUDE_vTaskDelete */
/*-----------------------------------------------------------*/
#if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )
@ -2602,8 +2560,7 @@ tskTCB *pxNewTCB;
return xReturn;
}
#endif
#endif /* ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */
/*-----------------------------------------------------------*/
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
@ -2631,7 +2588,7 @@ tskTCB *pxNewTCB;
return xReturn;
}
#endif
#endif /* ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) */
/*-----------------------------------------------------------*/
#if ( configUSE_MUTEXES == 1 )
@ -2673,7 +2630,7 @@ tskTCB *pxNewTCB;
}
}
#endif
#endif /* configUSE_MUTEXES */
/*-----------------------------------------------------------*/
#if ( configUSE_MUTEXES == 1 )
@ -2703,7 +2660,7 @@ tskTCB *pxNewTCB;
}
}
#endif
#endif /* configUSE_MUTEXES */
/*-----------------------------------------------------------*/
#if ( portCRITICAL_NESTING_IN_TCB == 1 )
@ -2718,7 +2675,7 @@ tskTCB *pxNewTCB;
}
}
#endif
#endif /* portCRITICAL_NESTING_IN_TCB */
/*-----------------------------------------------------------*/
#if ( portCRITICAL_NESTING_IN_TCB == 1 )
@ -2737,9 +2694,9 @@ tskTCB *pxNewTCB;
}
}
}
}
}
#endif
#endif /* portCRITICAL_NESTING_IN_TCB */
/*-----------------------------------------------------------*/