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