From a6f3eaaf9f149f1afa0e8effd23837b294ac2dc1 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Mon, 22 Nov 2010 10:46:54 +0000 Subject: [PATCH] Added in the 'death' tasks to the MingW Win32 demo. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1162 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../CreateProjectDirectoryStructure.bat | 2 ++ Demo/WIN32-MingW/main.c | 33 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Demo/WIN32-MingW/CreateProjectDirectoryStructure.bat b/Demo/WIN32-MingW/CreateProjectDirectoryStructure.bat index a1986dc04..26a75fa86 100644 --- a/Demo/WIN32-MingW/CreateProjectDirectoryStructure.bat +++ b/Demo/WIN32-MingW/CreateProjectDirectoryStructure.bat @@ -43,6 +43,7 @@ IF EXIST FreeRTOS Goto END copy ..\Common\include\QPeek.h DemoTasks\include copy ..\Common\include\flop.h DemoTasks\include copy ..\Common\include\recmutex.h DemoTasks\include + copy ..\Common\include\death.h DemoTasks\include copy ..\Common\Minimal\BlockQ.c DemoTasks copy ..\Common\Minimal\integer.c DemoTasks copy ..\Common\Minimal\semtest.c DemoTasks @@ -50,5 +51,6 @@ IF EXIST FreeRTOS Goto END copy ..\Common\Minimal\GenQTest.c DemoTasks copy ..\Common\Minimal\QPeek.c DemoTasks copy ..\Common\Minimal\flop.c DemoTasks + copy ..\Common\Minimal\death.c DemoTasks : END \ No newline at end of file diff --git a/Demo/WIN32-MingW/main.c b/Demo/WIN32-MingW/main.c index 5f89ef62c..d8eb1a0d0 100644 --- a/Demo/WIN32-MingW/main.c +++ b/Demo/WIN32-MingW/main.c @@ -56,12 +56,7 @@ * -NOTE- The Win32 port is a simulation (or is that emulation?) only! Do not * expect to get real time behaviour from the Win32 port or this demo * application. It is provided as a convenient development and demonstration - * test bed only. Also, at the time of writing, a method of deleting theads - * has not been implemented, although doing so would be trivial so this - * functionality might be added in at a later date. At present, calling - * vTaskDelete() will delete the real time task from FreeRTOS but not the Win32 - * thread in which the task was executing. DO NOT CALL vTaskDelete() when using - * the Win32 port! This was tested using Windows XP on a dual core laptop. + * test bed only. This was tested using Windows XP on a dual core laptop. * * - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT - ******************************************************************************* @@ -101,6 +96,7 @@ #include "QPeek.h" #include "recmutex.h" #include "flop.h" +#include "death.h" /* Priorities at which the tasks are created. */ #define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) @@ -134,6 +130,11 @@ int main( void ) vStartMathTasks( mainFLOP_TASK_PRIORITY ); vStartRecursiveMutexTasks(); + /* The suicide tasks must be created last as they need to know how many + tasks were running prior to their creation in order to ascertain whether + or not the correct/expected number of tasks are running at any given time. */ + vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); + /* Start the scheduler itself. */ vTaskStartScheduler(); @@ -189,6 +190,10 @@ char *pcStatusMessage = "OK"; { pcStatusMessage = "Error: Flop"; } + else if( xIsCreateTaskStillRunning() != pdPASS ) + { + pcStatusMessage = "Error: Create"; + } else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: RecMutex"; @@ -204,19 +209,11 @@ char *pcStatusMessage = "OK"; void vApplicationIdleHook( void ) { - /* Sleep to reduce CPU load, but don't sleep indefinitely if not using - preemption as as nothing will cause a task switch. */ - #if( configUSE_PREEMPTION != 0 ) - { - SleepEx( INFINITE, TRUE ); - } - #else - { - const unsigned long ulMSToSleep = 5; +const unsigned long ulMSToSleep = 5; - SleepEx( ulMSToSleep, TRUE ); - } - #endif + /* 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 ); } /*-----------------------------------------------------------*/ -- 2.39.5