]> git.sur5r.net Git - freertos/commitdiff
Ensure the Win32 demo runs in co-operative mode.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 8 Nov 2013 10:11:46 +0000 (10:11 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 8 Nov 2013 10:11:46 +0000 (10:11 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2091 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Demo/WIN32-MSVC/DemosModifiedForLowTickRate/recmutex.c
FreeRTOS/Demo/WIN32-MSVC/main_blinky.c
FreeRTOS/Demo/WIN32-MSVC/main_full.c

index 21cfc1dd1813e353666a8404c482c27f2308aa60..f065dacdab5f8a6fd0d8118044979d387baa9460 100644 (file)
@@ -137,7 +137,7 @@ static volatile unsigned portBASE_TYPE uxControllingCycles = 0, uxBlockingCycles
 \r
 /* Handles of the two higher priority tasks, required so they can be resumed \r
 (unsuspended). */\r
-static xTaskHandle xControllingTaskHandle, xBlockingTaskHandle;\r
+static xTaskHandle xControllingTaskHandle, xBlockingTaskHandle, xPollingTaskHandle;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -160,7 +160,7 @@ void vStartRecursiveMutexTasks( void )
        {\r
                xTaskCreate( prvRecursiveMutexControllingTask, ( signed portCHAR * ) "Rec1Ctrl", configMINIMAL_STACK_SIZE, NULL, recmuCONTROLLING_TASK_PRIORITY, &xControllingTaskHandle );\r
         xTaskCreate( prvRecursiveMutexBlockingTask, ( signed portCHAR * ) "Rec2Blck", configMINIMAL_STACK_SIZE, NULL, recmuBLOCKING_TASK_PRIORITY, &xBlockingTaskHandle );\r
-        xTaskCreate( prvRecursiveMutexPollingTask, ( signed portCHAR * ) "Rec3Poll", configMINIMAL_STACK_SIZE, NULL, recmuPOLLING_TASK_PRIORITY, NULL );\r
+        xTaskCreate( prvRecursiveMutexPollingTask, ( signed portCHAR * ) "Rec3Poll", configMINIMAL_STACK_SIZE, NULL, recmuPOLLING_TASK_PRIORITY, &xPollingTaskHandle );\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -223,6 +223,10 @@ unsigned portBASE_TYPE ux;
                        {\r
                                xErrorOccurred = pdTRUE;\r
                        }\r
+\r
+                       #if configUSE_PREEMPTION == 0\r
+                               taskYIELD();\r
+                       #endif\r
                }\r
 \r
                /* Having given it back the same number of times as it was taken, we\r
@@ -329,10 +333,17 @@ static void prvRecursiveMutexPollingTask( void *pvParameters )
                                block indefinitely when it attempts to obtain the mutex, the\r
                                Controlling task will only block for a fixed period and an\r
                                error will be latched if the polling task has not returned the\r
-                               mutex by the time this fixed period has expired. */\r
+                               mutex by the time this fixed period has expired. */                             \r
                                vTaskResume( xBlockingTaskHandle );\r
-                vTaskResume( xControllingTaskHandle );\r
-                       \r
+                               #if configUSE_PREEMPTION == 0\r
+                                       taskYIELD();\r
+                               #endif\r
+\r
+                               vTaskResume( xControllingTaskHandle );\r
+                               #if configUSE_PREEMPTION == 0\r
+                                       taskYIELD();\r
+                               #endif\r
+\r
                                /* The other two tasks should now have executed and no longer\r
                                be suspended. */\r
                                if( ( xBlockingIsSuspended == pdTRUE ) || ( xControllingIsSuspended == pdTRUE ) )\r
@@ -345,6 +356,10 @@ static void prvRecursiveMutexPollingTask( void *pvParameters )
                                {\r
                                        xErrorOccurred = pdTRUE;\r
                                }\r
+\r
+                               #if configUSE_PREEMPTION == 0\r
+                                       taskYIELD();\r
+                               #endif\r
                        }\r
                }\r
 \r
index 8e63dc0c840fdd32984a37ca996a1a22da23bd84..0ebdbeaae26c4aed4ae355a594d91fa2e68d9f89 100644 (file)
@@ -191,6 +191,10 @@ static void prvQueueSendTask( void *pvParameters )
 portTickType xNextWakeTime;\r
 const unsigned long ulValueToSend = 100UL;\r
 \r
