]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/Common/Full/dynamic.c
Update to MIT licensed FreeRTOS V10.0.0 - see https://www.freertos.org/History.txt
[freertos] / FreeRTOS / Demo / Common / Full / dynamic.c
1 /*\r
2  * FreeRTOS Kernel V10.0.0\r
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software. If you wish to use our Amazon\r
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
15  *\r
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22  *\r
23  * http://www.FreeRTOS.org\r
24  * http://aws.amazon.com/freertos\r
25  *\r
26  * 1 tab == 4 spaces!\r
27  */\r
28 \r
29 /**\r
30  * The first test creates three tasks - two counter tasks (one continuous count \r
31  * and one limited count) and one controller.  A "count" variable is shared \r
32  * between all three tasks.  The two counter tasks should never be in a "ready" \r
33  * state at the same time.  The controller task runs at the same priority as \r
34  * the continuous count task, and at a lower priority than the limited count \r
35  * task.\r
36  *\r
37  * One counter task loops indefinitely, incrementing the shared count variable\r
38  * on each iteration.  To ensure it has exclusive access to the variable it\r
39  * raises it's priority above that of the controller task before each \r
40  * increment, lowering it again to it's original priority before starting the\r
41  * next iteration.\r
42  *\r
43  * The other counter task increments the shared count variable on each\r
44  * iteration of it's loop until the count has reached a limit of 0xff - at\r
45  * which point it suspends itself.  It will not start a new loop until the \r
46  * controller task has made it "ready" again by calling vTaskResume ().  \r
47  * This second counter task operates at a higher priority than controller \r
48  * task so does not need to worry about mutual exclusion of the counter \r
49  * variable.\r
50  *\r
51  * The controller task is in two sections.  The first section controls and\r
52  * monitors the continuous count task.  When this section is operational the \r
53  * limited count task is suspended.  Likewise, the second section controls \r
54  * and monitors the limited count task.  When this section is operational the \r
55  * continuous count task is suspended.\r
56  *\r
57  * In the first section the controller task first takes a copy of the shared\r
58  * count variable.  To ensure mutual exclusion on the count variable it\r
59  * suspends the continuous count task, resuming it again when the copy has been\r
60  * taken.  The controller task then sleeps for a fixed period - during which\r
61  * the continuous count task will execute and increment the shared variable.\r
62  * When the controller task wakes it checks that the continuous count task\r
63  * has executed by comparing the copy of the shared variable with its current\r
64  * value.  This time, to ensure mutual exclusion, the scheduler itself is \r
65  * suspended with a call to vTaskSuspendAll ().  This is for demonstration \r
66  * purposes only and is not a recommended technique due to its inefficiency.\r
67  *\r
68  * After a fixed number of iterations the controller task suspends the \r
69  * continuous count task, and moves on to its second section.\r
70  *\r
71  * At the start of the second section the shared variable is cleared to zero.\r
72  * The limited count task is then woken from it's suspension by a call to\r
73  * vTaskResume ().  As this counter task operates at a higher priority than\r
74  * the controller task the controller task should not run again until the\r
75  * shared variable has been counted up to the limited value causing the counter\r
76  * task to suspend itself.  The next line after vTaskResume () is therefore\r
77  * a check on the shared variable to ensure everything is as expected.\r
78  *\r
79  *\r
80  * The second test consists of a couple of very simple tasks that post onto a \r
81  * queue while the scheduler is suspended.  This test was added to test parts\r
82  * of the scheduler not exercised by the first test.\r
83  *\r
84  *\r
85  * The final set of two tasks implements a third test.  This simply raises the\r
86  * priority of a task while the scheduler is suspended.  Again this test was\r
87  * added to exercise parts of the code not covered by the first test.\r
88  *\r
89  * \page Priorities dynamic.c\r
90  * \ingroup DemoFiles\r
91  * <HR>\r
92  */\r
93 \r
94 /*\r
95 Changes from V2.0.0\r
96 \r
97         + Delay periods are now specified using variables and constants of\r
98           TickType_t rather than unsigned long.\r
99         + Added a second, simple test that uses the functions \r
100           vQueueReceiveWhenSuspendedTask() and vQueueSendWhenSuspendedTask().\r
101 \r
102 Changes from V3.1.1\r
103 \r
104         + Added a third simple test that uses the vTaskPrioritySet() function\r
105           while the scheduler is suspended.\r
106         + Modified the controller task slightly to test the calling of \r
107           vTaskResumeAll() while the scheduler is suspended.\r
108 */\r
109 \r
110 #include <stdlib.h>\r
111 \r
112 /* Scheduler include files. */\r
113 #include "FreeRTOS.h"\r
114 #include "task.h"\r
115 #include "semphr.h"\r
116 \r
117 /* Demo app include files. */\r
118 #include "dynamic.h"\r
119 #include "print.h"\r
120 \r
121 /* Function that implements the "limited count" task as described above. */\r
122 static void vLimitedIncrementTask( void * pvParameters );\r
123 \r
124 /* Function that implements the "continuous count" task as described above. */\r
125 static void vContinuousIncrementTask( void * pvParameters );\r
126 \r
127 /* Function that implements the controller task as described above. */\r
128 static void vCounterControlTask( void * pvParameters );\r
129 \r
130 /* The simple test functions that check sending and receiving while the\r
131 scheduler is suspended. */\r
132 static void vQueueReceiveWhenSuspendedTask( void *pvParameters );\r
133 static void vQueueSendWhenSuspendedTask( void *pvParameters );\r
134 \r
135 /* The simple test functions that check raising and lowering of task priorities\r
136 while the scheduler is suspended. */\r
137 static void prvChangePriorityWhenSuspendedTask( void *pvParameters );\r
138 static void prvChangePriorityHelperTask( void *pvParameters );\r
139 \r
140 \r
141 /* Demo task specific constants. */\r
142 #define priSTACK_SIZE                           ( ( unsigned short ) configMINIMAL_STACK_SIZE )\r
143 #define priSLEEP_TIME                           ( ( TickType_t ) 50 )\r
144 #define priLOOPS                                        ( 5 )\r
145 #define priMAX_COUNT                            ( ( unsigned long ) 0xff )\r
146 #define priNO_BLOCK                                     ( ( TickType_t ) 0 )\r
147 #define priSUSPENDED_QUEUE_LENGTH       ( 1 )\r
148 \r
149 /*-----------------------------------------------------------*/\r
150 \r
151 /* Handles to the two counter tasks.  These could be passed in as parameters\r
152 to the controller task to prevent them having to be file scope. */\r
153 static TaskHandle_t xContinuousIncrementHandle, xLimitedIncrementHandle, xChangePriorityWhenSuspendedHandle;\r
154 \r
155 /* The shared counter variable.  This is passed in as a parameter to the two \r
156 counter variables for demonstration purposes. */\r
157 static unsigned long ulCounter;\r
158 \r
159 /* Variable used in a similar way by the test that checks the raising and\r
160 lowering of task priorities while the scheduler is suspended. */\r
161 static unsigned long ulPrioritySetCounter;\r
162 \r
163 /* Variables used to check that the tasks are still operating without error.\r
164 Each complete iteration of the controller task increments this variable\r
165 provided no errors have been found.  The variable maintaining the same value\r
166 is therefore indication of an error. */\r
167 static unsigned short usCheckVariable = ( unsigned short ) 0;\r
168 static portBASE_TYPE xSuspendedQueueSendError = pdFALSE;\r
169 static portBASE_TYPE xSuspendedQueueReceiveError = pdFALSE;\r
170 static portBASE_TYPE xPriorityRaiseWhenSuspendedError = pdFALSE;\r
171 \r
172 /* Queue used by the second test. */\r
173 QueueHandle_t xSuspendedTestQueue;\r
174 \r
175 /*-----------------------------------------------------------*/\r
176 /*\r
177  * Start the seven tasks as described at the top of the file.\r
178  * Note that the limited count task is given a higher priority.\r
179  */\r
180 void vStartDynamicPriorityTasks( void )\r
181 {\r
182         xSuspendedTestQueue = xQueueCreate( priSUSPENDED_QUEUE_LENGTH, sizeof( unsigned long ) );\r
183         xTaskCreate( vContinuousIncrementTask, "CONT_INC", priSTACK_SIZE, ( void * ) &ulCounter, tskIDLE_PRIORITY, &xContinuousIncrementHandle );\r
184         xTaskCreate( vLimitedIncrementTask, "LIM_INC", priSTACK_SIZE, ( void * ) &ulCounter, tskIDLE_PRIORITY + 1, &xLimitedIncrementHandle );\r
185         xTaskCreate( vCounterControlTask, "C_CTRL", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
186         xTaskCreate( vQueueSendWhenSuspendedTask, "SUSP_SEND", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
187         xTaskCreate( vQueueReceiveWhenSuspendedTask, "SUSP_RECV", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
188         xTaskCreate( prvChangePriorityWhenSuspendedTask, "1st_P_CHANGE", priSTACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );\r
189         xTaskCreate( prvChangePriorityHelperTask, "2nd_P_CHANGE", priSTACK_SIZE, NULL, tskIDLE_PRIORITY, &xChangePriorityWhenSuspendedHandle );\r
190 }\r
191 /*-----------------------------------------------------------*/\r
192 \r
193 /*\r
194  * Just loops around incrementing the shared variable until the limit has been\r
195  * reached.  Once the limit has been reached it suspends itself. \r
196  */\r
197 static void vLimitedIncrementTask( void * pvParameters )\r
198 {\r
199 unsigned long *pulCounter;\r
200 \r
201         /* Take a pointer to the shared variable from the parameters passed into\r
202         the task. */\r
203         pulCounter = ( unsigned long * ) pvParameters;\r
204 \r
205         /* This will run before the control task, so the first thing it does is\r
206         suspend - the control task will resume it when ready. */\r
207         vTaskSuspend( NULL );\r
208 \r
209         for( ;; )\r
210         {\r
211                 /* Just count up to a value then suspend. */\r
212                 ( *pulCounter )++;      \r
213                 \r
214                 if( *pulCounter >= priMAX_COUNT )\r
215                 {\r
216                         vTaskSuspend( NULL );\r
217                 }       \r
218         }\r
219 }\r
220 /*-----------------------------------------------------------*/\r
221 \r
222 /*\r
223  * Just keep counting the shared variable up.  The control task will suspend\r
224  * this task when it wants.\r
225  */\r
226 static void vContinuousIncrementTask( void * pvParameters )\r
227 {\r
228 unsigned long *pulCounter;\r
229 unsigned portBASE_TYPE uxOurPriority;\r
230 \r
231         /* Take a pointer to the shared variable from the parameters passed into\r
232         the task. */\r
233         pulCounter = ( unsigned long * ) pvParameters;\r
234 \r
235         /* Query our priority so we can raise it when exclusive access to the \r
236         shared variable is required. */\r
237         uxOurPriority = uxTaskPriorityGet( NULL );\r
238 \r
239         for( ;; )\r
240         {\r
241                 /* Raise our priority above the controller task to ensure a context\r
242                 switch does not occur while we are accessing this variable. */\r
243                 vTaskPrioritySet( NULL, uxOurPriority + 1 );\r
244                         ( *pulCounter )++;              \r
245                 vTaskPrioritySet( NULL, uxOurPriority );\r
246 \r
247                 #if configUSE_PREEMPTION == 0\r
248                         taskYIELD();\r
249                 #endif\r
250         }\r
251 }\r
252 /*-----------------------------------------------------------*/\r
253 \r
254 /*\r
255  * Controller task as described above.\r
256  */\r
257 static void vCounterControlTask( void * pvParameters )\r
258 {\r
259 unsigned long ulLastCounter;\r
260 short sLoops;\r
261 short sError = pdFALSE;\r
262 const char * const pcTaskStartMsg = "Priority manipulation tasks started.\r\n";\r
263 const char * const pcTaskFailMsg = "Priority manipulation Task Failed\r\n";\r
264 \r
265         /* Just to stop warning messages. */\r
266         ( void ) pvParameters;\r
267 \r
268         /* Queue a message for printing to say the task has started. */\r
269         vPrintDisplayMessage( &pcTaskStartMsg );\r
270 \r
271         for( ;; )\r
272         {\r
273                 /* Start with the counter at zero. */\r
274                 ulCounter = ( unsigned long ) 0;\r
275 \r
276                 /* First section : */\r
277 \r
278                 /* Check the continuous count task is running. */\r
279                 for( sLoops = 0; sLoops < priLOOPS; sLoops++ )\r
280                 {\r
281                         /* Suspend the continuous count task so we can take a mirror of the\r
282                         shared variable without risk of corruption. */\r
283                         vTaskSuspend( xContinuousIncrementHandle );\r
284                                 ulLastCounter = ulCounter;\r
285                         vTaskResume( xContinuousIncrementHandle );\r
286                         \r
287                         /* Now delay to ensure the other task has processor time. */\r
288                         vTaskDelay( priSLEEP_TIME );\r
289 \r
290                         /* Check the shared variable again.  This time to ensure mutual \r
291                         exclusion the whole scheduler will be locked.  This is just for\r
292                         demo purposes! */\r
293                         vTaskSuspendAll();\r
294                         {\r
295                                 if( ulLastCounter == ulCounter )\r
296                                 {\r
297                                         /* The shared variable has not changed.  There is a problem\r
298                                         with the continuous count task so flag an error. */\r
299                                         sError = pdTRUE;\r
300                                         xTaskResumeAll();\r
301                                                 vPrintDisplayMessage( &pcTaskFailMsg );\r
302                                         vTaskSuspendAll();\r
303                                 }\r
304                         }\r
305                         xTaskResumeAll();\r
306                 }\r
307 \r
308 \r
309                 /* Second section: */\r
310 \r
311                 /* Suspend the continuous counter task so it stops accessing the shared variable. */\r
312                 vTaskSuspend( xContinuousIncrementHandle );\r
313 \r
314                 /* Reset the variable. */\r
315                 ulCounter = ( unsigned long ) 0;\r
316 \r
317                 /* Resume the limited count task which has a higher priority than us.\r
318                 We should therefore not return from this call until the limited count\r
319                 task has suspended itself with a known value in the counter variable. \r
320                 The scheduler suspension is not necessary but is included for test\r
321                 purposes. */\r
322                 vTaskSuspendAll();\r
323                         vTaskResume( xLimitedIncrementHandle );\r
324                 xTaskResumeAll();\r
325 \r
326                 /* Does the counter variable have the expected value? */\r
327                 if( ulCounter != priMAX_COUNT )\r
328                 {\r
329                         sError = pdTRUE;\r
330                         vPrintDisplayMessage( &pcTaskFailMsg );\r
331                 }\r
332 \r
333                 if( sError == pdFALSE )\r
334                 {\r
335                         /* If no errors have occurred then increment the check variable. */\r
336                         portENTER_CRITICAL();\r
337                                 usCheckVariable++;\r
338                         portEXIT_CRITICAL();\r
339                 }\r
340 \r
341                 #if configUSE_PREEMPTION == 0\r
342                         taskYIELD();\r
343                 #endif\r
344 \r
345                 /* Resume the continuous count task and do it all again. */\r
346                 vTaskResume( xContinuousIncrementHandle );\r
347         }\r
348 }\r
349 /*-----------------------------------------------------------*/\r
350 \r
351 static void vQueueSendWhenSuspendedTask( void *pvParameters )\r
352 {\r
353 static unsigned long ulValueToSend = ( unsigned long ) 0;\r
354 const char * const pcTaskStartMsg = "Queue send while suspended task started.\r\n";\r
355 const char * const pcTaskFailMsg = "Queue send while suspended failed.\r\n";\r
356 \r
357         /* Just to stop warning messages. */\r
358         ( void ) pvParameters;\r
359 \r
360         /* Queue a message for printing to say the task has started. */\r
361         vPrintDisplayMessage( &pcTaskStartMsg );\r
362 \r
363         for( ;; )\r
364         {\r
365                 vTaskSuspendAll();\r
366                 {\r
367                         /* We must not block while the scheduler is suspended! */\r
368                         if( xQueueSend( xSuspendedTestQueue, ( void * ) &ulValueToSend, priNO_BLOCK ) != pdTRUE )\r
369                         {\r
370                                 if( xSuspendedQueueSendError == pdFALSE )\r
371                                 {\r
372                                         xTaskResumeAll();\r
373                                                 vPrintDisplayMessage( &pcTaskFailMsg );\r
374                                         vTaskSuspendAll();\r
375                                 }\r
376 \r
377                                 xSuspendedQueueSendError = pdTRUE;\r
378                         }\r
379                 }\r
380                 xTaskResumeAll();\r
381 \r
382                 vTaskDelay( priSLEEP_TIME );\r
383 \r
384                 ++ulValueToSend;\r
385         }\r
386 }\r
387 /*-----------------------------------------------------------*/\r
388 \r
389 static void vQueueReceiveWhenSuspendedTask( void *pvParameters )\r
390 {\r
391 static unsigned long ulExpectedValue = ( unsigned long ) 0, ulReceivedValue;\r
392 const char * const pcTaskStartMsg = "Queue receive while suspended task started.\r\n";\r
393 const char * const pcTaskFailMsg = "Queue receive while suspended failed.\r\n";\r
394 portBASE_TYPE xGotValue;\r
395 \r
396         /* Just to stop warning messages. */\r
397         ( void ) pvParameters;\r
398 \r
399         /* Queue a message for printing to say the task has started. */\r
400         vPrintDisplayMessage( &pcTaskStartMsg );\r
401 \r
402         for( ;; )\r
403         {\r
404                 do\r
405                 {\r
406                         /* Suspending the scheduler here is fairly pointless and \r
407                         undesirable for a normal application.  It is done here purely\r
408                         to test the scheduler.  The inner xTaskResumeAll() should\r
409                         never return pdTRUE as the scheduler is still locked by the\r
410                         outer call. */\r
411                         vTaskSuspendAll();\r
412                         {\r
413                                 vTaskSuspendAll();\r
414                                 {\r
415                                         xGotValue = xQueueReceive( xSuspendedTestQueue, ( void * ) &ulReceivedValue, priNO_BLOCK );\r
416                                 }\r
417                                 if( xTaskResumeAll() )\r
418                                 {\r
419                                         xSuspendedQueueReceiveError = pdTRUE;\r
420                                 }\r
421                         }\r
422                         xTaskResumeAll();\r
423 \r
424                         #if configUSE_PREEMPTION == 0\r
425                                 taskYIELD();\r
426                         #endif\r
427 \r
428                 } while( xGotValue == pdFALSE );\r
429 \r
430                 if( ulReceivedValue != ulExpectedValue )\r
431                 {\r
432                         if( xSuspendedQueueReceiveError == pdFALSE )\r
433                         {\r
434                                 vPrintDisplayMessage( &pcTaskFailMsg );\r
435                         }\r
436                         xSuspendedQueueReceiveError = pdTRUE;\r
437                 }\r
438 \r
439                 ++ulExpectedValue;\r
440         }\r
441 }\r
442 /*-----------------------------------------------------------*/\r
443 \r
444 static void prvChangePriorityWhenSuspendedTask( void *pvParameters )\r
445 {\r
446 const char * const pcTaskStartMsg = "Priority change when suspended task started.\r\n";\r
447 const char * const pcTaskFailMsg = "Priority change when suspended task failed.\r\n";\r
448 \r
449         /* Just to stop warning messages. */\r
450         ( void ) pvParameters;\r
451 \r
452         /* Queue a message for printing to say the task has started. */\r
453         vPrintDisplayMessage( &pcTaskStartMsg );        \r
454         \r
455         for( ;; )\r
456         {\r
457                 /* Start with the counter at 0 so we know what the counter should be\r
458                 when we check it next. */\r
459                 ulPrioritySetCounter = ( unsigned long ) 0;\r
460 \r
461                 /* Resume the helper task.  At this time it has a priority lower than\r
462                 ours so no context switch should occur. */\r
463                 vTaskResume( xChangePriorityWhenSuspendedHandle );\r
464 \r
465                 /* Check to ensure the task just resumed has not executed. */\r
466                 portENTER_CRITICAL();\r
467                 {\r
468                         if( ulPrioritySetCounter != ( unsigned long ) 0 )\r
469                         {\r
470                                 xPriorityRaiseWhenSuspendedError = pdTRUE;\r
471                                 vPrintDisplayMessage( &pcTaskFailMsg );\r
472                         }\r
473                 }\r
474                 portEXIT_CRITICAL();\r
475 \r
476                 /* Now try raising the priority while the scheduler is suspended. */\r
477                 vTaskSuspendAll();\r
478                 {\r
479                         vTaskPrioritySet( xChangePriorityWhenSuspendedHandle, ( configMAX_PRIORITIES - 1 ) );\r
480 \r
481                         /* Again, even though the helper task has a priority greater than \r
482                         ours, it should not have executed yet because the scheduler is\r
483                         suspended. */\r
484                         portENTER_CRITICAL();\r
485                         {\r
486                                 if( ulPrioritySetCounter != ( unsigned long ) 0 )\r
487                                 {\r
488                                         xPriorityRaiseWhenSuspendedError = pdTRUE;\r
489                                         vPrintDisplayMessage( &pcTaskFailMsg );\r
490                                 }\r
491                         }\r
492                         portEXIT_CRITICAL();\r
493                 }\r
494                 xTaskResumeAll();\r
495                 \r
496                 /* Now the scheduler has been resumed the helper task should \r
497                 immediately preempt us and execute.  When it executes it will increment\r
498                 the ulPrioritySetCounter exactly once before suspending itself.\r
499 \r
500                 We should now always find the counter set to 1. */\r
501                 portENTER_CRITICAL();\r
502                 {\r
503                         if( ulPrioritySetCounter != ( unsigned long ) 1 )\r
504                         {\r
505                                 xPriorityRaiseWhenSuspendedError = pdTRUE;\r
506                                 vPrintDisplayMessage( &pcTaskFailMsg );\r
507                         }\r
508                 }\r
509                 portEXIT_CRITICAL();\r
510 \r
511                 /* Delay until we try this again. */            \r
512                 vTaskDelay( priSLEEP_TIME * 2 );\r
513                 \r
514                 /* Set the priority of the helper task back ready for the next \r
515                 execution of this task. */\r
516                 vTaskSuspendAll();\r
517                         vTaskPrioritySet( xChangePriorityWhenSuspendedHandle, tskIDLE_PRIORITY );                               \r
518                 xTaskResumeAll();                               \r
519         }\r
520 }\r
521 /*-----------------------------------------------------------*/\r
522 \r
523 static void prvChangePriorityHelperTask( void *pvParameters )\r
524 {\r
525         /* Just to stop warning messages. */\r
526         ( void ) pvParameters;\r
527 \r
528         for( ;; )\r
529         {\r
530                 /* This is the helper task for prvChangePriorityWhenSuspendedTask().\r
531                 It has it's priority raised and lowered.  When it runs it simply \r
532                 increments the counter then suspends itself again.  This allows\r
533                 prvChangePriorityWhenSuspendedTask() to know how many times it has\r
534                 executed. */\r
535                 ulPrioritySetCounter++;\r
536                 vTaskSuspend( NULL );\r
537         }\r
538 }\r
539 /*-----------------------------------------------------------*/\r
540 \r
541 /* Called to check that all the created tasks are still running without error. */\r
542 portBASE_TYPE xAreDynamicPriorityTasksStillRunning( void )\r
543 {\r
544 /* Keep a history of the check variables so we know if it has been incremented \r
545 since the last call. */\r
546 static unsigned short usLastTaskCheck = ( unsigned short ) 0;\r
547 portBASE_TYPE xReturn = pdTRUE;\r
548 \r
549         /* Check the tasks are still running by ensuring the check variable\r
550         is still incrementing. */\r
551 \r
552         if( usCheckVariable == usLastTaskCheck )\r
553         {\r
554                 /* The check has not incremented so an error exists. */\r
555                 xReturn = pdFALSE;\r
556         }\r
557 \r
558         if( xSuspendedQueueSendError == pdTRUE )\r
559         {\r
560                 xReturn = pdFALSE;\r
561         }\r
562 \r
563         if( xSuspendedQueueReceiveError == pdTRUE )\r
564         {\r
565                 xReturn = pdFALSE;\r
566         }\r
567 \r
568         if( xPriorityRaiseWhenSuspendedError == pdTRUE )\r
569         {\r
570                 xReturn = pdFALSE;\r
571         }\r
572 \r
573         usLastTaskCheck = usCheckVariable;\r
574         return xReturn;\r
575 }\r
576 \r
577 \r
578 \r
579 \r