]> git.sur5r.net Git - freertos/blob - Demo/Common/Minimal/GenQTest.c
Correct task names in BlockQ.c.
[freertos] / Demo / Common / Minimal / GenQTest.c
1 /*\r
2     FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
3         \r
4 \r
5     ***************************************************************************\r
6      *                                                                       *\r
7      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
8      *    Complete, revised, and edited pdf reference manuals are also       *\r
9      *    available.                                                         *\r
10      *                                                                       *\r
11      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
12      *    ensuring you get running as quickly as possible and with an        *\r
13      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
14      *    the FreeRTOS project to continue with its mission of providing     *\r
15      *    professional grade, cross platform, de facto standard solutions    *\r
16      *    for microcontrollers - completely free of charge!                  *\r
17      *                                                                       *\r
18      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
19      *                                                                       *\r
20      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
21      *                                                                       *\r
22     ***************************************************************************\r
23 \r
24 \r
25     This file is part of the FreeRTOS distribution.\r
26 \r
27     FreeRTOS is free software; you can redistribute it and/or modify it under\r
28     the terms of the GNU General Public License (version 2) as published by the\r
29     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
30     >>>NOTE<<< The modification to the GPL is included to allow you to\r
31     distribute a combined work that includes FreeRTOS without being obliged to\r
32     provide the source code for proprietary components outside of the FreeRTOS\r
33     kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
34     WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
35     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
36     more details. You should have received a copy of the GNU General Public\r
37     License and the FreeRTOS license exception along with FreeRTOS; if not it\r
38     can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
39     by writing to Richard Barry, contact details for whom are available on the\r
40     FreeRTOS WEB site.\r
41 \r
42     1 tab == 4 spaces!\r
43 \r
44     http://www.FreeRTOS.org - Documentation, latest information, license and\r
45     contact details.\r
46 \r
47     http://www.SafeRTOS.com - A version that is certified for use in safety\r
48     critical systems.\r
49 \r
50     http://www.OpenRTOS.com - Commercial support, development, porting,\r
51     licensing and training services.\r
52 */\r
53 \r
54 \r
55 /* \r
56  * Tests the extra queue functionality introduced in FreeRTOS.org V4.5.0 - \r
57  * including xQueueSendToFront(), xQueueSendToBack(), xQueuePeek() and \r
58  * mutex behaviour. \r
59  *\r
60  * See the comments above the prvSendFrontAndBackTest() and \r
61  * prvLowPriorityMutexTask() prototypes below for more information.\r
62  */\r
63 \r
64 \r
65 #include <stdlib.h>\r
66 \r
67 /* Scheduler include files. */\r
68 #include "FreeRTOS.h"\r
69 #include "task.h"\r
70 #include "queue.h"\r
71 #include "semphr.h"\r
72 \r
73 /* Demo program include files. */\r
74 #include "GenQTest.h"\r
75 \r
76 #define genqQUEUE_LENGTH                ( 5 )\r
77 #define genqNO_BLOCK                    ( 0 )\r
78 \r
79 #define genqMUTEX_LOW_PRIORITY          ( tskIDLE_PRIORITY )\r
80 #define genqMUTEX_TEST_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
81 #define genqMUTEX_MEDIUM_PRIORITY       ( tskIDLE_PRIORITY + 2 )\r
82 #define genqMUTEX_HIGH_PRIORITY         ( tskIDLE_PRIORITY + 3 )\r
83 \r
84 /*-----------------------------------------------------------*/\r
85 \r
86 /*\r
87  * Tests the behaviour of the xQueueSendToFront() and xQueueSendToBack()\r
88  * macros by using both to fill a queue, then reading from the queue to\r
89  * check the resultant queue order is as expected.  Queue data is also\r
90  * peeked.\r
91  */\r
92 static void prvSendFrontAndBackTest( void *pvParameters );\r
93 \r
94 /*\r
95  * The following three tasks are used to demonstrate the mutex behaviour.\r
96  * Each task is given a different priority to demonstrate the priority\r
97  * inheritance mechanism.\r
98  *\r
99  * The low priority task obtains a mutex.  After this a high priority task\r
100  * attempts to obtain the same mutex, causing its priority to be inherited\r
101  * by the low priority task.  The task with the inherited high priority then\r
102  * resumes a medium priority task to ensure it is not blocked by the medium\r
103  * priority task while it holds the inherited high priority.  Once the mutex\r
104  * is returned the task with the inherited priority returns to its original\r
105  * low priority, and is therefore immediately preempted by first the high\r
106  * priority task and then the medium prioroity task before it can continue.\r
107  */\r
108 static void prvLowPriorityMutexTask( void *pvParameters );\r
109 static void prvMediumPriorityMutexTask( void *pvParameters );\r
110 static void prvHighPriorityMutexTask( void *pvParameters );\r
111 \r
112 /*-----------------------------------------------------------*/\r
113 \r
114 /* Flag that will be latched to pdTRUE should any unexpected behaviour be\r
115 detected in any of the tasks. */\r
116 static portBASE_TYPE xErrorDetected = pdFALSE;\r
117 \r
118 /* Counters that are incremented on each cycle of a test.  This is used to\r
119 detect a stalled task - a test that is no longer running. */\r
120 static volatile unsigned portLONG ulLoopCounter = 0;\r
121 static volatile unsigned portLONG ulLoopCounter2 = 0;\r
122 \r
123 /* The variable that is guarded by the mutex in the mutex demo tasks. */\r
124 static volatile unsigned portLONG ulGuardedVariable = 0;\r
125 \r
126 /* Handles used in the mutext test to suspend and resume the high and medium\r
127 priority mutex test tasks. */\r
128 static xTaskHandle xHighPriorityMutexTask, xMediumPriorityMutexTask;\r
129 \r
130 /*-----------------------------------------------------------*/\r
131 \r
132 void vStartGenericQueueTasks( unsigned portBASE_TYPE uxPriority )\r
133 {\r
134 xQueueHandle xQueue;\r
135 xSemaphoreHandle xMutex;\r
136 \r
137         /* Create the queue that we are going to use for the\r
138         prvSendFrontAndBackTest demo. */\r
139         xQueue = xQueueCreate( genqQUEUE_LENGTH, sizeof( unsigned portLONG ) );\r
140 \r
141         /* vQueueAddToRegistry() adds the queue to the queue registry, if one is\r
142         in use.  The queue registry is provided as a means for kernel aware \r
143         debuggers to locate queues and has no purpose if a kernel aware debugger\r
144         is not being used.  The call to vQueueAddToRegistry() will be removed\r
145         by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is \r
146         defined to be less than 1. */\r
147         vQueueAddToRegistry( xQueue, ( signed portCHAR * ) "Gen_Queue_Test" );\r
148 \r
149         /* Create the demo task and pass it the queue just created.  We are\r
150         passing the queue handle by value so it does not matter that it is\r
151         declared on the stack here. */\r
152         xTaskCreate( prvSendFrontAndBackTest, ( signed portCHAR * )"GenQ", configMINIMAL_STACK_SIZE, ( void * ) xQueue, uxPriority, NULL );\r
153 \r
154         /* Create the mutex used by the prvMutexTest task. */\r
155         xMutex = xSemaphoreCreateMutex();\r
156 \r
157         /* vQueueAddToRegistry() adds the mutex to the registry, if one is\r
158         in use.  The registry is provided as a means for kernel aware \r
159         debuggers to locate mutexes and has no purpose if a kernel aware debugger\r
160         is not being used.  The call to vQueueAddToRegistry() will be removed\r
161         by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is \r
162         defined to be less than 1. */\r
163         vQueueAddToRegistry( ( xQueueHandle ) xMutex, ( signed portCHAR * ) "Gen_Queue_Mutex" );\r
164 \r
165         /* Create the mutex demo tasks and pass it the mutex just created.  We are\r
166         passing the mutex handle by value so it does not matter that it is declared\r
167         on the stack here. */\r
168         xTaskCreate( prvLowPriorityMutexTask, ( signed portCHAR * )"MuLow", configMINIMAL_STACK_SIZE, ( void * ) xMutex, genqMUTEX_LOW_PRIORITY, NULL );\r
169         xTaskCreate( prvMediumPriorityMutexTask, ( signed portCHAR * )"MuMed", configMINIMAL_STACK_SIZE, NULL, genqMUTEX_MEDIUM_PRIORITY, &xMediumPriorityMutexTask );\r
170         xTaskCreate( prvHighPriorityMutexTask, ( signed portCHAR * )"MuHigh", configMINIMAL_STACK_SIZE, ( void * ) xMutex, genqMUTEX_HIGH_PRIORITY, &xHighPriorityMutexTask );\r
171 }\r
172 /*-----------------------------------------------------------*/\r
173 \r
174 static void prvSendFrontAndBackTest( void *pvParameters )\r
175 {\r
176 unsigned portLONG ulData, ulData2;\r
177 xQueueHandle xQueue;\r
178 \r
179         #ifdef USE_STDIO\r
180         void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend );\r
181         \r
182                 const portCHAR * const pcTaskStartMsg = "Queue SendToFront/SendToBack/Peek test started.\r\n";\r
183 \r
184                 /* Queue a message for printing to say the task has started. */\r
185                 vPrintDisplayMessage( &pcTaskStartMsg );\r
186         #endif\r
187 \r
188         xQueue = ( xQueueHandle ) pvParameters;\r
189 \r
190         for( ;; )\r
191         {\r
192                 /* The queue is empty, so sending an item to the back of the queue\r
193                 should have the same efect as sending it to the front of the queue.\r
194 \r
195                 First send to the front and check everything is as expected. */\r
196                 xQueueSendToFront( xQueue, ( void * ) &ulLoopCounter, genqNO_BLOCK );\r
197 \r
198                 if( uxQueueMessagesWaiting( xQueue ) != 1 )\r
199                 {\r
200                         xErrorDetected = pdTRUE;\r
201                 }\r
202 \r
203                 if( xQueueReceive( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS )\r
204                 {\r
205                         xErrorDetected = pdTRUE;\r
206                 }\r
207 \r
208                 /* The data we sent to the queue should equal the data we just received\r
209                 from the queue. */\r
210                 if( ulLoopCounter != ulData )\r
211                 {\r
212                         xErrorDetected = pdTRUE;\r
213                 }\r
214 \r
215                 /* Then do the same, sending the data to the back, checking everything\r
216                 is as expected. */\r
217                 if( uxQueueMessagesWaiting( xQueue ) != 0 )\r
218                 {\r
219                         xErrorDetected = pdTRUE;\r
220                 }\r
221 \r
222                 xQueueSendToBack( xQueue, ( void * ) &ulLoopCounter, genqNO_BLOCK );\r
223 \r
224                 if( uxQueueMessagesWaiting( xQueue ) != 1 )\r
225                 {\r
226                         xErrorDetected = pdTRUE;\r
227                 }\r
228 \r
229                 if( xQueueReceive( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS )\r
230                 {\r
231                         xErrorDetected = pdTRUE;\r
232                 }\r
233 \r
234                 if( uxQueueMessagesWaiting( xQueue ) != 0 )\r
235                 {\r
236                         xErrorDetected = pdTRUE;\r
237                 }\r
238 \r
239                 /* The data we sent to the queue should equal the data we just received\r
240                 from the queue. */\r
241                 if( ulLoopCounter != ulData )\r
242                 {\r
243                         xErrorDetected = pdTRUE;\r
244                 }\r
245 \r
246                 #if configUSE_PREEMPTION == 0\r
247                         taskYIELD();\r
248                 #endif\r
249 \r
250 \r
251 \r
252                 /* Place 2, 3, 4 into the queue, adding items to the back of the queue. */\r
253                 for( ulData = 2; ulData < 5; ulData++ )\r
254                 {\r
255                         xQueueSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK );\r
256                 }\r
257 \r
258                 /* Now the order in the queue should be 2, 3, 4, with 2 being the first\r
259                 thing to be read out.  Now add 1 then 0 to the front of the queue. */\r
260                 if( uxQueueMessagesWaiting( xQueue ) != 3 )\r
261                 {\r
262                         xErrorDetected = pdTRUE;\r
263                 }\r
264                 ulData = 1;\r
265                 xQueueSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK );\r
266                 ulData = 0;\r
267                 xQueueSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK );\r
268 \r
269                 /* Now the queue should be full, and when we read the data out we\r
270                 should receive 0, 1, 2, 3, 4. */\r
271                 if( uxQueueMessagesWaiting( xQueue ) != 5 )\r
272                 {\r
273                         xErrorDetected = pdTRUE;\r
274                 }\r
275 \r
276                 if( xQueueSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )\r
277                 {\r
278                         xErrorDetected = pdTRUE;\r
279                 }\r
280 \r
281                 if( xQueueSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )\r
282                 {\r
283                         xErrorDetected = pdTRUE;\r
284                 }\r
285 \r
286                 #if configUSE_PREEMPTION == 0\r
287                         taskYIELD();\r
288                 #endif\r
289 \r
290                 /* Check the data we read out is in the expected order. */\r
291                 for( ulData = 0; ulData < genqQUEUE_LENGTH; ulData++ )\r
292                 {\r
293                         /* Try peeking the data first. */\r
294                         if( xQueuePeek( xQueue, &ulData2, genqNO_BLOCK ) != pdPASS )\r
295                         {\r
296                                 xErrorDetected = pdTRUE;\r
297                         }\r
298 \r
299                         if( ulData != ulData2 )\r
300                         {\r
301                                 xErrorDetected = pdTRUE;\r
302                         }\r
303                         \r
304 \r
305                         /* Now try receiving the data for real.  The value should be the\r
306                         same.  Clobber the value first so we know we really received it. */\r
307                         ulData2 = ~ulData2;\r
308                         if( xQueueReceive( xQueue, &ulData2, genqNO_BLOCK ) != pdPASS )\r
309                         {\r
310                                 xErrorDetected = pdTRUE;\r
311                         }\r
312 \r
313                         if( ulData != ulData2 )\r
314                         {\r
315                                 xErrorDetected = pdTRUE;\r
316                         }\r
317                 }\r
318 \r
319                 /* The queue should now be empty again. */\r
320                 if( uxQueueMessagesWaiting( xQueue ) != 0 )\r
321                 {\r
322                         xErrorDetected = pdTRUE;\r
323                 }\r
324 \r
325                 #if configUSE_PREEMPTION == 0\r
326                         taskYIELD();\r
327                 #endif\r
328 \r
329 \r
330                 /* Our queue is empty once more, add 10, 11 to the back. */\r
331                 ulData = 10;\r
332                 if( xQueueSend( xQueue, &ulData, genqNO_BLOCK ) != pdPASS )\r
333                 {\r
334                         xErrorDetected = pdTRUE;\r
335                 }\r
336                 ulData = 11;\r
337                 if( xQueueSend( xQueue, &ulData, genqNO_BLOCK ) != pdPASS )\r
338                 {\r
339                         xErrorDetected = pdTRUE;\r
340                 }\r
341 \r
342                 if( uxQueueMessagesWaiting( xQueue ) != 2 )\r
343                 {\r
344                         xErrorDetected = pdTRUE;\r
345                 }\r
346 \r
347                 /* Now we should have 10, 11 in the queue.  Add 7, 8, 9 to the\r
348                 front. */\r
349                 for( ulData = 9; ulData >= 7; ulData-- )\r
350                 {\r
351                         if( xQueueSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS )\r
352                         {\r
353                                 xErrorDetected = pdTRUE;\r
354                         }\r
355                 }\r
356 \r
357                 /* Now check that the queue is full, and that receiving data provides\r
358                 the expected sequence of 7, 8, 9, 10, 11. */\r
359                 if( uxQueueMessagesWaiting( xQueue ) != 5 )\r
360                 {\r
361                         xErrorDetected = pdTRUE;\r
362                 }\r
363 \r
364                 if( xQueueSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )\r
365                 {\r
366                         xErrorDetected = pdTRUE;\r
367                 }\r
368 \r
369                 if( xQueueSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )\r
370                 {\r
371                         xErrorDetected = pdTRUE;\r
372                 }\r
373 \r
374                 #if configUSE_PREEMPTION == 0\r
375                         taskYIELD();\r
376                 #endif\r
377 \r
378                 /* Check the data we read out is in the expected order. */\r
379                 for( ulData = 7; ulData < ( 7 + genqQUEUE_LENGTH ); ulData++ )\r
380                 {\r
381                         if( xQueueReceive( xQueue, &ulData2, genqNO_BLOCK ) != pdPASS )\r
382                         {\r
383                                 xErrorDetected = pdTRUE;\r
384                         }\r
385 \r
386                         if( ulData != ulData2 )\r
387                         {\r
388                                 xErrorDetected = pdTRUE;\r
389                         }\r
390                 }\r
391 \r
392                 if( uxQueueMessagesWaiting( xQueue ) != 0 )\r
393                 {\r
394                         xErrorDetected = pdTRUE;\r
395                 }\r
396 \r
397                 ulLoopCounter++;\r
398         }\r
399 }\r
400 /*-----------------------------------------------------------*/\r
401 \r
402 static void prvLowPriorityMutexTask( void *pvParameters )\r
403 {\r
404 xSemaphoreHandle xMutex = ( xSemaphoreHandle ) pvParameters;\r
405 \r
406         #ifdef USE_STDIO\r
407         void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend );\r
408         \r
409                 const portCHAR * const pcTaskStartMsg = "Mutex with priority inheritance test started.\r\n";\r
410 \r
411                 /* Queue a message for printing to say the task has started. */\r
412                 vPrintDisplayMessage( &pcTaskStartMsg );\r
413         #endif\r
414 \r
415         for( ;; )\r
416         {\r
417                 /* Take the mutex.  It should be available now. */\r
418                 if( xSemaphoreTake( xMutex, genqNO_BLOCK ) != pdPASS )\r
419                 {\r
420                         xErrorDetected = pdTRUE;\r
421                 }\r
422 \r
423                 /* Set our guarded variable to a known start value. */\r
424                 ulGuardedVariable = 0;\r
425 \r
426                 /* Our priority should be as per that assigned when the task was\r
427                 created. */\r
428                 if( uxTaskPriorityGet( NULL ) != genqMUTEX_LOW_PRIORITY )\r
429                 {\r
430                         xErrorDetected = pdTRUE;\r
431                 }\r
432 \r
433                 /* Now unsuspend the high priority task.  This will attempt to take the\r
434                 mutex, and block when it finds it cannot obtain it. */\r
435                 vTaskResume( xHighPriorityMutexTask );\r
436 \r
437                 /* We should now have inherited the prioritoy of the high priority task,\r
438                 as by now it will have attempted to get the mutex. */\r
439                 if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
440                 {\r
441                         xErrorDetected = pdTRUE;\r
442                 }\r
443 \r
444                 /* We can attempt to set our priority to the test priority - between the\r
445                 idle priority and the medium/high test priorities, but our actual\r
446                 prioroity should remain at the high priority. */\r
447                 vTaskPrioritySet( NULL, genqMUTEX_TEST_PRIORITY );\r
448                 if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
449                 {\r
450                         xErrorDetected = pdTRUE;\r
451                 }\r
452 \r
453                 /* Now unsuspend the medium priority task.  This should not run as our\r
454                 inherited priority is above that of the medium priority task. */\r
455                 vTaskResume( xMediumPriorityMutexTask );\r
456 \r
457                 /* If the did run then it will have incremented our guarded variable. */\r
458                 if( ulGuardedVariable != 0 )\r
459                 {\r
460                         xErrorDetected = pdTRUE;\r
461                 }\r
462 \r
463                 /* When we give back the semaphore our priority should be disinherited\r
464                 back to the priority to which we attempted to set ourselves.  This means\r
465                 that when the high priority task next blocks, the medium priority task\r
466                 should execute and increment the guarded variable.   When we next run\r
467                 both the high and medium priority tasks will have been suspended again. */\r
468                 if( xSemaphoreGive( xMutex ) != pdPASS )\r
469                 {\r
470                         xErrorDetected = pdTRUE;\r
471                 }\r
472 \r
473                 /* Check that the guarded variable did indeed increment... */\r
474                 if( ulGuardedVariable != 1 )\r
475                 {\r
476                         xErrorDetected = pdTRUE;\r
477                 }\r
478 \r
479                 /* ... and that our priority has been disinherited to\r
480                 genqMUTEX_TEST_PRIORITY. */\r
481                 if( uxTaskPriorityGet( NULL ) != genqMUTEX_TEST_PRIORITY )\r
482                 {\r
483                         xErrorDetected = pdTRUE;\r
484                 }\r
485 \r
486                 /* Set our priority back to our original priority ready for the next\r
487                 loop around this test. */\r
488                 vTaskPrioritySet( NULL, genqMUTEX_LOW_PRIORITY );\r
489 \r
490                 /* Just to show we are still running. */\r
491                 ulLoopCounter2++;\r
492 \r
493                 #if configUSE_PREEMPTION == 0\r
494                         taskYIELD();\r
495                 #endif          \r
496         }\r
497 }\r
498 /*-----------------------------------------------------------*/\r
499 \r
500 static void prvMediumPriorityMutexTask( void *pvParameters )\r
501 {\r
502         ( void ) pvParameters;\r
503 \r
504         for( ;; )\r
505         {\r
506                 /* The medium priority task starts by suspending itself.  The low\r
507                 priority task will unsuspend this task when required. */\r
508                 vTaskSuspend( NULL );\r
509 \r
510                 /* When this task unsuspends all it does is increment the guarded\r
511                 variable, this is so the low priority task knows that it has\r
512                 executed. */\r
513                 ulGuardedVariable++;\r
514         }\r
515 }\r
516 /*-----------------------------------------------------------*/\r
517 \r
518 static void prvHighPriorityMutexTask( void *pvParameters )\r
519 {\r
520 xSemaphoreHandle xMutex = ( xSemaphoreHandle ) pvParameters;\r
521 \r
522         for( ;; )\r
523         {\r
524                 /* The high priority task starts by suspending itself.  The low\r
525                 priority task will unsuspend this task when required. */\r
526                 vTaskSuspend( NULL );\r
527 \r
528                 /* When this task unsuspends all it does is attempt to obtain\r
529                 the mutex.  It should find the mutex is not available so a\r
530                 block time is specified. */\r
531                 if( xSemaphoreTake( xMutex, portMAX_DELAY ) != pdPASS )\r
532                 {\r
533                         xErrorDetected = pdTRUE;\r
534                 }\r
535 \r
536                 /* When we eventually obtain the mutex we just give it back then\r
537                 return to suspend ready for the next test. */\r
538                 if( xSemaphoreGive( xMutex ) != pdPASS )\r
539                 {\r
540                         xErrorDetected = pdTRUE;\r
541                 }               \r
542         }\r
543 }\r
544 /*-----------------------------------------------------------*/\r
545 \r
546 /* This is called to check that all the created tasks are still running. */\r
547 portBASE_TYPE xAreGenericQueueTasksStillRunning( void )\r
548 {\r
549 static unsigned portLONG ulLastLoopCounter = 0, ulLastLoopCounter2 = 0;\r
550 \r
551         /* If the demo task is still running then we expect the loopcounters to\r
552         have incremented since this function was last called. */\r
553         if( ulLastLoopCounter == ulLoopCounter )\r
554         {\r
555                 xErrorDetected = pdTRUE;\r
556         }\r
557 \r
558         if( ulLastLoopCounter2 == ulLoopCounter2 )\r
559         {\r
560                 xErrorDetected = pdTRUE;\r
561         }\r
562 \r
563         ulLastLoopCounter = ulLoopCounter;\r
564         ulLastLoopCounter2 = ulLoopCounter2;    \r
565 \r
566         /* Errors detected in the task itself will have latched xErrorDetected\r
567         to true. */\r
568 \r
569         return !xErrorDetected;\r
570 }\r
571 \r
572 \r