From 3d04e1e312f7c1b08b23c7c0dff55867cb0fdc18 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Tue, 13 Dec 2011 11:38:58 +0000 Subject: [PATCH] Add a few extra standard demo tasks to the Win32 demo. Make use of the new trace specific function calls from the Win32 demo - just to check the function as expected. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1657 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Demo/WIN32-MSVC/WIN32.suo | Bin 54784 -> 54784 bytes Demo/WIN32-MSVC/WIN32.vcxproj | 3 ++ Demo/WIN32-MSVC/WIN32.vcxproj.filters | 6 +++ Demo/WIN32-MSVC/main.c | 57 ++++++++++++++++++++++---- 4 files changed, 57 insertions(+), 9 deletions(-) diff --git a/Demo/WIN32-MSVC/WIN32.suo b/Demo/WIN32-MSVC/WIN32.suo index d5a322bb84675b31730bde6bd5d18fcce71c3017..2f4e676f815705edd3324a637654cc54ad584078 100644 GIT binary patch delta 1143 zcmah{Z%kWN6u&7xL zKBrqkf@Jh0u&|jZCdLFz)Vn2MaCu>gF@7*YHe>i;P-B9`@Wn>6gcQ%~D`fGD=jFWf z|J-|i=PEP2GQ)q~V=(6Zw9y!xW&MU+uJ{K+NICKz0?Kju1*F zz&hz;a_Mo->RX&29`dJue`WZ)ijec=*-x}wxLbBIKM<&d_3=w%JFhMeToTvktrQlI zNX+l}il+*i45f0QV^|1K<0SHc7WCsc1U>6XHD9*2woBU@xh|r^1?c@jo z5=F!=5Kx=thEv<6)&E=iXrt_TC?fFD6J_wT=P~%RrGP2VMR|zV7K+iKp}|IXljqA9 z6cMb=yUVEd3Uum{Cun1x8^6JZn%bJDyiYe(eXNFXyjgkbn3#M+VajU?pTC9TmJ}%T z^84U$qfepiwy2wHxG4Rq{4? z177c29I3Agh4o8-+E+=n2YN!gdM4KirB`gWKeopdRTFmCiKV+Z4k8m3@L~K#Sh<_a zlpck`LZ=OE9c#%x6@E?FU_G7-6)`*HFSwX1Zr@?BV70#a!4V@SOUfalj<&@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+ /wd4210 %(AdditionalOptions) _DEBUG;%(PreprocessorDefinitions) @@ -129,6 +130,8 @@ + + diff --git a/Demo/WIN32-MSVC/WIN32.vcxproj.filters b/Demo/WIN32-MSVC/WIN32.vcxproj.filters index 6ce6aed38..e32e36837 100644 --- a/Demo/WIN32-MSVC/WIN32.vcxproj.filters +++ b/Demo/WIN32-MSVC/WIN32.vcxproj.filters @@ -88,6 +88,12 @@ Demo App Source\Common Demo Tasks + + Demo App Source\Common Demo Tasks + + + Demo App Source\Common Demo Tasks + diff --git a/Demo/WIN32-MSVC/main.c b/Demo/WIN32-MSVC/main.c index cf80942a8..bb0116498 100644 --- a/Demo/WIN32-MSVC/main.c +++ b/Demo/WIN32-MSVC/main.c @@ -100,6 +100,8 @@ #include "flop.h" #include "TimerDemo.h" #include "countsem.h" +#include "death.h" +#include "dynamic.h" /* Priorities at which the tasks are created. */ #define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) @@ -121,9 +123,9 @@ static void prvCheckTask( void *pvParameters ); /* The variable into which error messages are latched. */ static char *pcStatusMessage = "OK"; -/* This semaphore is created purely to test using the vSemaphoreDelete() API -function. It has no other purpose. */ -static xSemaphoreHandle xSemaphoreToDelete = NULL; +/* This semaphore is created purely to test using the vSemaphoreDelete() and +semaphore tracing API functions. It has no other purpose. */ +static xSemaphoreHandle xMutexToDelete = NULL; /*-----------------------------------------------------------*/ @@ -143,10 +145,17 @@ int main( void ) vStartRecursiveMutexTasks(); vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); vStartCountingSemaphoreTasks(); + vStartDynamicPriorityTasks(); + + /* The suicide tasks must be created last as they need to know how many + tasks were running prior to their creation. This then allows them to + ascertain whether or not the correct/expected number of tasks are running at + any given time. */ + vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); /* Create the semaphore that will be deleted in the idle task hook. This is done purely to test the use of vSemaphoreDelete(). */ - xSemaphoreToDelete = xSemaphoreCreateMutex(); + xMutexToDelete = xSemaphoreCreateMutex(); /* Start the scheduler itself. */ vTaskStartScheduler(); @@ -214,6 +223,14 @@ const portTickType xCycleFrequency = 1000 / portTICK_RATE_MS; { pcStatusMessage = "Error: CountSem"; } + else if( xIsCreateTaskStillRunning() != pdTRUE ) + { + pcStatusMessage = "Error: Death"; + } + else if( xAreDynamicPriorityTasksStillRunning() != pdPASS ) + { + pcStatusMessage = "Error: Dynamic\r\n"; + } /* This is the only task that uses stdout so its ok to call printf() directly. */ @@ -227,15 +244,27 @@ void vApplicationIdleHook( void ) const unsigned long ulMSToSleep = 5; xTaskHandle xIdleTaskHandle, xTimerTaskHandle; signed char *pcTaskName; +const unsigned char ucConstQueueNumber = 0xaaU, ucConstTaskNumber = 0x55U; + +/* These three functions are only meant for use by trace code, and not for +direct use from application code, hence their prototypes are not in queue.h. */ +extern void vQueueSetQueueNumber( xQueueHandle pxQueue, unsigned char ucQueueNumber ); +extern unsigned char ucQueueGetQueueNumber( xQueueHandle pxQueue ); +extern unsigned char ucQueueGetQueueType( xQueueHandle pxQueue ); +extern void vTaskSetTaskNumber( xTaskHandle xTask, unsigned portBASE_TYPE uxHandle ); +extern unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask ); /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are tasks waiting to be terminated by the idle task. */ Sleep( ulMSToSleep ); /* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and - xTaskGetIdleTaskHandle() functions. */ + xTaskGetIdleTaskHandle() functions. Also try using the function that sets + the task number. */ xIdleTaskHandle = xTaskGetIdleTaskHandle(); xTimerTaskHandle = xTimerGetTimerDaemonTaskHandle(); + vTaskSetTaskNumber( xIdleTaskHandle, ( unsigned long ) ucConstTaskNumber ); + configASSERT( uxTaskGetTaskNumber( xIdleTaskHandle ) == ucConstTaskNumber ); /* This is the idle hook, so the current task handle should equal the returned idle task handle. */ @@ -251,14 +280,24 @@ signed char *pcTaskName; pcStatusMessage = "Error: Returned timer task handle was incorrect"; } - /* If xSemaphoreToDelete has not already been deleted, then delete it now. + /* If xMutexToDelete has not already been deleted, then delete it now. This is done purely to demonstrate the use of, and test, the vSemaphoreDelete() macro. Care must be taken not to delete a semaphore that has tasks blocked on it. */ - if( xSemaphoreToDelete != NULL ) + if( xMutexToDelete != NULL ) { - vSemaphoreDelete( xSemaphoreToDelete ); - xSemaphoreToDelete = NULL; + /* Before deleting the semaphore, test the function used to set its + number. This would normally only be done from trace software, rather + than application code. */ + vQueueSetQueueNumber( xMutexToDelete, ucConstQueueNumber ); + + /* Before deleting the semaphore, test the functions used to get its + type and number. Again, these would normally only be done from trace + software, rather than application code. */ + configASSERT( ucQueueGetQueueNumber( xMutexToDelete ) == ucConstQueueNumber ); + configASSERT( ucQueueGetQueueType( xMutexToDelete ) == queueQUEUE_TYPE_MUTEX ); + vSemaphoreDelete( xMutexToDelete ); + xMutexToDelete = NULL; } } /*-----------------------------------------------------------*/ -- 2.39.5