Change behaviour when configUSE_PREEMPTION is 0 (preemption is turned off). See the change history in the next release for details.

Remove an erroneous const in the prototype of queue receive/peek functions.
This commit is contained in:
Richard Barry 2013-11-07 14:58:14 +00:00
parent 30bc6c01a9
commit 20eb03ed7d
3 changed files with 58 additions and 27 deletions

View file

@ -714,7 +714,7 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
* \defgroup xQueuePeekFromISR xQueuePeekFromISR * \defgroup xQueuePeekFromISR xQueuePeekFromISR
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, const void * const pvBuffer ) PRIVILEGED_FUNCTION; signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;
/** /**
* queue. h * queue. h
@ -906,7 +906,7 @@ signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, const void * const
* \defgroup xQueueReceive xQueueReceive * \defgroup xQueueReceive xQueueReceive
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek ) PRIVILEGED_FUNCTION; signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek ) PRIVILEGED_FUNCTION;
/** /**
* queue. h * queue. h
@ -1421,7 +1421,7 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle xQueue, const void *
* \defgroup xQueueReceiveFromISR xQueueReceiveFromISR * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, const void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
/* /*
* Utilities to query queues that are safe to use from an ISR. These utilities * Utilities to query queues that are safe to use from an ISR. These utilities

View file

@ -1,5 +1,5 @@
/* /*
FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.
All rights reserved All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
@ -110,6 +110,13 @@ zero. */
#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portBASE_TYPE ) 0 ) #define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portBASE_TYPE ) 0 )
#define queueMUTEX_GIVE_BLOCK_TIME ( ( portTickType ) 0U ) #define queueMUTEX_GIVE_BLOCK_TIME ( ( portTickType ) 0U )
#if( configUSE_PREEMPTION == 0 )
/* If the cooperative scheduler is being used then a yield should not be
performed just because a higher priority task has been woken. */
#define queueYIELD_IF_USING_PREEMPTION()
#else
#define queueYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()
#endif
/* /*
* Definition of the queue used by the scheduler. * Definition of the queue used by the scheduler.
@ -205,7 +212,7 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
/* /*
* Copies an item out of a queue. * Copies an item out of a queue.
*/ */
static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void * const pvBuffer ) PRIVILEGED_FUNCTION; static void prvCopyDataFromQueue( xQUEUE * const pxQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;
#if ( configUSE_QUEUE_SETS == 1 ) #if ( configUSE_QUEUE_SETS == 1 )
/* /*
@ -255,14 +262,14 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
{ {
/* If there are tasks blocked waiting to read from the queue, then /* If there are tasks blocked waiting to read from the queue, then
the tasks will remain blocked as after this function exits the queue the tasks will remain blocked as after this function exits the queue
will still be empty. If there are tasks blocked waiting to write to will still be empty. If there are tasks blocked waiting to write to
the queue, then one should be unblocked as after this function exits the queue, then one should be unblocked as after this function exits
it will be possible to write to it. */ it will be possible to write to it. */
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
{ {
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )
{ {
portYIELD_WITHIN_API(); queueYIELD_IF_USING_PREEMPTION();
} }
} }
} }
@ -586,7 +593,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
/* The queue is a member of a queue set, and posting /* The queue is a member of a queue set, and posting
to the queue set caused a higher priority task to to the queue set caused a higher priority task to
unblock. A context switch is required. */ unblock. A context switch is required. */
portYIELD_WITHIN_API(); queueYIELD_IF_USING_PREEMPTION();
} }
} }
else else
@ -601,7 +608,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
our own so yield immediately. Yes it is ok to our own so yield immediately. Yes it is ok to
do this from within the critical section - the do this from within the critical section - the
kernel takes care of that. */ kernel takes care of that. */
portYIELD_WITHIN_API(); queueYIELD_IF_USING_PREEMPTION();
} }
} }
} }
@ -618,7 +625,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
our own so yield immediately. Yes it is ok to do our own so yield immediately. Yes it is ok to do
this from within the critical section - the kernel this from within the critical section - the kernel
takes care of that. */ takes care of that. */
portYIELD_WITHIN_API(); queueYIELD_IF_USING_PREEMPTION();
} }
} }
} }
@ -1033,7 +1040,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )
{ {
signed portBASE_TYPE xEntryTimeSet = pdFALSE; signed portBASE_TYPE xEntryTimeSet = pdFALSE;
xTimeOutType xTimeOut; xTimeOutType xTimeOut;
@ -1083,7 +1090,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
{ {
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )
{ {
portYIELD_WITHIN_API(); queueYIELD_IF_USING_PREEMPTION();
} }
} }
} }
@ -1104,7 +1111,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{ {
/* The task waiting has a higher priority than this task. */ /* The task waiting has a higher priority than this task. */
portYIELD_WITHIN_API(); queueYIELD_IF_USING_PREEMPTION();
} }
} }
} }
@ -1188,7 +1195,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, const void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken ) signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken )
{ {
signed portBASE_TYPE xReturn; signed portBASE_TYPE xReturn;
unsigned portBASE_TYPE uxSavedInterruptStatus; unsigned portBASE_TYPE uxSavedInterruptStatus;
@ -1263,7 +1270,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, const void * const pvBuffer ) signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, void * const pvBuffer )
{ {
signed portBASE_TYPE xReturn; signed portBASE_TYPE xReturn;
unsigned portBASE_TYPE uxSavedInterruptStatus; unsigned portBASE_TYPE uxSavedInterruptStatus;
@ -1455,7 +1462,7 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void * const pvBuffer ) static void prvCopyDataFromQueue( xQUEUE * const pxQueue, void * const pvBuffer )
{ {
if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX ) if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX )
{ {
@ -2082,3 +2089,14 @@ signed portBASE_TYPE xReturn;
#endif /* configUSE_QUEUE_SETS */ #endif /* configUSE_QUEUE_SETS */

View file

@ -1,5 +1,5 @@
/* /*
FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.
All rights reserved All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
@ -104,6 +104,14 @@ privileged Vs unprivileged linkage and placement. */
*/ */
#define tskIDLE_STACK_SIZE configMINIMAL_STACK_SIZE #define tskIDLE_STACK_SIZE configMINIMAL_STACK_SIZE
#if( configUSE_PREEMPTION == 0 )
/* If the cooperative scheduler is being used then a yield should not be
performed just because a higher priority task has been woken. */
#define taskYIELD_IF_USING_PREEMPTION()
#else
#define taskYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()
#endif
/* /*
* Task control block. A task control block (TCB) is allocated for each task, * Task control block. A task control block (TCB) is allocated for each task,
* and stores task state information, including a pointer to the task's context * and stores task state information, including a pointer to the task's context
@ -621,7 +629,7 @@ tskTCB * pxNewTCB;
then it should run now. */ then it should run now. */
if( pxCurrentTCB->uxPriority < uxPriority ) if( pxCurrentTCB->uxPriority < uxPriority )
{ {
portYIELD_WITHIN_API(); taskYIELD_IF_USING_PREEMPTION();
} }
} }
} }
@ -844,7 +852,7 @@ tskTCB * pxNewTCB;
else if( pxStateList == &xSuspendedTaskList ) else if( pxStateList == &xSuspendedTaskList )
{ {
/* The task being queried is referenced from the suspended /* The task being queried is referenced from the suspended
list. Is it genuinely suspended or is it block list. Is it genuinely suspended or is it block
indefinitely? */ indefinitely? */
if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL ) if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL )
{ {
@ -1019,7 +1027,7 @@ tskTCB * pxNewTCB;
if( xYieldRequired == pdTRUE ) if( xYieldRequired == pdTRUE )
{ {
portYIELD_WITHIN_API(); taskYIELD_IF_USING_PREEMPTION();
} }
/* Remove compiler warning about unused variables when the port /* Remove compiler warning about unused variables when the port
@ -1155,9 +1163,10 @@ tskTCB * pxNewTCB;
/* We may have just resumed a higher priority task. */ /* We may have just resumed a higher priority task. */
if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority ) if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )
{ {
/* This yield may not cause the task just resumed to run, but /* This yield may not cause the task just resumed to run,
will leave the lists in the correct state for the next yield. */ but will leave the lists in the correct state for the
portYIELD_WITHIN_API(); next yield. */
taskYIELD_IF_USING_PREEMPTION();
} }
} }
} }
@ -1407,8 +1416,12 @@ portBASE_TYPE xAlreadyYielded = pdFALSE;
if( xYieldPending == pdTRUE ) if( xYieldPending == pdTRUE )
{ {
xAlreadyYielded = pdTRUE; #if( configUSE_PREEMPTION != 0 )
portYIELD_WITHIN_API(); {
xAlreadyYielded = pdTRUE;
}
#endif
taskYIELD_IF_USING_PREEMPTION();
} }
} }
} }
@ -1694,7 +1707,7 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
} }
} }
#endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */ #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */
#if ( configUSE_TICK_HOOK == 1 ) #if ( configUSE_TICK_HOOK == 1 )
{ {
/* Guard against the tick hook being called when the pended tick /* Guard against the tick hook being called when the pended tick
@ -1704,7 +1717,7 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
vApplicationTickHook(); vApplicationTickHook();
} }
} }
#endif /* configUSE_TICK_HOOK */ #endif /* configUSE_TICK_HOOK */
} }
else else
{ {