Add configUSE_MINI_LIST_ITEM configuration option to enable the MiniListItem_t type. (#433)

* Add configUSE_MINI_LIST_ITEM configuration option to enable the MiniListItem_t type.

When configUSE_MINI_LIST_ITEM == 0:
	MiniListItem_t and ListItem_t are both typedefs of struct xLIST_ITEM.

When configUSE_MINI_LIST_ITEM == 1 (the default in projdefs.h):
	MiniListItem_t is a typedef of struct xMINI_LIST_ITEM, which contains 3 fewer fields than a struct xLIST_ITEM.
	This configuration saves approximately sizeof(TickType_t) + 2 * sizeof( void * ) bytes of ram, however it also violates strict aliasing rules which some compilers depend on for optimization.

configUSE_MINI_LIST_ITEM defaults to 1 when not defined.

* Add pp_indent_brace option to uncrustify config

Improves compliance with the FreeRTOS code style guide:
https://www.freertos.org/FreeRTOS-Coding-Standard-and-Style-Guide.html
This commit is contained in:
Paul Bartell 2022-01-19 13:12:57 -08:00 committed by GitHub
parent 043c2c7ef6
commit dca4f80a6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1173 additions and 1143 deletions

View File

@ -157,4 +157,5 @@ pp_indent_at_level = true # false/true
pp_indent_count = 4 # unsigned number pp_indent_count = 4 # unsigned number
pp_space = remove # ignore/add/remove/force pp_space = remove # ignore/add/remove/force
pp_if_indent_code = true # false/true pp_if_indent_code = true # false/true
pp_indent_brace = false # true/false
# option(s) with 'not default' value: 158 # option(s) with 'not default' value: 158

View File

@ -7,6 +7,12 @@ Documentation and download available at https://www.FreeRTOS.org/
The new function xTimerGetAutoReload() provides the auto-reload state as The new function xTimerGetAutoReload() provides the auto-reload state as
a BaseType_t. The legacy function uxTimerGetAutoReload is retained with the a BaseType_t. The legacy function uxTimerGetAutoReload is retained with the
original UBaseType_t return value. original UBaseType_t return value.
+ Introduce the configUSE_MINI_LIST_ITEM configuration option. When this
option is set to 1, ListItem_t and MiniLitItem_t remain separate types.
However, when configUSE_MINI_LIST_ITEM == 0, MiniLitItem_t and ListItem_t
are both typedefs of the same struct xLIST_ITEM. This addresses some issues
observed when strict-aliasing and link time optimization are enabled.
To maintain backwards compatibility, configUSE_MINI_LIST_ITEM defaults to 1.
Changes between FreeRTOS V10.4.4 and FreeRTOS V10.4.5 released September 10 2021 Changes between FreeRTOS V10.4.4 and FreeRTOS V10.4.5 released September 10 2021

View File

@ -101,13 +101,13 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits,
configASSERT( pxEventGroupBuffer ); configASSERT( pxEventGroupBuffer );
#if ( configASSERT_DEFINED == 1 ) #if ( configASSERT_DEFINED == 1 )
{ {
/* Sanity check that the size of the structure used to declare a /* Sanity check that the size of the structure used to declare a
* variable of type StaticEventGroup_t equals the size of the real * variable of type StaticEventGroup_t equals the size of the real
* event group structure. */ * event group structure. */
volatile size_t xSize = sizeof( StaticEventGroup_t ); volatile size_t xSize = sizeof( StaticEventGroup_t );
configASSERT( xSize == sizeof( EventGroup_t ) ); configASSERT( xSize == sizeof( EventGroup_t ) );
} /*lint !e529 xSize is referenced if configASSERT() is defined. */ } /*lint !e529 xSize is referenced if configASSERT() is defined. */
#endif /* configASSERT_DEFINED */ #endif /* configASSERT_DEFINED */
/* The user has provided a statically allocated event group - use it. */ /* The user has provided a statically allocated event group - use it. */
@ -119,12 +119,12 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits,
vListInitialise( &( pxEventBits->xTasksWaitingForBits ) ); vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{ {
/* Both static and dynamic allocation can be used, so note that /* Both static and dynamic allocation can be used, so note that
* this event group was created statically in case the event group * this event group was created statically in case the event group
* is later deleted. */ * is later deleted. */
pxEventBits->ucStaticallyAllocated = pdTRUE; pxEventBits->ucStaticallyAllocated = pdTRUE;
} }
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
traceEVENT_GROUP_CREATE( pxEventBits ); traceEVENT_GROUP_CREATE( pxEventBits );
@ -170,12 +170,12 @@ static BaseType_t prvTestWaitCondition( const EventBits_t uxCurrentEventBits,
vListInitialise( &( pxEventBits->xTasksWaitingForBits ) ); vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );
#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
{ {
/* Both static and dynamic allocation can be used, so note this /* Both static and dynamic allocation can be used, so note this
* event group was allocated statically in case the event group is * event group was allocated statically in case the event group is
* later deleted. */ * later deleted. */
pxEventBits->ucStaticallyAllocated = pdFALSE; pxEventBits->ucStaticallyAllocated = pdFALSE;
} }
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
traceEVENT_GROUP_CREATE( pxEventBits ); traceEVENT_GROUP_CREATE( pxEventBits );
@ -204,9 +204,9 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ); configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
configASSERT( uxBitsToWaitFor != 0 ); configASSERT( uxBitsToWaitFor != 0 );
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{ {
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
} }
#endif #endif
vTaskSuspendAll(); vTaskSuspendAll();
@ -331,9 +331,9 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ); configASSERT( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
configASSERT( uxBitsToWaitFor != 0 ); configASSERT( uxBitsToWaitFor != 0 );
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{ {
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
} }
#endif #endif
vTaskSuspendAll(); vTaskSuspendAll();
@ -649,24 +649,24 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup )
( void ) xTaskResumeAll(); ( void ) xTaskResumeAll();
#if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
{
/* The event group can only have been allocated dynamically - free
* it again. */
vPortFree( pxEventBits );
}
#elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
{
/* The event group could have been allocated statically or
* dynamically, so check before attempting to free the memory. */
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
{ {
/* The event group can only have been allocated dynamically - free
* it again. */
vPortFree( pxEventBits ); vPortFree( pxEventBits );
} }
#elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) else
{ {
/* The event group could have been allocated statically or mtCOVERAGE_TEST_MARKER();
* dynamically, so check before attempting to free the memory. */
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
{
vPortFree( pxEventBits );
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
}
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

View File

@ -334,6 +334,10 @@
#define pcQueueGetName( xQueue ) #define pcQueueGetName( xQueue )
#endif #endif
#ifndef configUSE_MINI_LIST_ITEM
#define configUSE_MINI_LIST_ITEM 1
#endif
#ifndef portPOINTER_SIZE_TYPE #ifndef portPOINTER_SIZE_TYPE
#define portPOINTER_SIZE_TYPE uint32_t #define portPOINTER_SIZE_TYPE uint32_t
#endif #endif
@ -1134,16 +1138,20 @@ struct xSTATIC_LIST_ITEM
}; };
typedef struct xSTATIC_LIST_ITEM StaticListItem_t; typedef struct xSTATIC_LIST_ITEM StaticListItem_t;
/* See the comments above the struct xSTATIC_LIST_ITEM definition. */ #if ( configUSE_MINI_LIST_ITEM == 1 )
struct xSTATIC_MINI_LIST_ITEM /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
{ struct xSTATIC_MINI_LIST_ITEM
#if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) {
TickType_t xDummy1; #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
#endif TickType_t xDummy1;
TickType_t xDummy2; #endif
void * pvDummy3[ 2 ]; TickType_t xDummy2;
}; void * pvDummy3[ 2 ];
typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; };
typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t;
#else /* if ( configUSE_MINI_LIST_ITEM == 1 ) */
typedef struct xSTATIC_LIST_ITEM StaticMiniListItem_t;
#endif /* if ( configUSE_MINI_LIST_ITEM == 1 ) */
/* See the comments above the struct xSTATIC_LIST_ITEM definition. */ /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
typedef struct xSTATIC_LIST typedef struct xSTATIC_LIST

