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