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