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