]> git.sur5r.net Git - freertos/commitdiff
Change behaviour when configUSE_PREEMPTION is 0 (preemption is turned off). See...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 7 Nov 2013 14:58:14 +0000 (14:58 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 7 Nov 2013 14:58:14 +0000 (14:58 +0000)
Remove an erroneous const in the prototype of queue receive/peek functions.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2088 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/include/queue.h
FreeRTOS/Source/queue.c
FreeRTOS/Source/tasks.c

index 16ae19c36b45cb91afc5b07061be1de47f7a8197..b5fac2b7d76b524d3314cdbbe2ce69a8d41e1cda 100644 (file)
@@ -714,7 +714,7 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
  * \defgroup xQueuePeekFromISR xQueuePeekFromISR\r
  * \ingroup QueueManagement\r
  */\r
-signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, const void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * queue. h\r
@@ -906,7 +906,7 @@ signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, const void * const
  * \defgroup xQueueReceive xQueueReceive\r
  * \ingroup QueueManagement\r
  */\r
-signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeek ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * queue. h\r
@@ -1421,7 +1421,7 @@ signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle xQueue, const void *
  * \defgroup xQueueReceiveFromISR xQueueReceiveFromISR\r
  * \ingroup QueueManagement\r
  */\r
-signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, const void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Utilities to query queues that are safe to use from an ISR.  These utilities\r
index 21977a75c4e1ae32325401bf403e05851628f8ea..0622eee135fa335d02e24c057cce0d59ff76a350 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+    FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -110,6 +110,13 @@ zero. */
 #define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( unsigned portBASE_TYPE ) 0 )\r
 #define queueMUTEX_GIVE_BLOCK_TIME              ( ( portTickType ) 0U )\r
 \r
+#if( configUSE_PREEMPTION == 0 )\r
+       /* If the cooperative scheduler is being used then a yield should not be\r
+       performed just because a higher priority task has been woken. */\r
+       #define queueYIELD_IF_USING_PREEMPTION()\r
+#else\r
+       #define queueYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()\r
+#endif\r
 \r
 /*\r
  * Definition of the queue used by the scheduler.\r
@@ -205,7 +212,7 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
 /*\r
  * Copies an item out of a queue.\r
  */\r
-static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
+static void prvCopyDataFromQueue( xQUEUE * const pxQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION;\r
 \r
 #if ( configUSE_QUEUE_SETS == 1 )\r
        /*\r
@@ -255,14 +262,14 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
                {\r
                        /* If there are tasks blocked waiting to read from the queue, then\r
                        the tasks will remain blocked as after this function exits the queue\r
-                       will still be empty.  If there are tasks blocked waiting to     write to\r
+                       will still be empty.  If there are tasks blocked waiting to write to\r
                        the queue, then one should be unblocked as after this function exits\r
                        it will be possible to write to it. */\r
                        if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
                        {\r
                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
                                {\r
-                                       portYIELD_WITHIN_API();\r
+                                       queueYIELD_IF_USING_PREEMPTION();\r
                                }\r
                        }\r
                }\r
@@ -586,7 +593,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
                                                        /* The queue is a member of a queue set, and posting\r
                                                        to the queue set caused a higher priority task to\r
                                                        unblock. A context switch is required. */\r
-                                                       portYIELD_WITHIN_API();\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
                                                }\r
                                        }\r
                                        else\r
@@ -601,7 +608,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
                                                                our own so yield immediately.  Yes it is ok to\r
                                                                do this from within the critical section - the\r
                                                                kernel takes care of that. */\r
-                                                               portYIELD_WITHIN_API();\r
+                                                               queueYIELD_IF_USING_PREEMPTION();\r
                                                        }\r
                                                }\r
                                        }\r
@@ -618,7 +625,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
                                                        our own so yield immediately.  Yes it is ok to do\r
                                                        this from within the critical section - the kernel\r
                                                        takes care of that. */\r
-                                                       portYIELD_WITHIN_API();\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
                                                }\r
                                        }\r
                                }\r
@@ -1033,7 +1040,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )\r
+signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )\r
 {\r
 signed portBASE_TYPE xEntryTimeSet = pdFALSE;\r
 xTimeOutType xTimeOut;\r
@@ -1083,7 +1090,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
                                        {\r
                                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )\r
                                                {\r
-                                                       portYIELD_WITHIN_API();\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
                                                }\r
                                        }\r
                                }\r
@@ -1104,7 +1111,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
                                                if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
                                                {\r
                                                        /* The task waiting has a higher priority than this task. */\r
-                                                       portYIELD_WITHIN_API();\r
+                                                       queueYIELD_IF_USING_PREEMPTION();\r
                                                }\r
                                        }\r
                                }\r
