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