+       /* Remove compiler warning in the case that configASSERT() is not \r
+       defined. */\r
+       ( void ) pvParameters;\r
+\r
        /* Check the task parameter is as expected. */\r
        configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER );\r
 \r
@@ -218,6 +222,10 @@ static void prvQueueReceiveTask( void *pvParameters )
 {\r
 unsigned long ulReceivedValue;\r
 \r
+       /* Remove compiler warning in the case that configASSERT() is not \r
+       defined. */\r
+       ( void ) pvParameters;\r
+\r
        /* Check the task parameter is as expected. */\r
        configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );\r
 \r
index 91bf1e8f81a9c8b2c4ff65d9306f7fe0bd423661..1ca3b69865e660e0508126649f71fd9fd18bfc95 100644 (file)
@@ -190,14 +190,20 @@ int main_full( void )
        vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );\r
        vStartQueuePeekTasks();\r
        vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
-       vStartRecursiveMutexTasks();\r
-       vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
+       vStartRecursiveMutexTasks();    \r
        vStartCountingSemaphoreTasks();\r
        vStartDynamicPriorityTasks();\r
        vStartQueueSetTasks();\r
        vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );       \r
        xTaskCreate( prvDemoQueueSpaceFunctions, ( signed char * ) "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
 \r
+       #if( configUSE_PREEMPTION != 0  )\r
+       {\r
+               /* Don't expect these tasks to pass when preemption is not used. */\r
+               vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
+       }\r
+       #endif\r
+\r
        /* The suicide tasks must be created last as they need to know how many\r
        tasks were running prior to their creation.  This then allows them to \r
        ascertain whether or not the correct/expected number of tasks are running at \r
@@ -234,11 +240,17 @@ const portTickType xCycleFrequency = 2500 / portTICK_RATE_MS;
                vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );\r
 \r
                /* Check the standard demo tasks are running without error. */\r
-               if( xAreTimerDemoTasksStillRunning( xCycleFrequency ) != pdTRUE )\r
+               #if( configUSE_PREEMPTION != 0 )\r
                {\r
-                       pcStatusMessage = "Error: TimerDemo";\r
+                       /* These tasks are only created when preemption is used. */\r
+                       if( xAreTimerDemoTasksStillRunning( xCycleFrequency ) != pdTRUE )\r
+                       {\r
+                               pcStatusMessage = "Error: TimerDemo";\r
+                       }\r
                }\r
-           else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
+               #endif\r
+\r
+           if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
            {\r
                        pcStatusMessage = "Error: IntMath";\r
            }   \r
@@ -280,15 +292,15 @@ const portTickType xCycleFrequency = 2500 / portTICK_RATE_MS;
                }\r
                else if( xAreDynamicPriorityTasksStillRunning() != pdPASS )\r
                {\r
-                       pcStatusMessage = "Error: Dynamic\r\n";\r
+                       pcStatusMessage = "Error: Dynamic";\r
                }\r
                else if( xAreQueueSetTasksStillRunning() != pdPASS )\r
                {\r
-                       pcStatusMessage = "Error: Queue set\r\n";\r
+                       pcStatusMessage = "Error: Queue set";\r
                }\r
                else if( xIsQueueOverwriteTaskStillRunning() != pdPASS )\r
                {\r
-                       pcStatusMessage = "Error: Queue overwrite\r\n";\r
+                       pcStatusMessage = "Error: Queue overwrite";\r
                }\r
 \r
                /* This is the only task that uses stdout so its ok to call printf() \r
@@ -371,7 +383,12 @@ void vFullDemoTickHookFunction( void )
 {\r
        /* Call the periodic timer test, which tests the timer API functions that\r
        can be called from an ISR. */\r
-       vTimerPeriodicISRTests();\r
+       #if( configUSE_PREEMPTION != 0 )\r
+       {\r
+               /* Only created when preemption is used. */\r
+               vTimerPeriodicISRTests();\r
+       }\r
+       #endif\r
 \r
        /* Call the periodic queue overwrite from ISR demo. */\r
        vQueueOverwritePeriodicISRDemo();\r
@@ -521,6 +538,10 @@ unsigned portBASE_TYPE uxReturn, x;
 \r
                /* The queue is full, start again. */\r
                xQueueReset( xQueue );\r
+\r
+               #if( configUSE_PREEMPTION == 0 )\r
+                       taskYIELD();\r
+               #endif\r
        }\r
 }\r
 \r