]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/Common/Minimal/IntSemTest.c
Update version number to 9.0.0rc2.
[freertos] / FreeRTOS / Demo / Common / Minimal / IntSemTest.c
1 /*\r
2     FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \r
9     FreeRTOS is free software; you can redistribute it and/or modify it under\r
10     the terms of the GNU General Public License (version 2) as published by the\r
11     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
12 \r
13     ***************************************************************************\r
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
16     >>!   obliged to provide the source code for proprietary components     !<<\r
17     >>!   outside of the FreeRTOS kernel.                                   !<<\r
18     ***************************************************************************\r
19 \r
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
23     link: http://www.freertos.org/a00114.html\r
24 \r
25     ***************************************************************************\r
26      *                                                                       *\r
27      *    FreeRTOS provides completely free yet professionally developed,    *\r
28      *    robust, strictly quality controlled, supported, and cross          *\r
29      *    platform software that is more than just the market leader, it     *\r
30      *    is the industry's de facto standard.                               *\r
31      *                                                                       *\r
32      *    Help yourself get started quickly while simultaneously helping     *\r
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
34      *    tutorial book, reference manual, or both:                          *\r
35      *    http://www.FreeRTOS.org/Documentation                              *\r
36      *                                                                       *\r
37     ***************************************************************************\r
38 \r
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
40     the FAQ page "My application does not run, what could be wrong?".  Have you\r
41     defined configASSERT()?\r
42 \r
43     http://www.FreeRTOS.org/support - In return for receiving this top quality\r
44     embedded software for free we request you assist our global community by\r
45     participating in the support forum.\r
46 \r
47     http://www.FreeRTOS.org/training - Investing in training allows your team to\r
48     be as productive as possible as early as possible.  Now you can receive\r
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
50     Ltd, and the world's leading authority on the world's leading RTOS.\r
51 \r
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
55 \r
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
58 \r
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
61     licenses offer ticketed support, indemnification and commercial middleware.\r
62 \r
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
64     engineered and independently SIL3 certified version for use in safety and\r
65     mission critical applications that require provable dependability.\r
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 \r
71 /*\r
72  * Demonstrates and tests mutexes being used from an interrupt.\r
73  */\r
74 \r
75 \r
76 #include <stdlib.h>\r
77 \r
78 /* Scheduler include files. */\r
79 #include "FreeRTOS.h"\r
80 #include "task.h"\r
81 #include "semphr.h"\r
82 \r
83 /* Demo program include files. */\r
84 #include "IntSemTest.h"\r
85 \r
86 /*-----------------------------------------------------------*/\r
87 \r
88 /* The priorities of the test tasks. */\r
89 #define intsemMASTER_PRIORITY           ( tskIDLE_PRIORITY )\r
90 #define intsemSLAVE_PRIORITY            ( tskIDLE_PRIORITY + 1 )\r
91 \r
92 /* The rate at which the tick hook will give the mutex. */\r
93 #define intsemINTERRUPT_MUTEX_GIVE_PERIOD_MS ( 100 )\r
94 \r
95 /* A block time of 0 means 'don't block'. */\r
96 #define intsemNO_BLOCK                          0\r
97 \r
98 /* The maximum count value for the counting semaphore given from an\r
99 interrupt. */\r
100 #define intsemMAX_COUNT                         3\r
101 \r
102 /*-----------------------------------------------------------*/\r
103 \r
104 /*\r
105  * The master is a task that receives a mutex that is given from an interrupt -\r
106  * although generally mutexes should not be used given in interrupts (and\r
107  * definitely never taken in an interrupt) there are some circumstances when it\r
108  * may be desirable.\r
109  *\r
110  * The slave task is just used by the master task to force priority inheritance\r
111  * on a mutex that is shared between the master and the slave - which is a\r
112  * separate mutex to that given by the interrupt.\r
113  */\r
114 static void vInterruptMutexSlaveTask( void *pvParameters );\r
115 static void vInterruptMutexMasterTask( void *pvParameters );\r
116 \r
117 /*\r
118  * A test whereby the master takes the shared and interrupt mutexes in that\r
119  * order, then gives them back in the same order, ensuring the priority\r
120  * inheritance is behaving as expected at each step.\r
121  */\r
122 static void prvTakeAndGiveInTheSameOrder( void );\r
123 \r
124 /*\r
125  * A test whereby the master takes the shared and interrupt mutexes in that\r
126  * order, then gives them back in the opposite order to which they were taken,\r
127  * ensuring the priority inheritance is behaving as expected at each step.\r
128  */\r
129 static void prvTakeAndGiveInTheOppositeOrder( void );\r
130 \r
131 /*\r
132  * A simple task that interacts with an interrupt using a counting semaphore,\r
133  * primarily for code coverage purposes.\r
134  */\r
135 static void vInterruptCountingSemaphoreTask( void *pvParameters );\r
136 \r
137 /*-----------------------------------------------------------*/\r
138 \r
139 /* Flag that will be latched to pdTRUE should any unexpected behaviour be\r
140 detected in any of the tasks. */\r
141 static volatile BaseType_t xErrorDetected = pdFALSE;\r
142 \r
143 /* Counters that are incremented on each cycle of a test.  This is used to\r
144 detect a stalled task - a test that is no longer running. */\r
145 static volatile uint32_t ulMasterLoops = 0, ulCountingSemaphoreLoops = 0;\r
146 \r
147 /* Handles of the test tasks that must be accessed from other test tasks. */\r
148 static TaskHandle_t xSlaveHandle;\r
149 \r
150 /* A mutex which is given from an interrupt - although generally mutexes should\r
151 not be used given in interrupts (and definitely never taken in an interrupt)\r
152 there are some circumstances when it may be desirable. */\r
153 static SemaphoreHandle_t xISRMutex = NULL;\r
154 \r
155 /* A counting semaphore which is given from an interrupt. */\r
156 static SemaphoreHandle_t xISRCountingSemaphore = NULL;\r
157 \r
158 /* A mutex which is shared between the master and slave tasks - the master\r
159 does both sharing of this mutex with the slave and receiving a mutex from the\r
160 interrupt. */\r
161 static SemaphoreHandle_t xMasterSlaveMutex = NULL;\r
162 \r
163 /* Flag that allows the master task to control when the interrupt gives or does\r
164 not give the mutex.  There is no mutual exclusion on this variable, but this is\r
165 only test code and it should be fine in the 32=bit test environment. */\r
166 static BaseType_t xOkToGiveMutex = pdFALSE, xOkToGiveCountingSemaphore = pdFALSE;\r
167 \r
168 /* Used to coordinate timing between tasks and the interrupt. */\r
169 const TickType_t xInterruptGivePeriod = pdMS_TO_TICKS( intsemINTERRUPT_MUTEX_GIVE_PERIOD_MS );\r
170 \r
171 /*-----------------------------------------------------------*/\r
172 \r
173 void vStartInterruptSemaphoreTasks( void )\r
174 {\r
175         /* Create the semaphores that are given from an interrupt. */\r
176         xISRMutex = xSemaphoreCreateMutex();\r
177         configASSERT( xISRMutex );\r
178         xISRCountingSemaphore = xSemaphoreCreateCounting( intsemMAX_COUNT, 0 );\r
179         configASSERT( xISRCountingSemaphore );\r
180 \r
181         /* Create the mutex that is shared between the master and slave tasks (the\r
182         master receives a mutex from an interrupt and shares a mutex with the\r
183         slave. */\r
184         xMasterSlaveMutex = xSemaphoreCreateMutex();\r
185         configASSERT( xMasterSlaveMutex );\r
186 \r
187         /* Create the tasks that share mutexes between then and with interrupts. */\r
188         xTaskCreate( vInterruptMutexSlaveTask, "IntMuS", configMINIMAL_STACK_SIZE, NULL, intsemSLAVE_PRIORITY, &xSlaveHandle );\r
189         xTaskCreate( vInterruptMutexMasterTask, "IntMuM", configMINIMAL_STACK_SIZE, NULL, intsemMASTER_PRIORITY, NULL );\r
190 \r
191         /* Create the task that blocks on the counting semaphore. */\r
192         xTaskCreate( vInterruptCountingSemaphoreTask, "IntCnt", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
193 }\r
194 /*-----------------------------------------------------------*/\r
195 \r
196 static void vInterruptMutexMasterTask( void *pvParameters )\r
197 {\r
198         /* Just to avoid compiler warnings. */\r
199         ( void ) pvParameters;\r
200 \r
201         for( ;; )\r
202         {\r
203                 prvTakeAndGiveInTheSameOrder();\r
204 \r
205                 /* Ensure not to starve out other tests. */\r
206                 ulMasterLoops++;\r
207                 vTaskDelay( intsemINTERRUPT_MUTEX_GIVE_PERIOD_MS );\r
208 \r
209                 prvTakeAndGiveInTheOppositeOrder();\r
210 \r
211                 /* Ensure not to starve out other tests. */\r
212                 ulMasterLoops++;\r
213                 vTaskDelay( intsemINTERRUPT_MUTEX_GIVE_PERIOD_MS );\r
214         }\r
215 }\r
216 /*-----------------------------------------------------------*/\r
217 \r
218 static void prvTakeAndGiveInTheSameOrder( void )\r
219 {\r
220         /* Ensure the slave is suspended, and that this task is running at the\r
221         lower priority as expected as the start conditions. */\r
222         #if( INCLUDE_eTaskGetState == 1 )\r
223         {\r
224                 configASSERT( eTaskGetState( xSlaveHandle ) == eSuspended );\r
225         }\r
226         #endif /* INCLUDE_eTaskGetState */\r
227 \r
228         if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY )\r
229         {\r
230                 xErrorDetected = pdTRUE;\r
231         }\r
232 \r
233         /* Take the semaphore that is shared with the slave. */\r
234         if( xSemaphoreTake( xMasterSlaveMutex, intsemNO_BLOCK ) != pdPASS )\r
235         {\r
236                 xErrorDetected = pdTRUE;\r
237         }\r
238 \r
239         /* This task now has the mutex.  Unsuspend the slave so it too\r
240         attempts to take the mutex. */\r
241         vTaskResume( xSlaveHandle );\r
242 \r
243         /* The slave has the higher priority so should now have executed and\r
244         blocked on the semaphore. */\r
245         #if( INCLUDE_eTaskGetState == 1 )\r
246         {\r
247                 configASSERT( eTaskGetState( xSlaveHandle ) == eBlocked );\r
248         }\r
249         #endif /* INCLUDE_eTaskGetState */\r
250 \r
251         /* This task should now have inherited the priority of the slave\r
252         task. */\r
253         if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY )\r
254         {\r
255                 xErrorDetected = pdTRUE;\r
256         }\r
257 \r
258         /* Now wait a little longer than the time between ISR gives to also\r
259         obtain the ISR mutex. */\r
260         xOkToGiveMutex = pdTRUE;\r
261         if( xSemaphoreTake( xISRMutex, ( xInterruptGivePeriod * 2 ) ) != pdPASS )\r
262         {\r
263                 xErrorDetected = pdTRUE;\r
264         }\r
265         xOkToGiveMutex = pdFALSE;\r
266 \r
267         /* Attempting to take again immediately should fail as the mutex is\r
268         already held. */\r
269         if( xSemaphoreTake( xISRMutex, intsemNO_BLOCK ) != pdFAIL )\r
270         {\r
271                 xErrorDetected = pdTRUE;\r
272         }\r
273 \r
274         /* Should still be at the priority of the slave task. */\r
275         if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY )\r
276         {\r
277                 xErrorDetected = pdTRUE;\r
278         }\r
279 \r
280         /* Give back the ISR semaphore to ensure the priority is not\r
281         disinherited as the shared mutex (which the higher priority task is\r
282         attempting to obtain) is still held. */\r
283         if( xSemaphoreGive( xISRMutex ) != pdPASS )\r
284         {\r
285                 xErrorDetected = pdTRUE;\r
286         }\r
287 \r
288         if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY )\r
289         {\r
290                 xErrorDetected = pdTRUE;\r
291         }\r
292 \r
293         /* Finally give back the shared mutex.  This time the higher priority\r
294         task should run before this task runs again - so this task should have\r
295         disinherited the priority and the higher priority task should be in the\r
296         suspended state again. */\r
297         if( xSemaphoreGive( xMasterSlaveMutex ) != pdPASS )\r
298         {\r
299                 xErrorDetected = pdTRUE;\r
300         }\r
301 \r
302         if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY )\r
303         {\r
304                 xErrorDetected = pdTRUE;\r
305         }\r
306 \r
307         #if( INCLUDE_eTaskGetState == 1 )\r
308         {\r
309                 configASSERT( eTaskGetState( xSlaveHandle ) == eSuspended );\r
310         }\r
311         #endif /* INCLUDE_eTaskGetState */\r
312 \r
313         /* Reset the mutex ready for the next round. */\r
314         xQueueReset( xISRMutex );\r
315 }\r
316 /*-----------------------------------------------------------*/\r
317 \r
318 static void prvTakeAndGiveInTheOppositeOrder( void )\r
319 {\r
320         /* Ensure the slave is suspended, and that this task is running at the\r
321         lower priority as expected as the start conditions. */\r
322         #if( INCLUDE_eTaskGetState == 1 )\r
323         {\r
324                 configASSERT( eTaskGetState( xSlaveHandle ) == eSuspended );\r
325         }\r
326         #endif /* INCLUDE_eTaskGetState */\r
327 \r
328         if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY )\r
329         {\r
330                 xErrorDetected = pdTRUE;\r
331         }\r
332 \r
333         /* Take the semaphore that is shared with the slave. */\r
334         if( xSemaphoreTake( xMasterSlaveMutex, intsemNO_BLOCK ) != pdPASS )\r
335         {\r
336                 xErrorDetected = pdTRUE;\r
337         }\r
338 \r
339         /* This task now has the mutex.  Unsuspend the slave so it too\r
340         attempts to take the mutex. */\r
341         vTaskResume( xSlaveHandle );\r
342 \r
343         /* The slave has the higher priority so should now have executed and\r
344         blocked on the semaphore. */\r
345         #if( INCLUDE_eTaskGetState == 1 )\r
346         {\r
347                 configASSERT( eTaskGetState( xSlaveHandle ) == eBlocked );\r
348         }\r
349         #endif /* INCLUDE_eTaskGetState */\r
350 \r
351         /* This task should now have inherited the priority of the slave\r
352         task. */\r
353         if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY )\r
354         {\r
355                 xErrorDetected = pdTRUE;\r
356         }\r
357 \r
358         /* Now wait a little longer than the time between ISR gives to also\r
359         obtain the ISR mutex. */\r
360         xOkToGiveMutex = pdTRUE;\r
361         if( xSemaphoreTake( xISRMutex, ( xInterruptGivePeriod * 2 ) ) != pdPASS )\r
362         {\r
363                 xErrorDetected = pdTRUE;\r
364         }\r
365         xOkToGiveMutex = pdFALSE;\r
366 \r
367         /* Attempting to take again immediately should fail as the mutex is\r
368         already held. */\r
369         if( xSemaphoreTake( xISRMutex, intsemNO_BLOCK ) != pdFAIL )\r
370         {\r
371                 xErrorDetected = pdTRUE;\r
372         }\r
373 \r
374         /* Should still be at the priority of the slave task. */\r
375         if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY )\r
376         {\r
377                 xErrorDetected = pdTRUE;\r
378         }\r
379 \r
380         /* Give back the shared semaphore to ensure the priority is not disinherited\r
381         as the ISR mutex is still held.  The higher priority slave task should run\r
382         before this task runs again. */\r
383         if( xSemaphoreGive( xMasterSlaveMutex ) != pdPASS )\r
384         {\r
385                 xErrorDetected = pdTRUE;\r
386         }\r
387 \r
388         /* Should still be at the priority of the slave task as this task still\r
389         holds one semaphore (this is a simplification in the priority inheritance\r
390         mechanism. */\r
391         if( uxTaskPriorityGet( NULL ) != intsemSLAVE_PRIORITY )\r
392         {\r
393                 xErrorDetected = pdTRUE;\r
394         }\r
395 \r
396         /* Give back the ISR semaphore, which should result in the priority being\r
397         disinherited as it was the last mutex held. */\r
398         if( xSemaphoreGive( xISRMutex ) != pdPASS )\r
399         {\r
400                 xErrorDetected = pdTRUE;\r
401         }\r
402 \r
403         if( uxTaskPriorityGet( NULL ) != intsemMASTER_PRIORITY )\r
404         {\r
405                 xErrorDetected = pdTRUE;\r
406         }\r
407 \r
408         /* Reset the mutex ready for the next round. */\r
409         xQueueReset( xISRMutex );\r
410 }\r
411 /*-----------------------------------------------------------*/\r
412 \r
413 static void vInterruptMutexSlaveTask( void *pvParameters )\r
414 {\r
415         /* Just to avoid compiler warnings. */\r
416         ( void ) pvParameters;\r
417 \r
418         for( ;; )\r
419         {\r
420                 /* This task starts by suspending itself so when it executes can be\r
421                 controlled by the master task. */\r
422                 vTaskSuspend( NULL );\r
423 \r
424                 /* This task will execute when the master task already holds the mutex.\r
425                 Attempting to take the mutex will place this task in the Blocked\r
426                 state. */\r
427                 if( xSemaphoreTake( xMasterSlaveMutex, portMAX_DELAY ) != pdPASS )\r
428                 {\r
429                         xErrorDetected = pdTRUE;\r
430                 }\r
431 \r
432                 if( xSemaphoreGive( xMasterSlaveMutex ) != pdPASS )\r
433                 {\r
434                         xErrorDetected = pdTRUE;\r
435                 }\r
436         }\r
437 }\r
438 /*-----------------------------------------------------------*/\r
439 \r
440 static void vInterruptCountingSemaphoreTask( void *pvParameters )\r
441 {\r
442 BaseType_t xCount;\r
443 const TickType_t xDelay = pdMS_TO_TICKS( intsemINTERRUPT_MUTEX_GIVE_PERIOD_MS ) * ( intsemMAX_COUNT + 1 );\r
444 \r
445         ( void ) pvParameters;\r
446 \r
447         for( ;; )\r
448         {\r
449                 /* Expect to start with the counting semaphore empty. */\r
450                 if( uxQueueMessagesWaiting( ( QueueHandle_t ) xISRCountingSemaphore ) != 0 )\r
451                 {\r
452                         xErrorDetected = pdTRUE;\r
453                 }\r
454 \r
455                 /* Wait until it is expected that the interrupt will have filled the\r
456                 counting semaphore. */\r
457                 xOkToGiveCountingSemaphore = pdTRUE;\r
458                 vTaskDelay( xDelay );\r
459                 xOkToGiveCountingSemaphore = pdFALSE;\r
460 \r
461                 /* Now it is expected that the counting semaphore is full. */\r
462                 if( uxQueueMessagesWaiting( ( QueueHandle_t ) xISRCountingSemaphore ) != intsemMAX_COUNT )\r
463                 {\r
464                         xErrorDetected = pdTRUE;\r
465                 }\r
466 \r
467                 if( uxQueueSpacesAvailable( ( QueueHandle_t ) xISRCountingSemaphore ) != 0 )\r
468                 {\r
469                         xErrorDetected = pdTRUE;\r
470                 }\r
471 \r
472                 ulCountingSemaphoreLoops++;\r
473 \r
474                 /* Expect to be able to take the counting semaphore intsemMAX_COUNT\r
475                 times.  A block time of 0 is used as the semaphore should already be\r
476                 there. */\r
477                 xCount = 0;\r
478                 while( xSemaphoreTake( xISRCountingSemaphore, 0 ) == pdPASS )\r
479                 {\r
480                         xCount++;\r
481                 }\r
482 \r
483                 if( xCount != intsemMAX_COUNT )\r
484                 {\r
485                         xErrorDetected = pdTRUE;\r
486                 }\r
487 \r
488                 /* Now raise the priority of this task so it runs immediately that the\r
489                 semaphore is given from the interrupt. */\r
490                 vTaskPrioritySet( NULL, configMAX_PRIORITIES - 1 );\r
491 \r
492                 /* Block to wait for the semaphore to be given from the interrupt. */\r
493                 xOkToGiveCountingSemaphore = pdTRUE;\r
494                 xSemaphoreTake( xISRCountingSemaphore, portMAX_DELAY );\r
495                 xSemaphoreTake( xISRCountingSemaphore, portMAX_DELAY );\r
496                 xOkToGiveCountingSemaphore = pdFALSE;\r
497 \r
498                 /* Reset the priority so as not to disturbe other tests too much. */\r
499                 vTaskPrioritySet( NULL, tskIDLE_PRIORITY );\r
500 \r
501                 ulCountingSemaphoreLoops++;\r
502         }\r
503 }\r
504 /*-----------------------------------------------------------*/\r
505 \r
506 void vInterruptSemaphorePeriodicTest( void )\r
507 {\r
508 static TickType_t xLastGiveTime = 0;\r
509 BaseType_t xHigherPriorityTaskWoken = pdFALSE;\r
510 TickType_t xTimeNow;\r
511 \r
512         /* No mutual exclusion on xOkToGiveMutex, but this is only test code (and\r
513         only executed on a 32-bit architecture) so ignore that in this case. */\r
514         xTimeNow = xTaskGetTickCountFromISR();\r
515         if( ( ( TickType_t ) ( xTimeNow - xLastGiveTime ) ) >= pdMS_TO_TICKS( intsemINTERRUPT_MUTEX_GIVE_PERIOD_MS ) )\r
516         {\r
517                 configASSERT( xISRMutex );\r
518                 if( xOkToGiveMutex != pdFALSE )\r
519                 {\r
520                         /* Null is used as the second parameter in this give, and non-NULL\r
521                         in the other gives for code coverage reasons. */\r
522                         xSemaphoreGiveFromISR( xISRMutex, NULL );\r
523 \r
524                         /* Second give attempt should fail. */\r
525                         configASSERT( xSemaphoreGiveFromISR( xISRMutex, &xHigherPriorityTaskWoken ) == pdFAIL );\r
526                 }\r
527 \r
528                 if( xOkToGiveCountingSemaphore != pdFALSE )\r
529                 {\r
530                         xSemaphoreGiveFromISR( xISRCountingSemaphore, &xHigherPriorityTaskWoken );\r
531                 }\r
532                 xLastGiveTime = xTimeNow;\r
533         }\r
534 \r
535         /* Remove compiler warnings about the value being set but not used. */\r
536         ( void ) xHigherPriorityTaskWoken;\r
537 }\r
538 /*-----------------------------------------------------------*/\r
539 \r
540 /* This is called to check that all the created tasks are still running. */\r
541 BaseType_t xAreInterruptSemaphoreTasksStillRunning( void )\r
542 {\r
543 static uint32_t ulLastMasterLoopCounter = 0, ulLastCountingSemaphoreLoops = 0;\r
544 \r
545         /* If the demo tasks are running then it is expected that the loop counters\r
546         will have changed since this function was last called. */\r
547         if( ulLastMasterLoopCounter == ulMasterLoops )\r
548         {\r
549                 xErrorDetected = pdTRUE;\r
550         }\r
551 \r
552         ulLastMasterLoopCounter = ulMasterLoops;\r
553 \r
554         if( ulLastCountingSemaphoreLoops == ulCountingSemaphoreLoops )\r
555         {\r
556                 xErrorDetected = pdTRUE;\r
557         }\r
558 \r
559         ulLastCountingSemaphoreLoops = ulCountingSemaphoreLoops++;\r
560 \r
561         /* Errors detected in the task itself will have latched xErrorDetected\r
562         to true. */\r
563 \r
564         return ( BaseType_t ) !xErrorDetected;\r
565 }\r
566 \r
567 \r