]> git.sur5r.net Git - freertos/blob - Demo/Common/Minimal/AltQTest.c
Correct task names in BlockQ.c.
[freertos] / Demo / Common / Minimal / AltQTest.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  * This file implements the same demo and test as GenQTest.c, but uses the \r
57  * light weight API in place of the fully featured API.\r
58  *\r
59  * See the comments at the top of GenQTest.c for a description.\r
60  */\r
61 \r
62 \r
63 #include <stdlib.h>\r
64 \r
65 /* Scheduler include files. */\r
66 #include "FreeRTOS.h"\r
67 #include "task.h"\r
68 #include "queue.h"\r
69 #include "semphr.h"\r
70 \r
71 /* Demo program include files. */\r
72 #include "AltQTest.h"\r
73 \r
74 #define genqQUEUE_LENGTH                ( 5 )\r
75 #define genqNO_BLOCK                    ( 0 )\r
76 \r
77 #define genqMUTEX_LOW_PRIORITY          ( tskIDLE_PRIORITY )\r
78 #define genqMUTEX_TEST_PRIORITY         ( tskIDLE_PRIORITY + 1 )\r
79 #define genqMUTEX_MEDIUM_PRIORITY       ( tskIDLE_PRIORITY + 2 )\r
80 #define genqMUTEX_HIGH_PRIORITY         ( tskIDLE_PRIORITY + 3 )\r
81 \r
82 /*-----------------------------------------------------------*/\r
83 \r
84 /*\r
85  * Tests the behaviour of the xQueueAltSendToFront() and xQueueAltSendToBack()\r
86  * macros by using both to fill a queue, then reading from the queue to\r
87  * check the resultant queue order is as expected.  Queue data is also\r
88  * peeked.\r
89  */\r
90 static void prvSendFrontAndBackTest( void *pvParameters );\r
91 \r
92 /*\r
93  * The following three tasks are used to demonstrate the mutex behaviour.\r
94  * Each task is given a different priority to demonstrate the priority\r
95  * inheritance mechanism.\r
96  *\r
97  * The low priority task obtains a mutex.  After this a high priority task\r
98  * attempts to obtain the same mutex, causing its priority to be inherited\r
99  * by the low priority task.  The task with the inherited high priority then\r
100  * resumes a medium priority task to ensure it is not blocked by the medium\r
101  * priority task while it holds the inherited high priority.  Once the mutex\r
102  * is returned the task with the inherited priority returns to its original\r
103  * low priority, and is therefore immediately preempted by first the high\r
104  * priority task and then the medium prioroity task before it can continue.\r
105  */\r
106 static void prvLowPriorityMutexTask( void *pvParameters );\r
107 static void prvMediumPriorityMutexTask( void *pvParameters );\r
108 static void prvHighPriorityMutexTask( void *pvParameters );\r
109 \r
110 /*-----------------------------------------------------------*/\r
111 \r
112 /* Flag that will be latched to pdTRUE should any unexpected behaviour be\r
113 detected in any of the tasks. */\r
114 static portBASE_TYPE xErrorDetected = pdFALSE;\r
115 \r
116 /* Counters that are incremented on each cycle of a test.  This is used to\r
117 detect a stalled task - a test that is no longer running. */\r
118 static volatile unsigned portLONG ulLoopCounter = 0;\r
119 static volatile unsigned portLONG ulLoopCounter2 = 0;\r
120 \r
121 /* The variable that is guarded by the mutex in the mutex demo tasks. */\r
122 static volatile unsigned portLONG ulGuardedVariable = 0;\r
123 \r
124 /* Handles used in the mutext test to suspend and resume the high and medium\r
125 priority mutex test tasks. */\r
126 static xTaskHandle xHighPriorityMutexTask, xMediumPriorityMutexTask;\r
127 \r
128 /*-----------------------------------------------------------*/\r
129 \r
130 void vStartAltGenericQueueTasks( unsigned portBASE_TYPE uxPriority )\r
131 {\r
132 xQueueHandle xQueue;\r
133 xSemaphoreHandle xMutex;\r
134 \r
135         /* Create the queue that we are going to use for the\r
136         prvSendFrontAndBackTest demo. */\r
137         xQueue = xQueueCreate( genqQUEUE_LENGTH, sizeof( unsigned portLONG ) );\r
138 \r
139         /* vQueueAddToRegistry() adds the queue to the queue registry, if one is\r
140         in use.  The queue registry is provided as a means for kernel aware \r
141         debuggers to locate queues and has no purpose if a kernel aware debugger\r
142         is not being used.  The call to vQueueAddToRegistry() will be removed\r
143         by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is \r
144         defined to be less than 1. */\r
145         vQueueAddToRegistry( xQueue, ( signed portCHAR * ) "Alt_Gen_Test_Queue" );\r
146 \r
147         /* Create the demo task and pass it the queue just created.  We are\r
148         passing the queue handle by value so it does not matter that it is\r
149         declared on the stack here. */\r
150         xTaskCreate( prvSendFrontAndBackTest, ( signed portCHAR * ) "FGenQ", configMINIMAL_STACK_SIZE, ( void * ) xQueue, uxPriority, NULL );\r
151 \r
152         /* Create the mutex used by the prvMutexTest task. */\r
153         xMutex = xSemaphoreCreateMutex();\r
154 \r
155         /* vQueueAddToRegistry() adds the mutex to the registry, if one is\r
156         in use.  The registry is provided as a means for kernel aware \r
157         debuggers to locate mutex and has no purpose if a kernel aware debugger\r
158         is not being used.  The call to vQueueAddToRegistry() will be removed\r
159         by the pre-processor if configQUEUE_REGISTRY_SIZE is not defined or is \r
160         defined to be less than 1. */\r
161         vQueueAddToRegistry( ( xQueueHandle ) xMutex, ( signed portCHAR * ) "Alt_Q_Mutex" );\r
162 \r
163         /* Create the mutex demo tasks and pass it the mutex just created.  We are\r
164         passing the mutex handle by value so it does not matter that it is declared\r
165         on the stack here. */\r
166         xTaskCreate( prvLowPriorityMutexTask, ( signed portCHAR * ) "FMuLow", configMINIMAL_STACK_SIZE, ( void * ) xMutex, genqMUTEX_LOW_PRIORITY, NULL );\r
167         xTaskCreate( prvMediumPriorityMutexTask, ( signed portCHAR * ) "FMuMed", configMINIMAL_STACK_SIZE, NULL, genqMUTEX_MEDIUM_PRIORITY, &xMediumPriorityMutexTask );\r
168         xTaskCreate( prvHighPriorityMutexTask, ( signed portCHAR * ) "FMuHigh", configMINIMAL_STACK_SIZE, ( void * ) xMutex, genqMUTEX_HIGH_PRIORITY, &xHighPriorityMutexTask );\r
169 }\r
170 /*-----------------------------------------------------------*/\r
171 \r
172 static void prvSendFrontAndBackTest( void *pvParameters )\r
173 {\r
174 unsigned portLONG ulData, ulData2;\r
175 xQueueHandle xQueue;\r
176 \r
177         #ifdef USE_STDIO\r
178         void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend );\r
179         \r
180                 const portCHAR * const pcTaskStartMsg = "Alt queue SendToFront/SendToBack/Peek test started.\r\n";\r
181 \r
182                 /* Queue a message for printing to say the task has started. */\r
183                 vPrintDisplayMessage( &pcTaskStartMsg );\r
184         #endif\r
185 \r
186         xQueue = ( xQueueHandle ) pvParameters;\r
187 \r
188         for( ;; )\r
189         {\r
190                 /* The queue is empty, so sending an item to the back of the queue\r
191                 should have the same efect as sending it to the front of the queue.\r
192 \r
193                 First send to the front and check everything is as expected. */\r
194                 xQueueAltSendToFront( xQueue, ( void * ) &ulLoopCounter, genqNO_BLOCK );\r
195 \r
196                 if( uxQueueMessagesWaiting( xQueue ) != 1 )\r
197                 {\r
198                         xErrorDetected = pdTRUE;\r
199                 }\r
200 \r
201                 if( xQueueAltReceive( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS )\r
202                 {\r
203                         xErrorDetected = pdTRUE;\r
204                 }\r
205 \r
206                 /* The data we sent to the queue should equal the data we just received\r
207                 from the queue. */\r
208                 if( ulLoopCounter != ulData )\r
209                 {\r
210                         xErrorDetected = pdTRUE;\r
211                 }\r
212 \r
213                 /* Then do the same, sending the data to the back, checking everything\r
214                 is as expected. */\r
215                 if( uxQueueMessagesWaiting( xQueue ) != 0 )\r
216                 {\r
217                         xErrorDetected = pdTRUE;\r
218                 }\r
219 \r
220                 xQueueAltSendToBack( xQueue, ( void * ) &ulLoopCounter, genqNO_BLOCK );\r
221 \r
222                 if( uxQueueMessagesWaiting( xQueue ) != 1 )\r
223                 {\r
224                         xErrorDetected = pdTRUE;\r
225                 }\r
226 \r
227                 if( xQueueAltReceive( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS )\r
228                 {\r
229                         xErrorDetected = pdTRUE;\r
230                 }\r
231 \r
232                 if( uxQueueMessagesWaiting( xQueue ) != 0 )\r
233                 {\r
234                         xErrorDetected = pdTRUE;\r
235                 }\r
236 \r
237                 /* The data we sent to the queue should equal the data we just received\r
238                 from the queue. */\r
239                 if( ulLoopCounter != ulData )\r
240                 {\r
241                         xErrorDetected = pdTRUE;\r
242                 }\r
243 \r
244                 #if configUSE_PREEMPTION == 0\r
245                         taskYIELD();\r
246                 #endif\r
247 \r
248 \r
249 \r
250                 /* Place 2, 3, 4 into the queue, adding items to the back of the queue. */\r
251                 for( ulData = 2; ulData < 5; ulData++ )\r
252                 {\r
253                         xQueueAltSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK );\r
254                 }\r
255 \r
256                 /* Now the order in the queue should be 2, 3, 4, with 2 being the first\r
257                 thing to be read out.  Now add 1 then 0 to the front of the queue. */\r
258                 if( uxQueueMessagesWaiting( xQueue ) != 3 )\r
259                 {\r
260                         xErrorDetected = pdTRUE;\r
261                 }\r
262                 ulData = 1;\r
263                 xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK );\r
264                 ulData = 0;\r
265                 xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK );\r
266 \r
267                 /* Now the queue should be full, and when we read the data out we\r
268                 should receive 0, 1, 2, 3, 4. */\r
269                 if( uxQueueMessagesWaiting( xQueue ) != 5 )\r
270                 {\r
271                         xErrorDetected = pdTRUE;\r
272                 }\r
273 \r
274                 if( xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )\r
275                 {\r
276                         xErrorDetected = pdTRUE;\r
277                 }\r
278 \r
279                 if( xQueueAltSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )\r
280                 {\r
281                         xErrorDetected = pdTRUE;\r
282                 }\r
283 \r
284                 #if configUSE_PREEMPTION == 0\r
285                         taskYIELD();\r
286                 #endif\r
287 \r
288                 /* Check the data we read out is in the expected order. */\r
289                 for( ulData = 0; ulData < genqQUEUE_LENGTH; ulData++ )\r
290                 {\r
291                         /* Try peeking the data first. */\r
292                         if( xQueueAltPeek( xQueue, &ulData2, genqNO_BLOCK ) != pdPASS )\r
293                         {\r
294                                 xErrorDetected = pdTRUE;\r
295                         }\r
296 \r
297                         if( ulData != ulData2 )\r
298                         {\r
299                                 xErrorDetected = pdTRUE;\r
300                         }\r
301                         \r
302 \r
303                         /* Now try receiving the data for real.  The value should be the\r
304                         same.  Clobber the value first so we know we really received it. */\r
305                         ulData2 = ~ulData2;\r
306                         if( xQueueAltReceive( xQueue, &ulData2, genqNO_BLOCK ) != pdPASS )\r
307                         {\r
308                                 xErrorDetected = pdTRUE;\r
309                         }\r
310 \r
311                         if( ulData != ulData2 )\r
312                         {\r
313                                 xErrorDetected = pdTRUE;\r
314                         }\r
315                 }\r
316 \r
317                 /* The queue should now be empty again. */\r
318                 if( uxQueueMessagesWaiting( xQueue ) != 0 )\r
319                 {\r
320                         xErrorDetected = pdTRUE;\r
321                 }\r
322 \r
323                 #if configUSE_PREEMPTION == 0\r
324                         taskYIELD();\r
325                 #endif\r
326 \r
327 \r
328                 /* Our queue is empty once more, add 10, 11 to the back. */\r
329                 ulData = 10;\r
330                 if( xQueueAltSendToBack( xQueue, &ulData, genqNO_BLOCK ) != pdPASS )\r
331                 {\r
332                         xErrorDetected = pdTRUE;\r
333                 }\r
334                 ulData = 11;\r
335                 if( xQueueAltSendToBack( xQueue, &ulData, genqNO_BLOCK ) != pdPASS )\r
336                 {\r
337                         xErrorDetected = pdTRUE;\r
338                 }\r
339 \r
340                 if( uxQueueMessagesWaiting( xQueue ) != 2 )\r
341                 {\r
342                         xErrorDetected = pdTRUE;\r
343                 }\r
344 \r
345                 /* Now we should have 10, 11 in the queue.  Add 7, 8, 9 to the\r
346                 front. */\r
347                 for( ulData = 9; ulData >= 7; ulData-- )\r
348                 {\r
349                         if( xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS )\r
350                         {\r
351                                 xErrorDetected = pdTRUE;\r
352                         }\r
353                 }\r
354 \r
355                 /* Now check that the queue is full, and that receiving data provides\r
356                 the expected sequence of 7, 8, 9, 10, 11. */\r
357                 if( uxQueueMessagesWaiting( xQueue ) != 5 )\r
358                 {\r
359                         xErrorDetected = pdTRUE;\r
360                 }\r
361 \r
362                 if( xQueueAltSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )\r
363                 {\r
364                         xErrorDetected = pdTRUE;\r
365                 }\r
366 \r
367                 if( xQueueAltSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != errQUEUE_FULL )\r
368                 {\r
369                         xErrorDetected = pdTRUE;\r
370                 }\r
371 \r
372                 #if configUSE_PREEMPTION == 0\r
373                         taskYIELD();\r
374                 #endif\r
375 \r
376                 /* Check the data we read out is in the expected order. */\r
377                 for( ulData = 7; ulData < ( 7 + genqQUEUE_LENGTH ); ulData++ )\r
378                 {\r
379                         if( xQueueAltReceive( xQueue, &ulData2, genqNO_BLOCK ) != pdPASS )\r
380                         {\r
381                                 xErrorDetected = pdTRUE;\r
382                         }\r
383 \r
384                         if( ulData != ulData2 )\r
385                         {\r
386                                 xErrorDetected = pdTRUE;\r
387                         }\r
388                 }\r
389 \r
390                 if( uxQueueMessagesWaiting( xQueue ) != 0 )\r
391                 {\r
392                         xErrorDetected = pdTRUE;\r
393                 }\r
394 \r
395                 ulLoopCounter++;\r
396         }\r
397 }\r
398 /*-----------------------------------------------------------*/\r
399 \r
400 static void prvLowPriorityMutexTask( void *pvParameters )\r
401 {\r
402 xSemaphoreHandle xMutex = ( xSemaphoreHandle ) pvParameters;\r
403 \r
404         #ifdef USE_STDIO\r
405         void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend );\r
406         \r
407                 const portCHAR * const pcTaskStartMsg = "Fast mutex with priority inheritance test started.\r\n";\r
408 \r
409                 /* Queue a message for printing to say the task has started. */\r
410                 vPrintDisplayMessage( &pcTaskStartMsg );\r
411         #endif\r
412 \r
413         ( void ) pvParameters;\r
414 \r
415 \r
416         for( ;; )\r
417         {\r
418                 /* Take the mutex.  It should be available now. */\r
419                 if( xSemaphoreAltTake( xMutex, genqNO_BLOCK ) != pdPASS )\r
420                 {\r
421                         xErrorDetected = pdTRUE;\r
422                 }\r
423 \r
424                 /* Set our guarded variable to a known start value. */\r
425                 ulGuardedVariable = 0;\r
426 \r
427                 /* Our priority should be as per that assigned when the task was\r
428                 created. */\r
429                 if( uxTaskPriorityGet( NULL ) != genqMUTEX_LOW_PRIORITY )\r
430                 {\r
431                         xErrorDetected = pdTRUE;\r
432                 }\r
433 \r
434                 /* Now unsuspend the high priority task.  This will attempt to take the\r
435                 mutex, and block when it finds it cannot obtain it. */\r
436                 vTaskResume( xHighPriorityMutexTask );\r
437 \r
438                 /* We should now have inherited the prioritoy of the high priority task,\r
439                 as by now it will have attempted to get the mutex. */\r
440                 if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
441                 {\r
442                         xErrorDetected = pdTRUE;\r
443                 }\r
444 \r
445                 /* We can attempt to set our priority to the test priority - between the\r
446                 idle priority and the medium/high test priorities, but our actual\r
447                 prioroity should remain at the high priority. */\r
448                 vTaskPrioritySet( NULL, genqMUTEX_TEST_PRIORITY );\r
449                 if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY )\r
450                 {\r
451                         xErrorDetected = pdTRUE;\r
452                 }\r
453 \r
454                 /* Now unsuspend the medium priority task.  This should not run as our\r
455                 inherited priority is above that of the medium priority task. */\r
456                 vTaskResume( xMediumPriorityMutexTask );\r
457 \r
458                 /* If the did run then it will have incremented our guarded variable. */\r
459                 if( ulGuardedVariable != 0 )\r
460                 {\r
461                         xErrorDetected = pdTRUE;\r
462                 }\r
463 \r
464                 /* When we give back the semaphore our priority should be disinherited\r
465                 back to the priority to which we attempted to set ourselves.  This means\r
466                 that when the high priority task next blocks, the medium priority task\r
467                 should execute and increment the guarded variable.   When we next run\r
468                 both the high and medium priority tasks will have been suspended again. */\r
469                 if( xSemaphoreAltGive( xMutex ) != pdPASS )\r
470                 {\r
471                         xErrorDetected = pdTRUE;\r
472                 }\r
473 \r
474                 /* Check that the guarded variable did indeed increment... */\r
475                 if( ulGuardedVariable != 1 )\r
476                 {\r
477                         xErrorDetected = pdTRUE;\r
478                 }\r
479 \r
480                 /* ... and that our priority has been disinherited to\r
481                 genqMUTEX_TEST_PRIORITY. */\r
482                 if( uxTaskPriorityGet( NULL ) != genqMUTEX_TEST_PRIORITY )\r
483                 {\r
484                         xErrorDetected = pdTRUE;\r
485                 }\r
486 \r
487                 /* Set our priority back to our original priority ready for the next\r
488                 loop around this test. */\r
489                 vTaskPrioritySet( NULL, genqMUTEX_LOW_PRIORITY );\r
490 \r
491                 /* Just to show we are still running. */\r
492                 ulLoopCounter2++;\r
493 \r
494                 #if configUSE_PREEMPTION == 0\r
495                         taskYIELD();\r
496                 #endif          \r
497         }\r
498 }\r
499 /*-----------------------------------------------------------*/\r
500 \r
501 static void prvMediumPriorityMutexTask( void *pvParameters )\r
502 {\r
503         ( void ) pvParameters;\r
504 \r
505         for( ;; )\r
506         {\r
507                 /* The medium priority task starts by suspending itself.  The low\r
508                 priority task will unsuspend this task when required. */\r
509                 vTaskSuspend( NULL );\r
510 \r
511                 /* When this task unsuspends all it does is increment the guarded\r
512                 variable, this is so the low priority task knows that it has\r
513                 executed. */\r
514                 ulGuardedVariable++;\r
515         }\r
516 }\r
517 /*-----------------------------------------------------------*/\r
518 \r
519 static void prvHighPriorityMutexTask( void *pvParameters )\r
520 {\r
521 xSemaphoreHandle xMutex = ( xSemaphoreHandle ) pvParameters;\r
522 \r
523         ( void ) pvParameters;\r
524 \r
525         for( ;; )\r
526         {\r
527                 /* The high priority task starts by suspending itself.  The low\r
528                 priority task will unsuspend this task when required. */\r
529                 vTaskSuspend( NULL );\r
530 \r
531                 /* When this task unsuspends all it does is attempt to obtain\r
532                 the mutex.  It should find the mutex is not available so a\r
533                 block time is specified. */\r
534                 if( xSemaphoreAltTake( xMutex, portMAX_DELAY ) != pdPASS )\r
535                 {\r
536                         xErrorDetected = pdTRUE;\r
537                 }\r
538 \r
539                 /* When we eventually obtain the mutex we just give it back then\r
540                 return to suspend ready for the next test. */\r
541                 if( xSemaphoreAltGive( xMutex ) != pdPASS )\r
542                 {\r
543                         xErrorDetected = pdTRUE;\r
544                 }               \r
545         }\r
546 }\r
547 /*-----------------------------------------------------------*/\r
548 \r
549 /* This is called to check that all the created tasks are still running. */\r
550 portBASE_TYPE xAreAltGenericQueueTasksStillRunning( void )\r
551 {\r
552 static unsigned portLONG ulLastLoopCounter = 0, ulLastLoopCounter2 = 0;\r
553 \r
554         /* If the demo task is still running then we expect the loopcounters to\r
555         have incremented since this function was last called. */\r
556         if( ulLastLoopCounter == ulLoopCounter )\r
557         {\r
558                 xErrorDetected = pdTRUE;\r
559         }\r
560 \r
561         if( ulLastLoopCounter2 == ulLoopCounter2 )\r
562         {\r
563                 xErrorDetected = pdTRUE;\r
564         }\r
565 \r
566         ulLastLoopCounter = ulLoopCounter;\r
567         ulLastLoopCounter2 = ulLoopCounter2;    \r
568 \r
569         /* Errors detected in the task itself will have latched xErrorDetected\r
570         to true. */\r
571 \r
572         return !xErrorDetected;\r
573 }\r
574 \r
575 \r