mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Minor changes to new queue functions plus add comments.
This commit is contained in:
parent
55c96044b0
commit
143c58e032
|
@ -445,6 +445,10 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const
|
|||
signed portBASE_TYPE xEntryTimeSet = pdFALSE;
|
||||
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( ;; )
|
||||
{
|
||||
taskENTER_CRITICAL();
|
||||
|
@ -463,7 +467,9 @@ xTimeOutType xTimeOut;
|
|||
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )
|
||||
{
|
||||
/* 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();
|
||||
}
|
||||
}
|
||||
|
@ -475,11 +481,15 @@ xTimeOutType xTimeOut;
|
|||
{
|
||||
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();
|
||||
return errQUEUE_FULL;
|
||||
}
|
||||
else if( xEntryTimeSet == pdFALSE )
|
||||
{
|
||||
/* The queue was full and a block time was specified so
|
||||
configure the timeout structure. */
|
||||
vTaskSetTimeOutState( &xTimeOut );
|
||||
xEntryTimeSet = pdTRUE;
|
||||
}
|
||||
|
@ -487,15 +497,16 @@ xTimeOutType xTimeOut;
|
|||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
/* Interrupts and other tasks can send to and receive from the queue
|
||||
now the critical section has been exited. */
|
||||
|
||||
vTaskSuspendAll();
|
||||
prvLockQueue( pxQueue );
|
||||
|
||||
if( prvIsQueueFull( pxQueue ) )
|
||||
{
|
||||
/* Need to call xTaskCheckForTimeout again as time could
|
||||
have passed since it was last called if this is not the
|
||||
first time around this loop. */
|
||||
/* Update the timeout state to see if it has expired yet. */
|
||||
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
||||
{
|
||||
if( prvIsQueueFull( pxQueue ) )
|
||||
{
|
||||
traceBLOCKING_ON_QUEUE_SEND( pxQueue );
|
||||
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
|
||||
|
@ -519,15 +530,17 @@ xTimeOutType xTimeOut;
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Try again. */
|
||||
prvUnlockQueue( pxQueue );
|
||||
( void ) xTaskResumeAll();
|
||||
return errQUEUE_FULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The timeout has expired. */
|
||||
prvUnlockQueue( pxQueue );
|
||||
( void ) xTaskResumeAll();
|
||||
return errQUEUE_FULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -584,24 +597,21 @@ xTimeOutType xTimeOut;
|
|||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if( prvIsQueueFull( pxQueue ) )
|
||||
{
|
||||
/* Need to call xTaskCheckForTimeout again as time could
|
||||
have passed since it was last called if this is not the
|
||||
first time around this loop. */
|
||||
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
||||
{
|
||||
if( prvIsQueueFull( pxQueue ) )
|
||||
{
|
||||
traceBLOCKING_ON_QUEUE_SEND( pxQueue );
|
||||
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
|
||||
taskYIELD();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
taskEXIT_CRITICAL();
|
||||
return errQUEUE_FULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
@ -698,12 +708,9 @@ xTimeOutType xTimeOut;
|
|||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if( prvIsQueueEmpty( pxQueue ) )
|
||||
{
|
||||
/* Need to call xTaskCheckForTimeout again as time could
|
||||
have passed since it was last called if this is not the
|
||||
first time around this loop. */
|
||||
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
||||
{
|
||||
if( prvIsQueueEmpty( pxQueue ) )
|
||||
{
|
||||
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
|
||||
|
||||
|
@ -721,13 +728,13 @@ xTimeOutType xTimeOut;
|
|||
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
|
||||
taskYIELD();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
taskEXIT_CRITICAL();
|
||||
return errQUEUE_EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
@ -795,10 +802,16 @@ signed portBASE_TYPE xEntryTimeSet = pdFALSE;
|
|||
xTimeOutType xTimeOut;
|
||||
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( ;; )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
/* Remember our read position in case we are just peeking. */
|
||||
|
@ -862,11 +875,15 @@ signed portCHAR *pcOriginalReadPosition;
|
|||
{
|
||||
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();
|
||||
return errQUEUE_EMPTY;
|
||||
}
|
||||
else if( xEntryTimeSet == pdFALSE )
|
||||
{
|
||||
/* The queue was empty and a block time was specified so
|
||||
configure the timeout structure. */
|
||||
vTaskSetTimeOutState( &xTimeOut );
|
||||
xEntryTimeSet = pdTRUE;
|
||||
}
|
||||
|
@ -874,15 +891,16 @@ signed portCHAR *pcOriginalReadPosition;
|
|||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
/* Interrupts and other tasks can send to and receive from the queue
|
||||
now the critical section has been exited. */
|
||||
|
||||
vTaskSuspendAll();
|
||||
prvLockQueue( pxQueue );
|
||||
|
||||
if( prvIsQueueEmpty( pxQueue ) )
|
||||
{
|
||||
/* Need to call xTaskCheckForTimeout again as time could
|
||||
have passed since it was last called if this is not the
|
||||
first time around this loop. */
|
||||
/* Update the timeout state to see if it has expired yet. */
|
||||
if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) == pdFALSE )
|
||||
{
|
||||
if( prvIsQueueEmpty( pxQueue ) )
|
||||
{
|
||||
traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue );
|
||||
|
||||
|
@ -891,7 +909,9 @@ signed portCHAR *pcOriginalReadPosition;
|
|||
if( pxQueue->uxQueueType == queueQUEUE_IS_MUTEX )
|
||||
{
|
||||
portENTER_CRITICAL();
|
||||
{
|
||||
vTaskPriorityInherit( ( void * ) pxQueue->pxMutexHolder );
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
@ -906,15 +926,16 @@ signed portCHAR *pcOriginalReadPosition;
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Try again. */
|
||||
prvUnlockQueue( pxQueue );
|
||||
( void ) xTaskResumeAll();
|
||||
return errQUEUE_EMPTY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prvUnlockQueue( pxQueue );
|
||||
( void ) xTaskResumeAll();
|
||||
return errQUEUE_EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue