Change the semantics of the xQueueGenericSendFromISR() function.

This commit is contained in:
Richard Barry 2008-04-12 09:45:02 +00:00
parent 2bc9dfa3f8
commit b73dafb1f4

View File

@ -118,7 +118,7 @@ xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBA
signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );
unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ); unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue );
void vQueueDelete( xQueueHandle xQueue ); void vQueueDelete( xQueueHandle xQueue );
signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken, portBASE_TYPE xCopyPosition ); signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition );
signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ); signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );
signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, const void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ); signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, const void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken );
xQueueHandle xQueueCreateMutex( void ); xQueueHandle xQueueCreateMutex( void );
@ -799,8 +799,10 @@ xTimeOutType xTimeOut;
#endif /* configUSE_ALTERNATIVE_API */ #endif /* configUSE_ALTERNATIVE_API */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE xTaskPreviouslyWoken, portBASE_TYPE xCopyPosition ) signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition )
{ {
signed portBASE_TYPE xReturn;
/* Similar to xQueueGenericSend, except we don't block if there is no room /* Similar to xQueueGenericSend, except we don't block if there is no room
in the queue. Also we don't directly wake a task that was blocked on a in the queue. Also we don't directly wake a task that was blocked on a
queue read, instead we return a flag to say whether a context switch is queue read, instead we return a flag to say whether a context switch is
@ -815,10 +817,6 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void
/* If the queue is locked we do not alter the event list. This will /* If the queue is locked we do not alter the event list. This will
be done when the queue is unlocked later. */ be done when the queue is unlocked later. */
if( pxQueue->xTxLock == queueUNLOCKED ) if( pxQueue->xTxLock == queueUNLOCKED )
{
/* We only want to wake one task per ISR, so check that a task has
not already been woken. */
if( !xTaskPreviouslyWoken )
{ {
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) ) if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) )
{ {
@ -826,8 +824,7 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void
{ {
/* The task waiting has a higher priority so record that a /* The task waiting has a higher priority so record that a
context switch is required. */ context switch is required. */
return pdTRUE; *pxHigherPriorityTaskWoken = pdTRUE;
}
} }
} }
} }
@ -837,13 +834,16 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void
knows that data was posted while it was locked. */ knows that data was posted while it was locked. */
++( pxQueue->xTxLock ); ++( pxQueue->xTxLock );
} }
xReturn = pdPASS;
} }
else else
{ {
traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue ); traceQUEUE_SEND_FROM_ISR_FAILED( pxQueue );
xReturn = errQUEUE_FULL;
} }
return xTaskPreviouslyWoken; return xReturn;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -1016,10 +1016,6 @@ signed portBASE_TYPE xReturn;
we update the lock count so the task that unlocks the queue will know we update the lock count so the task that unlocks the queue will know
that an ISR has removed data while the queue was locked. */ that an ISR has removed data while the queue was locked. */
if( pxQueue->xRxLock == queueUNLOCKED ) if( pxQueue->xRxLock == queueUNLOCKED )
{
/* We only want to wake one task per ISR, so check that a task has
not already been woken. */
if( !( *pxTaskWoken ) )
{ {
if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) ) if( !listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) )
{ {
@ -1031,7 +1027,6 @@ signed portBASE_TYPE xReturn;
} }
} }
} }
}
else else
{ {
/* Increment the lock count so the task that unlocks the queue /* Increment the lock count so the task that unlocks the queue