|
|
@ -445,6 +445,10 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const
|
|
|
|
signed portBASE_TYPE xEntryTimeSet = pdFALSE;
|
|
|
|
signed portBASE_TYPE xEntryTimeSet = pdFALSE;
|
|
|
|
xTimeOutType xTimeOut;
|
|
|
|
xTimeOutType xTimeOut;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This function relaxes the coding standard somewhat to allow return
|
|
|
|
|
|
|
|
statements within the function itself. This is done in the interest
|
|
|
|
|
|
|
|
of execution time efficiency. */
|
|
|
|
|
|
|
|
|
|
|
|
for( ;; )
|
|
|
|
for( ;; )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
taskENTER_CRITICAL();
|
|
|
@ -463,7 +467,9 @@ xTimeOutType xTimeOut;
|
|
|
|
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )
|
|
|
|
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* The unblocked task has a priority higher than
|
|
|
|
/* The unblocked task has a priority higher than
|
|
|
|
our own so yield immediately. */
|
|
|
|
our own so yield immediately. Yes it is ok to do
|
|
|
|
|
|
|
|
this from within the critical section - the kernel
|
|
|
|
|
|
|
|
takes care of that. */
|
|
|
|
taskYIELD();
|
|
|
|
taskYIELD();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -475,11 +481,15 @@ xTimeOutType xTimeOut;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( xTicksToWait == ( portTickType ) 0 )
|
|
|
|
if( xTicksToWait == ( portTickType ) 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* The queue was full and no block time is specified (or
|
|
|
|
|
|
|
|
the block time has expired) so leave now. */
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
return errQUEUE_FULL;
|
|
|
|
return errQUEUE_FULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( xEntryTimeSet == pdFALSE )
|
|
|
|
else if( xEntryTimeSet == pdFALSE )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* The queue was full and a block time was specified so
|
|
|
|
|
|
|
|
configure the timeout structure. */
|
|
|
|
vTaskSetTimeOutState( &xTimeOut );
|
|
|
|
vTaskSetTimeOutState( &xTimeOut );
|
|
|
|
xEntryTimeSet = pdTRUE;
|
|
|
|
xEntryTimeSet = pdTRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -487,16 +497,17 @@ xTimeOutType xTimeOut;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Interrupts and other tasks can send to and receive from the queue
|
|
|
|
|
|
|
|
now the critical section has been exited. */
|
|
|
|
|
|
|
|
|
|
|
|
vTaskSuspendAll();
|
|
|
|
vTaskSuspendAll();
|
|
|
|
prvLockQueue( pxQueue );
|
|
|
|
prvLockQueue( pxQueue );
|
|
|
|
|
|
|
|
|
|
|
|
if( prvIsQueueFull( pxQueue ) )
|
|
|
|
/* Update the timeout state to see if it has expired yet. */
|
|
|
|
|
|
|
|
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Need to call xTaskCheckForTimeout again as time could
|
|
|
|
if( prvIsQueueFull( pxQueue ) )
|
|
|
|
have passed since it was last called if this is not the
|
|
|
|
{
|
|
|
|
first time around this loop. */
|
|
|
|
|
|
|
|
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
traceBLOCKING_ON_QUEUE_SEND( pxQueue );
|
|
|
|
traceBLOCKING_ON_QUEUE_SEND( pxQueue );
|
|
|
|
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
|
|
|
|
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
|
|
|
|
|
|
|
|
|
|
|
@ -519,15 +530,17 @@ xTimeOutType xTimeOut;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Try again. */
|
|
|
|
prvUnlockQueue( pxQueue );
|
|
|
|
prvUnlockQueue( pxQueue );
|
|
|
|
( void ) xTaskResumeAll();
|
|
|
|
( void ) xTaskResumeAll();
|
|
|
|
return errQUEUE_FULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* The timeout has expired. */
|
|
|
|
prvUnlockQueue( pxQueue );
|
|
|
|
prvUnlockQueue( pxQueue );
|
|
|
|
( void ) xTaskResumeAll();
|
|
|
|
( void ) xTaskResumeAll();
|
|
|
|
|
|
|
|
return errQUEUE_FULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -584,22 +597,19 @@ xTimeOutType xTimeOut;
|
|
|
|
|
|
|
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( prvIsQueueFull( pxQueue ) )
|
|
|
|
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Need to call xTaskCheckForTimeout again as time could
|
|
|
|
if( prvIsQueueFull( pxQueue ) )
|
|
|
|
have passed since it was last called if this is not the
|
|
|
|
{
|
|
|
|
first time around this loop. */
|
|
|
|
|
|
|
|
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
traceBLOCKING_ON_QUEUE_SEND( pxQueue );
|
|
|
|
traceBLOCKING_ON_QUEUE_SEND( pxQueue );
|
|
|
|
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
|
|
|
|
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
|
|
|
|
taskYIELD();
|
|
|
|
taskYIELD();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
}
|
|
|
|
{
|
|
|
|
else
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
{
|
|
|
|
return errQUEUE_FULL;
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
}
|
|
|
|
return errQUEUE_FULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
@ -698,13 +708,10 @@ xTimeOutType xTimeOut;
|
|
|
|
|
|
|
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( prvIsQueueEmpty( pxQueue ) )
|
|
|
|
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Need to call xTaskCheckForTimeout again as time could
|
|
|
|
if( prvIsQueueEmpty( pxQueue ) )
|
|
|
|
have passed since it was last called if this is not the
|
|
|
|
{
|
|
|
|
first time around this loop. */
|
|
|
|
|
|
|
|
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
|
|
|
|
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
|
|
|
|
|
|
|
|
|
|
|
|
#if ( configUSE_MUTEXES == 1 )
|
|
|
|
#if ( configUSE_MUTEXES == 1 )
|
|
|
@ -721,11 +728,11 @@ xTimeOutType xTimeOut;
|
|
|
|
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
|
|
|
|
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
|
|
|
|
taskYIELD();
|
|
|
|
taskYIELD();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
}
|
|
|
|
{
|
|
|
|
else
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
{
|
|
|
|
return errQUEUE_EMPTY;
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
}
|
|
|
|
return errQUEUE_EMPTY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
@ -795,10 +802,16 @@ signed portBASE_TYPE xEntryTimeSet = pdFALSE;
|
|
|
|
xTimeOutType xTimeOut;
|
|
|
|
xTimeOutType xTimeOut;
|
|
|
|
signed portCHAR *pcOriginalReadPosition;
|
|
|
|
signed portCHAR *pcOriginalReadPosition;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This function relaxes the coding standard somewhat to allow return
|
|
|
|
|
|
|
|
statements within the function itself. This is done in the interest
|
|
|
|
|
|
|
|
of execution time efficiency. */
|
|
|
|
|
|
|
|
|
|
|
|
for( ;; )
|
|
|
|
for( ;; )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Is there space on the queue now? To be running we must be
|
|
|
|
|
|
|
|
the highest priority task wanting to access the queue. */
|
|
|
|
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
|
|
|
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Remember our read position in case we are just peeking. */
|
|
|
|
/* Remember our read position in case we are just peeking. */
|
|
|
@ -862,11 +875,15 @@ signed portCHAR *pcOriginalReadPosition;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( xTicksToWait == ( portTickType ) 0 )
|
|
|
|
if( xTicksToWait == ( portTickType ) 0 )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* The queue was empty and no block time is specified (or
|
|
|
|
|
|
|
|
the block time has expired) so leave now. */
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
return errQUEUE_EMPTY;
|
|
|
|
return errQUEUE_EMPTY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( xEntryTimeSet == pdFALSE )
|
|
|
|
else if( xEntryTimeSet == pdFALSE )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* The queue was empty and a block time was specified so
|
|
|
|
|
|
|
|
configure the timeout structure. */
|
|
|
|
vTaskSetTimeOutState( &xTimeOut );
|
|
|
|
vTaskSetTimeOutState( &xTimeOut );
|
|
|
|
xEntryTimeSet = pdTRUE;
|
|
|
|
xEntryTimeSet = pdTRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -874,15 +891,16 @@ signed portCHAR *pcOriginalReadPosition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Interrupts and other tasks can send to and receive from the queue
|
|
|
|
|
|
|
|
now the critical section has been exited. */
|
|
|
|
|
|
|
|
|
|
|
|
vTaskSuspendAll();
|
|
|
|
vTaskSuspendAll();
|
|
|
|
prvLockQueue( pxQueue );
|
|
|
|
prvLockQueue( pxQueue );
|
|
|
|
|
|
|
|
|
|
|
|
if( prvIsQueueEmpty( pxQueue ) )
|
|
|
|
/* Update the timeout state to see if it has expired yet. */
|
|
|
|
|
|
|
|
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Need to call xTaskCheckForTimeout again as time could
|
|
|
|
if( prvIsQueueEmpty( pxQueue ) )
|
|
|
|
have passed since it was last called if this is not the
|
|
|
|
|
|
|
|
first time around this loop. */
|
|
|
|
|
|
|
|
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
|
|
|
|
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
|
|
|
|
|
|
|
|
|
|
|
@ -891,7 +909,9 @@ signed portCHAR *pcOriginalReadPosition;
|
|
|
|
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
|
|
|
|
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
portENTER_CRITICAL();
|
|
|
|
|
|
|
|
{
|
|
|
|
vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );
|
|
|
|
vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );
|
|
|
|
|
|
|
|
}
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
portEXIT_CRITICAL();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -906,15 +926,16 @@ signed portCHAR *pcOriginalReadPosition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Try again. */
|
|
|
|
prvUnlockQueue( pxQueue );
|
|
|
|
prvUnlockQueue( pxQueue );
|
|
|
|
( void ) xTaskResumeAll();
|
|
|
|
( void ) xTaskResumeAll();
|
|
|
|
return errQUEUE_EMPTY;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
prvUnlockQueue( pxQueue );
|
|
|
|
prvUnlockQueue( pxQueue );
|
|
|
|
( void ) xTaskResumeAll();
|
|
|
|
( void ) xTaskResumeAll();
|
|
|
|
|
|
|
|
return errQUEUE_EMPTY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|