View File

@ -153,14 +153,18 @@ struct xLIST_ITEM
}; };
typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */
struct xMINI_LIST_ITEM #if ( configUSE_MINI_LIST_ITEM == 1 )
{ struct xMINI_LIST_ITEM
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ {
configLIST_VOLATILE TickType_t xItemValue; listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
struct xLIST_ITEM * configLIST_VOLATILE pxNext; configLIST_VOLATILE TickType_t xItemValue;
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; struct xLIST_ITEM * configLIST_VOLATILE pxNext;
}; struct xLIST_ITEM * configLIST_VOLATILE pxPrevious;
typedef struct xMINI_LIST_ITEM MiniListItem_t; };
typedef struct xMINI_LIST_ITEM MiniListItem_t;
#else
typedef struct xLIST_ITEM MiniListItem_t;
#endif
/* /*
* Definition of the type of queue used by the scheduler. * Definition of the type of queue used by the scheduler.

11
list.c
View File

@ -54,6 +54,8 @@ void vListInitialise( List_t * const pxList )
* as the only list entry. */ * as the only list entry. */
pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */ pxList->pxIndex = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( &( pxList->xListEnd ) );
/* The list end value is the highest possible value in the list to /* The list end value is the highest possible value in the list to
* ensure it remains at the end of the list. */ * ensure it remains at the end of the list. */
pxList->xListEnd.xItemValue = portMAX_DELAY; pxList->xListEnd.xItemValue = portMAX_DELAY;
@ -63,6 +65,15 @@ void vListInitialise( List_t * const pxList )
pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */ pxList->xListEnd.pxNext = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */ pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
/* Initialize the remaining fields of xListEnd when it is a proper ListItem_t */
#if ( configUSE_MINI_LIST_ITEM == 0 )
{
pxList->xListEnd.pvOwner = NULL;
pxList->xListEnd.pxContainer = NULL;
listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( &( pxList->xListEnd ) );
}
#endif
pxList->uxNumberOfItems = ( UBaseType_t ) 0U; pxList->uxNumberOfItems = ( UBaseType_t ) 0U;
/* Write known values into the list if /* Write known values into the list if

592
queue.c
View File

@ -383,16 +383,16 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ) ) ( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ) )
{ {
#if ( configASSERT_DEFINED == 1 ) #if ( configASSERT_DEFINED == 1 )
{ {
/* Sanity check that the size of the structure used to declare a /* Sanity check that the size of the structure used to declare a
* variable of type StaticQueue_t or StaticSemaphore_t equals the size of * variable of type StaticQueue_t or StaticSemaphore_t equals the size of
* the real queue and semaphore structures. */ * the real queue and semaphore structures. */
volatile size_t xSize = sizeof( StaticQueue_t ); volatile size_t xSize = sizeof( StaticQueue_t );
/* This assertion cannot be branch covered in unit tests */ /* This assertion cannot be branch covered in unit tests */
configASSERT( xSize == sizeof( Queue_t ) ); /* LCOV_EXCL_BR_LINE */ configASSERT( xSize == sizeof( Queue_t ) ); /* LCOV_EXCL_BR_LINE */
( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */ ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */
} }
#endif /* configASSERT_DEFINED */ #endif /* configASSERT_DEFINED */
/* The address of a statically allocated queue was passed in, use it. /* The address of a statically allocated queue was passed in, use it.
@ -401,12 +401,12 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{ {
/* Queues can be allocated wither statically or dynamically, so /* Queues can be allocated wither statically or dynamically, so
* note this queue was allocated statically in case the queue is * note this queue was allocated statically in case the queue is
* later deleted. */ * later deleted. */
pxNewQueue->ucStaticallyAllocated = pdTRUE; pxNewQueue->ucStaticallyAllocated = pdTRUE;
} }
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue ); prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue );
@ -463,12 +463,12 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
pucQueueStorage += sizeof( Queue_t ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ pucQueueStorage += sizeof( Queue_t ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */
#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
{ {
/* Queues can be created either statically or dynamically, so /* Queues can be created either statically or dynamically, so
* note this task was created dynamically in case it is later * note this task was created dynamically in case it is later
* deleted. */ * deleted. */
pxNewQueue->ucStaticallyAllocated = pdFALSE; pxNewQueue->ucStaticallyAllocated = pdFALSE;
} }
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue ); prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue );
@ -522,15 +522,15 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength,
( void ) xQueueGenericReset( pxNewQueue, pdTRUE ); ( void ) xQueueGenericReset( pxNewQueue, pdTRUE );
#if ( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
{ {
pxNewQueue->ucQueueType = ucQueueType; pxNewQueue->ucQueueType = ucQueueType;
} }
#endif /* configUSE_TRACE_FACILITY */ #endif /* configUSE_TRACE_FACILITY */
#if ( configUSE_QUEUE_SETS == 1 ) #if ( configUSE_QUEUE_SETS == 1 )
{ {
pxNewQueue->pxQueueSetContainer = NULL; pxNewQueue->pxQueueSetContainer = NULL;
} }
#endif /* configUSE_QUEUE_SETS */ #endif /* configUSE_QUEUE_SETS */
traceQUEUE_CREATE( pxNewQueue ); traceQUEUE_CREATE( pxNewQueue );
@ -845,9 +845,9 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) );
configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) ); configASSERT( !( ( xCopyPosition == queueOVERWRITE ) && ( pxQueue->uxLength != 1 ) ) );
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{ {
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
} }
#endif #endif
/*lint -save -e904 This function relaxes the coding standard somewhat to /*lint -save -e904 This function relaxes the coding standard somewhat to
@ -866,69 +866,34 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
traceQUEUE_SEND( pxQueue ); traceQUEUE_SEND( pxQueue );
#if ( configUSE_QUEUE_SETS == 1 ) #if ( configUSE_QUEUE_SETS == 1 )
{
const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting;
xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
if( pxQueue->pxQueueSetContainer != NULL )
{ {
const UBaseType_t uxPreviousMessagesWaiting = pxQueue->uxMessagesWaiting; if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) )
xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
if( pxQueue->pxQueueSetContainer != NULL )
{ {
if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) ) /* Do not notify the queue set as an existing item
{ * was overwritten in the queue so the number of items
/* Do not notify the queue set as an existing item * in the queue has not changed. */
* was overwritten in the queue so the number of items mtCOVERAGE_TEST_MARKER();
* in the queue has not changed. */ }
mtCOVERAGE_TEST_MARKER(); else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
} {
else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE ) /* The queue is a member of a queue set, and posting
{ * to the queue set caused a higher priority task to
/* The queue is a member of a queue set, and posting * unblock. A context switch is required. */
* to the queue set caused a higher priority task to queueYIELD_IF_USING_PREEMPTION();
* unblock. A context switch is required. */
queueYIELD_IF_USING_PREEMPTION();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
else else
{ {
/* If there was a task waiting for data to arrive on the mtCOVERAGE_TEST_MARKER();
* queue then unblock it now. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The unblocked task has a priority higher than
* our own so yield immediately. Yes it is ok to
* do this from within the critical section - the
* kernel takes care of that. */
queueYIELD_IF_USING_PREEMPTION();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else if( xYieldRequired != pdFALSE )
{
/* This path is a special case that will only get
* executed if the task was holding multiple mutexes
* and the mutexes were given back in an order that is
* different to that in which they were taken. */
queueYIELD_IF_USING_PREEMPTION();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
} }
#else /* configUSE_QUEUE_SETS */ else
{ {
xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
/* If there was a task waiting for data to arrive on the /* If there was a task waiting for data to arrive on the
* queue then unblock it now. */ * queue then unblock it now. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
@ -936,9 +901,9 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{ {
/* The unblocked task has a priority higher than /* The unblocked task has a priority higher than
* our own so yield immediately. Yes it is ok to do * our own so yield immediately. Yes it is ok to
* this from within the critical section - the kernel * do this from within the critical section - the
* takes care of that. */ * kernel takes care of that. */
queueYIELD_IF_USING_PREEMPTION(); queueYIELD_IF_USING_PREEMPTION();
} }
else else
@ -949,8 +914,8 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
else if( xYieldRequired != pdFALSE ) else if( xYieldRequired != pdFALSE )
{ {
/* This path is a special case that will only get /* This path is a special case that will only get
* executed if the task was holding multiple mutexes and * executed if the task was holding multiple mutexes
* the mutexes were given back in an order that is * and the mutexes were given back in an order that is
* different to that in which they were taken. */ * different to that in which they were taken. */
queueYIELD_IF_USING_PREEMPTION(); queueYIELD_IF_USING_PREEMPTION();
} }
@ -959,6 +924,41 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
mtCOVERAGE_TEST_MARKER(); mtCOVERAGE_TEST_MARKER();
} }
} }
}
#else /* configUSE_QUEUE_SETS */
{
xYieldRequired = prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );
/* If there was a task waiting for data to arrive on the
* queue then unblock it now. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The unblocked task has a priority higher than
* our own so yield immediately. Yes it is ok to do
* this from within the critical section - the kernel
* takes care of that. */
queueYIELD_IF_USING_PREEMPTION();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else if( xYieldRequired != pdFALSE )
{
/* This path is a special case that will only get
* executed if the task was holding multiple mutexes and
* the mutexes were given back in an order that is
* different to that in which they were taken. */
queueYIELD_IF_USING_PREEMPTION();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* configUSE_QUEUE_SETS */ #endif /* configUSE_QUEUE_SETS */
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
@ -1099,29 +1099,24 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
if( cTxLock == queueUNLOCKED ) if( cTxLock == queueUNLOCKED )
{ {
#if ( configUSE_QUEUE_SETS == 1 ) #if ( configUSE_QUEUE_SETS == 1 )
{
if( pxQueue->pxQueueSetContainer != NULL )
{ {
if( pxQueue->pxQueueSetContainer != NULL ) if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) )
{ {
if( ( xCopyPosition == queueOVERWRITE ) && ( uxPreviousMessagesWaiting != ( UBaseType_t ) 0 ) ) /* Do not notify the queue set as an existing item
* was overwritten in the queue so the number of items
* in the queue has not changed. */
mtCOVERAGE_TEST_MARKER();
}
else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* The queue is a member of a queue set, and posting
* to the queue set caused a higher priority task to
* unblock. A context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{ {
/* Do not notify the queue set as an existing item *pxHigherPriorityTaskWoken = pdTRUE;
* was overwritten in the queue so the number of items
* in the queue has not changed. */
mtCOVERAGE_TEST_MARKER();
}
else if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{
/* The queue is a member of a queue set, and posting
* to the queue set caused a higher priority task to
* unblock. A context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
else else
{ {
@ -1130,40 +1125,17 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
} }
else else
{ {
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) mtCOVERAGE_TEST_MARKER();
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so
* record that a context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
} }
#else /* configUSE_QUEUE_SETS */ else
{ {
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{ {
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{ {
/* The task waiting has a higher priority so record that a /* The task waiting has a higher priority so
* context switch is required. */ * record that a context switch is required. */
if( pxHigherPriorityTaskWoken != NULL ) if( pxHigherPriorityTaskWoken != NULL )
{ {
*pxHigherPriorityTaskWoken = pdTRUE; *pxHigherPriorityTaskWoken = pdTRUE;
@ -1182,10 +1154,38 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
{ {
mtCOVERAGE_TEST_MARKER(); mtCOVERAGE_TEST_MARKER();
} }
/* Not used in this path. */
( void ) uxPreviousMessagesWaiting;
} }
}
#else /* configUSE_QUEUE_SETS */
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that a
* context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
/* Not used in this path. */
( void ) uxPreviousMessagesWaiting;
}
#endif /* configUSE_QUEUE_SETS */ #endif /* configUSE_QUEUE_SETS */
} }
else else
@ -1275,22 +1275,17 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
if( cTxLock == queueUNLOCKED ) if( cTxLock == queueUNLOCKED )
{ {
#if ( configUSE_QUEUE_SETS == 1 ) #if ( configUSE_QUEUE_SETS == 1 )
{
if( pxQueue->pxQueueSetContainer != NULL )
{ {
if( pxQueue->pxQueueSetContainer != NULL ) if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{ {
if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE ) /* The semaphore is a member of a queue set, and
* posting to the queue set caused a higher priority
* task to unblock. A context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{ {
/* The semaphore is a member of a queue set, and *pxHigherPriorityTaskWoken = pdTRUE;
* posting to the queue set caused a higher priority
* task to unblock. A context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
else else
{ {
@ -1299,40 +1294,17 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
} }
else else
{ {
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) mtCOVERAGE_TEST_MARKER();
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so
* record that a context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
} }
#else /* configUSE_QUEUE_SETS */ else
{ {
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{ {
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{ {
/* The task waiting has a higher priority so record that a /* The task waiting has a higher priority so
* context switch is required. */ * record that a context switch is required. */
if( pxHigherPriorityTaskWoken != NULL ) if( pxHigherPriorityTaskWoken != NULL )
{ {
*pxHigherPriorityTaskWoken = pdTRUE; *pxHigherPriorityTaskWoken = pdTRUE;
@ -1352,6 +1324,34 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
mtCOVERAGE_TEST_MARKER(); mtCOVERAGE_TEST_MARKER();
} }
} }
}
#else /* configUSE_QUEUE_SETS */
{
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that a
* context switch is required. */
if( pxHigherPriorityTaskWoken != NULL )
{
*pxHigherPriorityTaskWoken = pdTRUE;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* configUSE_QUEUE_SETS */ #endif /* configUSE_QUEUE_SETS */
} }
else else
@ -1392,9 +1392,9 @@ BaseType_t xQueueReceive( QueueHandle_t xQueue,
/* Cannot block if the scheduler is suspended. */ /* Cannot block if the scheduler is suspended. */
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{ {
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
} }
#endif #endif
/*lint -save -e904 This function relaxes the coding standard somewhat to /*lint -save -e904 This function relaxes the coding standard somewhat to
@ -1538,9 +1538,9 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
/* Cannot block if the scheduler is suspended. */ /* Cannot block if the scheduler is suspended. */
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{ {
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
} }
#endif #endif
/*lint -save -e904 This function relaxes the coding standard somewhat to allow return /*lint -save -e904 This function relaxes the coding standard somewhat to allow return
@ -1565,18 +1565,18 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
pxQueue->uxMessagesWaiting = uxSemaphoreCount - ( UBaseType_t ) 1; pxQueue->uxMessagesWaiting = uxSemaphoreCount - ( UBaseType_t ) 1;
#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
{
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
{ {
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) /* Record the information required to implement
{ * priority inheritance should it become necessary. */
/* Record the information required to implement pxQueue->u.xSemaphore.xMutexHolder = pvTaskIncrementMutexHeldCount();
* priority inheritance should it become necessary. */
pxQueue->u.xSemaphore.xMutexHolder = pvTaskIncrementMutexHeldCount();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
else
{
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* configUSE_MUTEXES */ #endif /* configUSE_MUTEXES */
/* Check to see if other tasks are blocked waiting to give the /* Check to see if other tasks are blocked waiting to give the
@ -1608,9 +1608,9 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
* initial timeout, and an adjusted timeout cannot become 0, as * initial timeout, and an adjusted timeout cannot become 0, as
* if it were 0 the function would have exited. */ * if it were 0 the function would have exited. */
#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
{ {
configASSERT( xInheritanceOccurred == pdFALSE ); configASSERT( xInheritanceOccurred == pdFALSE );
} }
#endif /* configUSE_MUTEXES */ #endif /* configUSE_MUTEXES */
/* The semaphore count was 0 and no block time is specified /* The semaphore count was 0 and no block time is specified
@ -1653,20 +1653,20 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ); traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
{
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
{ {
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) taskENTER_CRITICAL();
{ {
taskENTER_CRITICAL(); xInheritanceOccurred = xTaskPriorityInherit( pxQueue->u.xSemaphore.xMutexHolder );
{
xInheritanceOccurred = xTaskPriorityInherit( pxQueue->u.xSemaphore.xMutexHolder );
}
taskEXIT_CRITICAL();
}
else
{
mtCOVERAGE_TEST_MARKER();
} }
taskEXIT_CRITICAL();
} }
else
{
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* if ( configUSE_MUTEXES == 1 ) */ #endif /* if ( configUSE_MUTEXES == 1 ) */
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
@ -1702,27 +1702,27 @@ BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
if( prvIsQueueEmpty( pxQueue ) != pdFALSE ) if( prvIsQueueEmpty( pxQueue ) != pdFALSE )
{ {
#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
{
/* xInheritanceOccurred could only have be set if
* pxQueue->uxQueueType == queueQUEUE_IS_MUTEX so no need to
* test the mutex type again to check it is actually a mutex. */
if( xInheritanceOccurred != pdFALSE )
{ {
/* xInheritanceOccurred could only have be set if taskENTER_CRITICAL();
* pxQueue->uxQueueType == queueQUEUE_IS_MUTEX so no need to
* test the mutex type again to check it is actually a mutex. */
if( xInheritanceOccurred != pdFALSE )
{ {
taskENTER_CRITICAL(); UBaseType_t uxHighestWaitingPriority;
{
UBaseType_t uxHighestWaitingPriority;
/* This task blocking on the mutex caused another /* This task blocking on the mutex caused another
* task to inherit this task's priority. Now this task * task to inherit this task's priority. Now this task
* has timed out the priority should be disinherited * has timed out the priority should be disinherited
* again, but only as low as the next highest priority * again, but only as low as the next highest priority
* task that is waiting for the same mutex. */ * task that is waiting for the same mutex. */
uxHighestWaitingPriority = prvGetDisinheritPriorityAfterTimeout( pxQueue ); uxHighestWaitingPriority = prvGetDisinheritPriorityAfterTimeout( pxQueue );
vTaskPriorityDisinheritAfterTimeout( pxQueue->u.xSemaphore.xMutexHolder, uxHighestWaitingPriority ); vTaskPriorityDisinheritAfterTimeout( pxQueue->u.xSemaphore.xMutexHolder, uxHighestWaitingPriority );
}
taskEXIT_CRITICAL();
} }
taskEXIT_CRITICAL();
} }
}
#endif /* configUSE_MUTEXES */ #endif /* configUSE_MUTEXES */
traceQUEUE_RECEIVE_FAILED( pxQueue ); traceQUEUE_RECEIVE_FAILED( pxQueue );
@ -1755,9 +1755,9 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue,
/* Cannot block if the scheduler is suspended. */ /* Cannot block if the scheduler is suspended. */
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
{ {
configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ); configASSERT( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) );
} }
#endif #endif
/*lint -save -e904 This function relaxes the coding standard somewhat to /*lint -save -e904 This function relaxes the coding standard somewhat to
@ -2089,36 +2089,36 @@ void vQueueDelete( QueueHandle_t xQueue )
traceQUEUE_DELETE( pxQueue ); traceQUEUE_DELETE( pxQueue );
#if ( configQUEUE_REGISTRY_SIZE > 0 ) #if ( configQUEUE_REGISTRY_SIZE > 0 )
{ {
vQueueUnregisterQueue( pxQueue ); vQueueUnregisterQueue( pxQueue );
} }
#endif #endif
#if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
{
/* The queue can only have been allocated dynamically - free it
* again. */
vPortFree( pxQueue );
}
#elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
{
/* The queue could have been allocated statically or dynamically, so
* check before attempting to free the memory. */
if( pxQueue->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
{ {
/* The queue can only have been allocated dynamically - free it
* again. */
vPortFree( pxQueue ); vPortFree( pxQueue );
} }
#elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) else
{ {
/* The queue could have been allocated statically or dynamically, so mtCOVERAGE_TEST_MARKER();
* check before attempting to free the memory. */
if( pxQueue->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
{
vPortFree( pxQueue );
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
}
#else /* if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) */ #else /* if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) */
{ {
/* The queue must have been statically allocated, so is not going to be /* The queue must have been statically allocated, so is not going to be
* deleted. Avoid compiler warnings about the unused parameter. */ * deleted. Avoid compiler warnings about the unused parameter. */
( void ) pxQueue; ( void ) pxQueue;
} }
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -2195,18 +2195,18 @@ static BaseType_t prvCopyDataToQueue( Queue_t * const pxQueue,
if( pxQueue->uxItemSize == ( UBaseType_t ) 0 ) if( pxQueue->uxItemSize == ( UBaseType_t ) 0 )
{ {
#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
{
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
{ {
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX ) /* The mutex is no longer being held. */
{ xReturn = xTaskPriorityDisinherit( pxQueue->u.xSemaphore.xMutexHolder );
/* The mutex is no longer being held. */ pxQueue->u.xSemaphore.xMutexHolder = NULL;
xReturn = xTaskPriorityDisinherit( pxQueue->u.xSemaphore.xMutexHolder );
pxQueue->u.xSemaphore.xMutexHolder = NULL;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
else
{
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* configUSE_MUTEXES */ #endif /* configUSE_MUTEXES */
} }
else if( xPosition == queueSEND_TO_BACK ) else if( xPosition == queueSEND_TO_BACK )
@ -2303,55 +2303,32 @@ static void prvUnlockQueue( Queue_t * const pxQueue )
/* Data was posted while the queue was locked. Are any tasks /* Data was posted while the queue was locked. Are any tasks
* blocked waiting for data to become available? */ * blocked waiting for data to become available? */
#if ( configUSE_QUEUE_SETS == 1 ) #if ( configUSE_QUEUE_SETS == 1 )
{
if( pxQueue->pxQueueSetContainer != NULL )
{ {
if( pxQueue->pxQueueSetContainer != NULL ) if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE )
{ {
if( prvNotifyQueueSetContainer( pxQueue ) != pdFALSE ) /* The queue is a member of a queue set, and posting to
{ * the queue set caused a higher priority task to unblock.
/* The queue is a member of a queue set, and posting to * A context switch is required. */
* the queue set caused a higher priority task to unblock. vTaskMissedYield();
* A context switch is required. */
vTaskMissedYield();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
else else
{ {
/* Tasks that are removed from the event list will get mtCOVERAGE_TEST_MARKER();
* added to the pending ready list as the scheduler is still
* suspended. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that a
* context switch is required. */
vTaskMissedYield();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
break;
}
} }
} }
#else /* configUSE_QUEUE_SETS */ else
{ {
/* Tasks that are removed from the event list will get added to /* Tasks that are removed from the event list will get
* the pending ready list as the scheduler is still suspended. */ * added to the pending ready list as the scheduler is still
* suspended. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE ) if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{ {
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{ {
/* The task waiting has a higher priority so record that /* The task waiting has a higher priority so record that a
* a context switch is required. */ * context switch is required. */
vTaskMissedYield(); vTaskMissedYield();
} }
else else
@ -2364,6 +2341,29 @@ static void prvUnlockQueue( Queue_t * const pxQueue )
break; break;
} }
} }
}
#else /* configUSE_QUEUE_SETS */
{
/* Tasks that are removed from the event list will get added to
* the pending ready list as the scheduler is still suspended. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )
{
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{
/* The task waiting has a higher priority so record that
* a context switch is required. */
vTaskMissedYield();
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
else
{
break;
}
}
#endif /* configUSE_QUEUE_SETS */ #endif /* configUSE_QUEUE_SETS */
--cTxLock; --cTxLock;

View File

@ -345,13 +345,13 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH ); configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH );
#if ( configASSERT_DEFINED == 1 ) #if ( configASSERT_DEFINED == 1 )
{ {
/* Sanity check that the size of the structure used to declare a /* Sanity check that the size of the structure used to declare a
* variable of type StaticStreamBuffer_t equals the size of the real * variable of type StaticStreamBuffer_t equals the size of the real
* message buffer structure. */ * message buffer structure. */
volatile size_t xSize = sizeof( StaticStreamBuffer_t ); volatile size_t xSize = sizeof( StaticStreamBuffer_t );
configASSERT( xSize == sizeof( StreamBuffer_t ) ); configASSERT( xSize == sizeof( StreamBuffer_t ) );
} /*lint !e529 xSize is referenced is configASSERT() is defined. */ } /*lint !e529 xSize is referenced is configASSERT() is defined. */
#endif /* configASSERT_DEFINED */ #endif /* configASSERT_DEFINED */
if( ( pucStreamBufferStorageArea != NULL ) && ( pxStaticStreamBuffer != NULL ) ) if( ( pucStreamBufferStorageArea != NULL ) && ( pxStaticStreamBuffer != NULL ) )
@ -393,17 +393,17 @@ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer )
if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) pdFALSE ) if( ( pxStreamBuffer->ucFlags & sbFLAGS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) pdFALSE )
{ {
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{ {
/* Both the structure and the buffer were allocated using a single call /* Both the structure and the buffer were allocated using a single call
* to pvPortMalloc(), hence only one call to vPortFree() is required. */ * to pvPortMalloc(), hence only one call to vPortFree() is required. */
vPortFree( ( void * ) pxStreamBuffer ); /*lint !e9087 Standard free() semantics require void *, plus pxStreamBuffer was allocated by pvPortMalloc(). */ vPortFree( ( void * ) pxStreamBuffer ); /*lint !e9087 Standard free() semantics require void *, plus pxStreamBuffer was allocated by pvPortMalloc(). */
} }
#else #else
{ {
/* Should not be possible to get here, ucFlags must be corrupt. /* Should not be possible to get here, ucFlags must be corrupt.
* Force an assert. */ * Force an assert. */
configASSERT( xStreamBuffer == ( StreamBufferHandle_t ) ~0 ); configASSERT( xStreamBuffer == ( StreamBufferHandle_t ) ~0 );
} }
#endif #endif
} }
else else
@ -427,11 +427,11 @@ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )
configASSERT( pxStreamBuffer ); configASSERT( pxStreamBuffer );
#if ( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
{ {
/* Store the stream buffer number so it can be restored after the /* Store the stream buffer number so it can be restored after the
* reset. */ * reset. */
uxStreamBufferNumber = pxStreamBuffer->uxStreamBufferNumber; uxStreamBufferNumber = pxStreamBuffer->uxStreamBufferNumber;
} }
#endif #endif
/* Can only reset a message buffer if there are no tasks blocked on it. */ /* Can only reset a message buffer if there are no tasks blocked on it. */
@ -449,9 +449,9 @@ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )
xReturn = pdPASS; xReturn = pdPASS;
#if ( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
{ {
pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber; pxStreamBuffer->uxStreamBufferNumber = uxStreamBufferNumber;
} }
#endif #endif
traceSTREAM_BUFFER_RESET( xStreamBuffer ); traceSTREAM_BUFFER_RESET( xStreamBuffer );
@ -1266,13 +1266,13 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
* be written to without generating exceptions, and is setting the buffer to a * be written to without generating exceptions, and is setting the buffer to a
* known value to assist in development/debugging. */ * known value to assist in development/debugging. */
#if ( configASSERT_DEFINED == 1 ) #if ( configASSERT_DEFINED == 1 )
{ {
/* The value written just has to be identifiable when looking at the /* The value written just has to be identifiable when looking at the
* memory. Don't use 0xA5 as that is the stack fill value and could * memory. Don't use 0xA5 as that is the stack fill value and could
* result in confusion as to what is actually being observed. */ * result in confusion as to what is actually being observed. */
const BaseType_t xWriteValue = 0x55; const BaseType_t xWriteValue = 0x55;
configASSERT( memset( pucBuffer, ( int ) xWriteValue, xBufferSizeBytes ) == pucBuffer ); configASSERT( memset( pucBuffer, ( int ) xWriteValue, xBufferSizeBytes ) == pucBuffer );
} /*lint !e529 !e438 xWriteValue is only used if configASSERT() is defined. */ } /*lint !e529 !e438 xWriteValue is only used if configASSERT() is defined. */
#endif #endif
( void ) memset( ( void * ) pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); /*lint !e9087 memset() requires void *. */ ( void ) memset( ( void * ) pxStreamBuffer, 0x00, sizeof( StreamBuffer_t ) ); /*lint !e9087 memset() requires void *. */

1338
tasks.c

File diff suppressed because it is too large Load Diff

180
timers.c
View File

@ -243,34 +243,34 @@
if( xTimerQueue != NULL ) if( xTimerQueue != NULL )
{ {
#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
{
StaticTask_t * pxTimerTaskTCBBuffer = NULL;
StackType_t * pxTimerTaskStackBuffer = NULL;
uint32_t ulTimerTaskStackSize;
vApplicationGetTimerTaskMemory( &pxTimerTaskTCBBuffer, &pxTimerTaskStackBuffer, &ulTimerTaskStackSize );
xTimerTaskHandle = xTaskCreateStatic( prvTimerTask,
configTIMER_SERVICE_TASK_NAME,
ulTimerTaskStackSize,
NULL,
( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
pxTimerTaskStackBuffer,
pxTimerTaskTCBBuffer );
if( xTimerTaskHandle != NULL )
{ {
StaticTask_t * pxTimerTaskTCBBuffer = NULL; xReturn = pdPASS;
StackType_t * pxTimerTaskStackBuffer = NULL;
uint32_t ulTimerTaskStackSize;
vApplicationGetTimerTaskMemory( &pxTimerTaskTCBBuffer, &pxTimerTaskStackBuffer, &ulTimerTaskStackSize );
xTimerTaskHandle = xTaskCreateStatic( prvTimerTask,
configTIMER_SERVICE_TASK_NAME,
ulTimerTaskStackSize,
NULL,
( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
pxTimerTaskStackBuffer,
pxTimerTaskTCBBuffer );
if( xTimerTaskHandle != NULL )
{
xReturn = pdPASS;
}
} }
}
#else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ #else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
{ {
xReturn = xTaskCreate( prvTimerTask, xReturn = xTaskCreate( prvTimerTask,
configTIMER_SERVICE_TASK_NAME, configTIMER_SERVICE_TASK_NAME,
configTIMER_TASK_STACK_DEPTH, configTIMER_TASK_STACK_DEPTH,
NULL, NULL,
( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT,
&xTimerTaskHandle ); &xTimerTaskHandle );
} }
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
} }
else else
@ -322,14 +322,14 @@
Timer_t * pxNewTimer; Timer_t * pxNewTimer;
#if ( configASSERT_DEFINED == 1 ) #if ( configASSERT_DEFINED == 1 )
{ {
/* Sanity check that the size of the structure used to declare a /* Sanity check that the size of the structure used to declare a
* variable of type StaticTimer_t equals the size of the real timer * variable of type StaticTimer_t equals the size of the real timer
* structure. */ * structure. */
volatile size_t xSize = sizeof( StaticTimer_t ); volatile size_t xSize = sizeof( StaticTimer_t );
configASSERT( xSize == sizeof( Timer_t ) ); configASSERT( xSize == sizeof( Timer_t ) );
( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */ ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */
} }
#endif /* configASSERT_DEFINED */ #endif /* configASSERT_DEFINED */
/* A pointer to a StaticTimer_t structure MUST be provided, use it. */ /* A pointer to a StaticTimer_t structure MUST be provided, use it. */
@ -574,15 +574,15 @@
( void ) pvParameters; ( void ) pvParameters;
#if ( configUSE_DAEMON_TASK_STARTUP_HOOK == 1 ) #if ( configUSE_DAEMON_TASK_STARTUP_HOOK == 1 )
{ {
extern void vApplicationDaemonTaskStartupHook( void ); extern void vApplicationDaemonTaskStartupHook( void );
/* Allow the application writer to execute some code in the context of /* Allow the application writer to execute some code in the context of
* this task at the point the task starts executing. This is useful if the * this task at the point the task starts executing. This is useful if the
* application includes initialisation code that would benefit from * application includes initialisation code that would benefit from
* executing after the scheduler has been started. */ * executing after the scheduler has been started. */
vApplicationDaemonTaskStartupHook(); vApplicationDaemonTaskStartupHook();
} }
#endif /* configUSE_DAEMON_TASK_STARTUP_HOOK */ #endif /* configUSE_DAEMON_TASK_STARTUP_HOOK */
for( ; ; ) for( ; ; )
@ -767,25 +767,25 @@
while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL ) /*lint !e603 xMessage does not have to be initialised as it is passed out, not in, and it is not used unless xQueueReceive() returns pdTRUE. */ while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL ) /*lint !e603 xMessage does not have to be initialised as it is passed out, not in, and it is not used unless xQueueReceive() returns pdTRUE. */
{ {
#if ( INCLUDE_xTimerPendFunctionCall == 1 ) #if ( INCLUDE_xTimerPendFunctionCall == 1 )
{
/* Negative commands are pended function calls rather than timer
* commands. */
if( xMessage.xMessageID < ( BaseType_t ) 0 )
{ {
/* Negative commands are pended function calls rather than timer const CallbackParameters_t * const pxCallback = &( xMessage.u.xCallbackParameters );
* commands. */
if( xMessage.xMessageID < ( BaseType_t ) 0 )
{
const CallbackParameters_t * const pxCallback = &( xMessage.u.xCallbackParameters );
/* The timer uses the xCallbackParameters member to request a /* The timer uses the xCallbackParameters member to request a
* callback be executed. Check the callback is not NULL. */ * callback be executed. Check the callback is not NULL. */
configASSERT( pxCallback ); configASSERT( pxCallback );
/* Call the function. */ /* Call the function. */
pxCallback->pxCallbackFunction( pxCallback->pvParameter1, pxCallback->ulParameter2 ); pxCallback->pxCallbackFunction( pxCallback->pvParameter1, pxCallback->ulParameter2 );
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
else
{
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* INCLUDE_xTimerPendFunctionCall */ #endif /* INCLUDE_xTimerPendFunctionCall */
/* Commands that are positive are timer commands rather than pended /* Commands that are positive are timer commands rather than pended
@ -872,27 +872,27 @@
case tmrCOMMAND_DELETE: case tmrCOMMAND_DELETE:
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
{
/* The timer has already been removed from the active list,
* just free up the memory if the memory was dynamically
* allocated. */
if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) 0 )
{ {
/* The timer has already been removed from the active list, vPortFree( pxTimer );
* just free up the memory if the memory was dynamically
* allocated. */
if( ( pxTimer->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) 0 )
{
vPortFree( pxTimer );
}
else
{
pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_ACTIVE );
}
} }
#else /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */ else
{ {
/* If dynamic allocation is not enabled, the memory
* could not have been dynamically allocated. So there is
* no need to free the memory - just mark the timer as
* "not active". */
pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_ACTIVE ); pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_ACTIVE );
} }
}
#else /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
{
/* If dynamic allocation is not enabled, the memory
* could not have been dynamically allocated. So there is
* no need to free the memory - just mark the timer as
* "not active". */
pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_ACTIVE );
}
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
break; break;
@ -945,31 +945,31 @@
pxOverflowTimerList = &xActiveTimerList2; pxOverflowTimerList = &xActiveTimerList2;
#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
{ {
/* The timer queue is allocated statically in case /* The timer queue is allocated statically in case
* configSUPPORT_DYNAMIC_ALLOCATION is 0. */ * configSUPPORT_DYNAMIC_ALLOCATION is 0. */
PRIVILEGED_DATA static StaticQueue_t xStaticTimerQueue; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */ PRIVILEGED_DATA static StaticQueue_t xStaticTimerQueue; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */
PRIVILEGED_DATA static uint8_t ucStaticTimerQueueStorage[ ( size_t ) configTIMER_QUEUE_LENGTH * sizeof( DaemonTaskMessage_t ) ]; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */ PRIVILEGED_DATA static uint8_t ucStaticTimerQueueStorage[ ( size_t ) configTIMER_QUEUE_LENGTH * sizeof( DaemonTaskMessage_t ) ]; /*lint !e956 Ok to declare in this manner to prevent additional conditional compilation guards in other locations. */
xTimerQueue = xQueueCreateStatic( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, ( UBaseType_t ) sizeof( DaemonTaskMessage_t ), &( ucStaticTimerQueueStorage[ 0 ] ), &xStaticTimerQueue ); xTimerQueue = xQueueCreateStatic( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, ( UBaseType_t ) sizeof( DaemonTaskMessage_t ), &( ucStaticTimerQueueStorage[ 0 ] ), &xStaticTimerQueue );
} }
#else #else
{ {
xTimerQueue = xQueueCreate( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, sizeof( DaemonTaskMessage_t ) ); xTimerQueue = xQueueCreate( ( UBaseType_t ) configTIMER_QUEUE_LENGTH, sizeof( DaemonTaskMessage_t ) );
} }
#endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
#if ( configQUEUE_REGISTRY_SIZE > 0 ) #if ( configQUEUE_REGISTRY_SIZE > 0 )
{
if( xTimerQueue != NULL )
{ {
if( xTimerQueue != NULL ) vQueueAddToRegistry( xTimerQueue, "TmrQ" );
{
vQueueAddToRegistry( xTimerQueue, "TmrQ" );
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
else
{
mtCOVERAGE_TEST_MARKER();
}
}
#endif /* configQUEUE_REGISTRY_SIZE */ #endif /* configQUEUE_REGISTRY_SIZE */
} }
else else