@@ -1188,7 +1195,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, const void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken )\r
+signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle xQueue, void * const pvBuffer, signed portBASE_TYPE *pxHigherPriorityTaskWoken )\r
 {\r
 signed portBASE_TYPE xReturn;\r
 unsigned portBASE_TYPE uxSavedInterruptStatus;\r
@@ -1263,7 +1270,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, const void * const pvBuffer )\r
+signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue,  void * const pvBuffer )\r
 {\r
 signed portBASE_TYPE xReturn;\r
 unsigned portBASE_TYPE uxSavedInterruptStatus;\r
@@ -1455,7 +1462,7 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void * const pvBuffer )\r
+static void prvCopyDataFromQueue( xQUEUE * const pxQueue, void * const pvBuffer )\r
 {\r
        if( pxQueue->uxQueueType != queueQUEUE_IS_MUTEX )\r
        {\r
@@ -2082,3 +2089,14 @@ signed portBASE_TYPE xReturn;
 \r
 #endif /* configUSE_QUEUE_SETS */\r
 \r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
+\r
index 768c13358d11e3d32a5c4ba62847fb54b6dd4952..dfb1bcce80333089b5281bee851fb115db7b2a07 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+    FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -104,6 +104,14 @@ privileged Vs unprivileged linkage and placement. */
  */\r
 #define tskIDLE_STACK_SIZE     configMINIMAL_STACK_SIZE\r
 \r
+#if( configUSE_PREEMPTION == 0 )\r
+       /* If the cooperative scheduler is being used then a yield should not be\r
+       performed just because a higher priority task has been woken. */\r
+       #define taskYIELD_IF_USING_PREEMPTION()\r
+#else\r
+       #define taskYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()\r
+#endif\r
+\r
 /*\r
  * Task control block.  A task control block (TCB) is allocated for each task,\r
  * and stores task state information, including a pointer to the task's context\r
@@ -621,7 +629,7 @@ tskTCB * pxNewTCB;
                        then it should run now. */\r
                        if( pxCurrentTCB->uxPriority < uxPriority )\r
                        {\r
-                               portYIELD_WITHIN_API();\r
+                               taskYIELD_IF_USING_PREEMPTION();\r
                        }\r
                }\r
        }\r
@@ -844,7 +852,7 @@ tskTCB * pxNewTCB;
                                else if( pxStateList == &xSuspendedTaskList )\r
                                {\r
                                        /* The task being queried is referenced from the suspended\r
-                                       list.  Is it genuinely suspended or is it block \r
+                                       list.  Is it genuinely suspended or is it block\r
                                        indefinitely? */\r
                                        if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL )\r
                                        {\r
@@ -1019,7 +1027,7 @@ tskTCB * pxNewTCB;
 \r
                                if( xYieldRequired == pdTRUE )\r
                                {\r
-                                       portYIELD_WITHIN_API();\r
+                                       taskYIELD_IF_USING_PREEMPTION();\r
                                }\r
 \r
                                /* Remove compiler warning about unused variables when the port\r
@@ -1155,9 +1163,10 @@ tskTCB * pxNewTCB;
                                        /* We may have just resumed a higher priority task. */\r
                                        if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
                                        {\r
-                                               /* This yield may not cause the task just resumed to run, but\r
-                                               will leave the lists in the correct state for the next yield. */\r
-                                               portYIELD_WITHIN_API();\r
+                                               /* This yield may not cause the task just resumed to run,\r
+                                               but will leave the lists in the correct state for the\r
+                                               next yield. */\r
+                                               taskYIELD_IF_USING_PREEMPTION();\r
                                        }\r
                                }\r
                        }\r
@@ -1407,8 +1416,12 @@ portBASE_TYPE xAlreadyYielded = pdFALSE;
 \r
                                if( xYieldPending == pdTRUE )\r
                                {\r
-                                       xAlreadyYielded = pdTRUE;\r
-                                       portYIELD_WITHIN_API();\r
+                                       #if( configUSE_PREEMPTION != 0 )\r
+                                       {\r
+                                               xAlreadyYielded = pdTRUE;\r
+                                       }\r
+                                       #endif\r
+                                       taskYIELD_IF_USING_PREEMPTION();\r
                                }\r
                        }\r
                }\r
@@ -1694,7 +1707,7 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                        }\r
                }\r
                #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */\r
-               \r
+\r
                #if ( configUSE_TICK_HOOK == 1 )\r
                {\r
                        /* Guard against the tick hook being called when the pended tick\r
@@ -1704,7 +1717,7 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                                vApplicationTickHook();\r
                        }\r
                }\r
-               #endif /* configUSE_TICK_HOOK */                \r
+               #endif /* configUSE_TICK_HOOK */\r
        }\r
        else\r
        {\r