]> git.sur5r.net Git - freertos/blobdiff - Demo/PC/main.c
Update to V5.0.3.
[freertos] / Demo / PC / main.c
index 56095bc573c05cf6c001e39a887f51c0fb6de099..9c32c6adaf083b6f140ae257c207daa74dd6f16a 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-       FreeRTOS.org V4.7.0 - Copyright (C) 2003-2007 Richard Barry.\r
+       FreeRTOS.org V5.0.3 - Copyright (C) 2003-2008 Richard Barry.\r
 \r
        This file is part of the FreeRTOS.org distribution.\r
 \r
        of http://www.FreeRTOS.org for full details of how and when the exception\r
        can be applied.\r
 \r
-       ***************************************************************************\r
-       See http://www.FreeRTOS.org for documentation, latest information, license \r
-       and contact details.  Please ensure to read the configuration and relevant \r
-       port sections of the online documentation.\r
+    ***************************************************************************\r
+    ***************************************************************************\r
+    *                                                                         *\r
+    * SAVE TIME AND MONEY!  We can port FreeRTOS.org to your own hardware,    *\r
+    * and even write all or part of your application on your behalf.          *\r
+    * See http://www.OpenRTOS.com for details of the services we provide to   *\r
+    * expedite your project.                                                  *\r
+    *                                                                         *\r
+    ***************************************************************************\r
+    ***************************************************************************\r
 \r
-       Also see http://www.SafeRTOS.com a version that has been certified for use\r
-       in safety critical systems, plus commercial licensing, development and\r
-       support options.\r
-       ***************************************************************************\r
+       Please ensure to read the configuration and relevant port sections of the\r
+       online documentation.\r
+\r
+       http://www.FreeRTOS.org - Documentation, latest information, license and \r
+       contact details.\r
+\r
+       http://www.SafeRTOS.com - A version that is certified for use in safety \r
+       critical systems.\r
+\r
+       http://www.OpenRTOS.com - Commercial support, development, porting, \r
+       licensing and training services.\r
 */\r
 \r
 /**\r
 #include "AltQTest.h"\r
 #include "AltPollQ.h"\r
 #include "AltBlckQ.h"\r
+#include "RecMutex.h"\r
 \r
 /* Priority definitions for the tasks in the demo application. */\r
 #define mainLED_TASK_PRIORITY          ( tskIDLE_PRIORITY + 1 )\r
@@ -139,6 +153,14 @@ static void prvStartMathTasks( void );
 /* Check which ever tasks are relevant to this build. */\r
 static portBASE_TYPE prvCheckMathTasksAreStillRunning( void );\r
 \r
+/* Used to demonstrate the "task switched in" callback function. */\r
+static portBASE_TYPE prvExampleTaskHook( void * pvParameter );\r
+\r
+/* Just used to count the number of times the example task callback function is\r
+called, and the number of times a queue send passes. */\r
+static unsigned portLONG portLONG uxCheckTaskHookCallCount = 0;\r
+static unsigned portLONG portLONG uxQueueSendPassedCount = 0;\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 portSHORT main( void )\r
@@ -163,6 +185,7 @@ portSHORT main( void )
        vCreateAltBlockTimeTasks();\r
        vStartAltBlockingQueueTasks( mainQUEUE_BLOCK_PRIORITY );        \r
        vStartAltPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
+       vStartRecursiveMutexTasks();\r
                \r
        /* Create the "Print" task as described at the top of the file. */\r
        xTaskCreate( vErrorChecks, "Print", mainPRINT_STACK_SIZE, NULL, mainPRINT_TASK_PRIORITY, NULL );\r
@@ -185,6 +208,31 @@ portSHORT main( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+static portBASE_TYPE prvExampleTaskHook( void * pvParameter )\r
+{\r
+       if( pvParameter != ( void * ) 0xabcd )\r
+       {\r
+               /* The parameter did not contain the value we expected, so cause an\r
+               error to be detected by setting the call count back to zero. */\r
+               uxCheckTaskHookCallCount = 0;\r
+       }\r
+       else\r
+       {\r
+               /* Simply increment a number so we know the callback has been executed. */\r
+               uxCheckTaskHookCallCount++;\r
+       }\r
+\r
+       return 0;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vMainQueueSendPassed( void )\r
+{\r
+       /* This is just an example implementation of the "queue send" trace hook. */\r
+       uxQueueSendPassedCount++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 static void vErrorChecks( void *pvParameters )\r
 {\r
 portTickType xExpectedWakeTime;\r
@@ -197,6 +245,9 @@ const portCHAR * const pcTaskBlockedTooLongMsg = "Print task blocked too long!\r
 \r
        ( void ) pvParameters;\r
 \r
+       /* Register our callback function. */\r
+       vTaskSetApplicationTaskTag( NULL, prvExampleTaskHook );\r
+\r
        /* Loop continuously, blocking, then checking all the other tasks are still\r
        running, before blocking once again.  This task blocks on the queue of\r
        messages that require displaying so will wake either by its time out expiring,\r
@@ -307,6 +358,7 @@ portSHORT sIn;
 static void prvCheckOtherTasksAreStillRunning( void )\r
 {\r
 static portSHORT sErrorHasOccurred = pdFALSE;\r
+static unsigned portLONG portLONG uxLastHookCallCount = 0, uxLastQueueSendCount = 0;\r
 \r
        if( prvCheckMathTasksAreStillRunning() != pdTRUE )\r
        {\r
@@ -416,6 +468,38 @@ static portSHORT sErrorHasOccurred = pdFALSE;
                sErrorHasOccurred = pdTRUE;\r
        }\r
 \r
+       if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
+       {\r
+               vDisplayMessage( "Error in recursive mutex tasks!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+\r
+       /* The hook function associated with this task is called each time the task\r
+       is switched in.  We therefore expect the number of times the callback \r
+       function has been executed to have increrment since the last time this \r
+       function executed. */\r
+       if( uxCheckTaskHookCallCount <= uxLastHookCallCount )\r
+       {\r
+               vDisplayMessage( "Error in task hook call count!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               uxLastHookCallCount = uxCheckTaskHookCallCount;\r
+       }\r
+\r
+       /* We would expect some queue sending to occur between calls of this \r
+       function. */\r
+       if( uxQueueSendPassedCount <= uxLastQueueSendCount )\r
+       {\r
+               vDisplayMessage( "Error in queue send hook call count!\r\n" );\r
+               sErrorHasOccurred = pdTRUE;\r
+       }\r
+       else\r
+       {\r
+               uxLastQueueSendCount = uxQueueSendPassedCount;\r
+       }\r
+\r
        if( sErrorHasOccurred == pdFALSE )\r
        {\r
                vDisplayMessage( "OK " );\r