From 1c7968bb9d4b4d21b6a07f636ec534146b1ed00b Mon Sep 17 00:00:00 2001 From: richardbarry Date: Sun, 27 Jan 2008 20:25:36 +0000 Subject: [PATCH] Update to allow use with the cooperative scheduler. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@147 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Demo/Common/Full/dynamic.c | 12 ++++++++++++ Demo/Common/Full/events.c | 12 ++++++++++-- Demo/Common/Minimal/AltBlock.c | 13 +++++++++++++ Demo/Common/Minimal/blocktim.c | 7 +++++++ Demo/Common/Minimal/countsem.c | 8 ++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Demo/Common/Full/dynamic.c b/Demo/Common/Full/dynamic.c index 3503f714c..9150cad1d 100644 --- a/Demo/Common/Full/dynamic.c +++ b/Demo/Common/Full/dynamic.c @@ -251,6 +251,10 @@ unsigned portBASE_TYPE uxOurPriority; vTaskPrioritySet( NULL, uxOurPriority + 1 ); ( *pulCounter )++; vTaskPrioritySet( NULL, uxOurPriority ); + + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif } } /*-----------------------------------------------------------*/ @@ -342,6 +346,10 @@ const portCHAR * const pcTaskFailMsg = "Priority manipulation Task Failed\r\n"; portEXIT_CRITICAL(); } + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif + /* Resume the continuous count task and do it all again. */ vTaskResume( xContinuousIncrementHandle ); } @@ -421,6 +429,10 @@ portBASE_TYPE xGotValue; } xTaskResumeAll(); + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif + } while( xGotValue == pdFALSE ); if( ulReceivedValue != ulExpectedValue ) diff --git a/Demo/Common/Full/events.c b/Demo/Common/Full/events.c index bbc1e1f57..fe1fae12d 100644 --- a/Demo/Common/Full/events.c +++ b/Demo/Common/Full/events.c @@ -241,7 +241,9 @@ portBASE_TYPE xDummy = 0; xTaskResumeAll(); prvCheckTaskCounters( evtLOWEST_PRIORITY_INDEX, 1 ); - + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif /* Do the same basic test another few times - selectively suspending and resuming tasks and each time calling prvCheckTaskCounters() passing @@ -267,7 +269,9 @@ portBASE_TYPE xDummy = 0; prvCheckTaskCounters( evtHIGHEST_PRIORITY_INDEX_1, 1 ); - + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif /* Now a slight change, first suspend all tasks. */ @@ -310,6 +314,10 @@ portBASE_TYPE xDummy = 0; } } xTaskResumeAll(); + + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif /* We should have been preempted by resuming the scheduler - so by the time we are running again we expect the high priority task to have diff --git a/Demo/Common/Minimal/AltBlock.c b/Demo/Common/Minimal/AltBlock.c index f5d59553a..3990ec7b4 100644 --- a/Demo/Common/Minimal/AltBlock.c +++ b/Demo/Common/Minimal/AltBlock.c @@ -157,6 +157,12 @@ portTickType xTimeToBlock, xBlockedTime; } } + + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif + + /********************************************************************* Test 2 @@ -208,6 +214,10 @@ portTickType xTimeToBlock, xBlockedTime; } } + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif + /********************************************************************* Test 3 @@ -283,6 +293,9 @@ portTickType xTimeToBlock, xBlockedTime; vTaskDelay( bktSHORT_WAIT ); xRunIndicator = 0; + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif /********************************************************************* Test 4 diff --git a/Demo/Common/Minimal/blocktim.c b/Demo/Common/Minimal/blocktim.c index 523f5a9bf..4f0f05bf0 100644 --- a/Demo/Common/Minimal/blocktim.c +++ b/Demo/Common/Minimal/blocktim.c @@ -146,6 +146,10 @@ portTickType xTimeToBlock, xBlockedTime; } } + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif + /********************************************************************* Test 2 @@ -197,6 +201,9 @@ portTickType xTimeToBlock, xBlockedTime; } } + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif /********************************************************************* Test 3 diff --git a/Demo/Common/Minimal/countsem.c b/Demo/Common/Minimal/countsem.c index 288e22289..3d55776ea 100644 --- a/Demo/Common/Minimal/countsem.c +++ b/Demo/Common/Minimal/countsem.c @@ -159,6 +159,10 @@ unsigned portBASE_TYPE ux; ( *puxLoopCounter )++; } + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif + /* If the semaphore count is zero then we should not be able to 'take' the semaphore. */ if( xSemaphoreTake( xSemaphore, countDONT_BLOCK ) == pdPASS ) @@ -191,6 +195,10 @@ unsigned portBASE_TYPE ux; ( *puxLoopCounter )++; } + #if configUSE_PREEMPTION == 0 + taskYIELD(); + #endif + /* If the semaphore count is at its maximum then we should not be able to 'give' the semaphore. */ if( xSemaphoreGive( xSemaphore ) == pdPASS ) -- 2.39.5