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