]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c
Add the option to specify a stack size in the standard demo MessageBuffer tests.
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo / src / Full_Demo / main_full.c
1 /*\r
2  * FreeRTOS Kernel V10.0.1\r
3  * Copyright (C) 2017 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  * NOTE 1:  This project provides three demo applications.  A simple blinky\r
30  * style project, a more comprehensive test and demo application, and an\r
31  * lwIP example.  The mainSELECTED_APPLICATION setting in main.c is used to\r
32  * select between the three.  See the notes on using mainSELECTED_APPLICATION\r
33  * in main.c.  This file implements the comprehensive version.\r
34  *\r
35  * NOTE 2:  This file only contains the source code that is specific to the\r
36  * full demo.  Generic functions, such FreeRTOS hook functions, and functions\r
37  * required to configure the hardware, are defined in main.c.\r
38  *\r
39  * NOTE 3:  The full demo includes a test that checks the floating point context\r
40  * is maintained correctly across task switches.  The standard GCC libraries can\r
41  * use floating point registers and made this test fail (unless the tasks that\r
42  * use the library are given a floating point context as described on the\r
43  * documentation page for this demo).  printf-stdarg.c is included in this\r
44  * project to prevent the standard GCC libraries being linked into the project.\r
45  *\r
46  ******************************************************************************\r
47  *\r
48  * main_full() creates all the demo application tasks and software timers, then\r
49  * starts the scheduler.  The web documentation provides more details of the\r
50  * standard demo application tasks, which provide no particular functionality,\r
51  * but do provide a good example of how to use the FreeRTOS API.\r
52  *\r
53  * In addition to the standard demo tasks, the following tasks and tests are\r
54  * defined and/or created within this file:\r
55  *\r
56  * FreeRTOS+CLI command console.  The command console is access through the\r
57  * UART to USB connector on the ZC702 Zynq development board (marked J2).  For\r
58  * reasons of robustness testing the UART driver is deliberately written to be\r
59  * inefficient and should not be used as a template for a production driver.\r
60  * Type "help" to see a list of registered commands.  The FreeRTOS+CLI license\r
61  * is different to the FreeRTOS license, see http://www.FreeRTOS.org/cli for\r
62  * license and usage details.  The default baud rate is 115200.\r
63  *\r
64  * "Reg test" tasks - These fill both the core and floating point registers with\r
65  * known values, then check that each register maintains its expected value for\r
66  * the lifetime of the task.  Each task uses a different set of values.  The reg\r
67  * test tasks execute with a very low priority, so get preempted very\r
68  * frequently.  A register containing an unexpected value is indicative of an\r
69  * error in the context switching mechanism.\r
70  *\r
71  * "Check" task - The check task period is initially set to three seconds.  The\r
72  * task checks that all the standard demo tasks, and the register check tasks,\r
73  * are not only still executing, but are executing without reporting any errors.\r
74  * If the check task discovers that a task has either stalled, or reported an\r
75  * error, then it changes its own execution period from the initial three\r
76  * seconds, to just 200ms.  The check task also toggles an LED each time it is\r
77  * called.  This provides a visual indication of the system status:  If the LED\r
78  * toggles every three seconds, then no issues have been discovered.  If the LED\r
79  * toggles every 200ms, then an issue has been discovered with at least one\r
80  * task.\r
81  */\r
82 \r
83 /* Standard includes. */\r
84 #include <stdio.h>\r
85 \r
86 /* Kernel includes. */\r
87 #include "FreeRTOS.h"\r
88 #include "task.h"\r
89 #include "timers.h"\r
90 #include "semphr.h"\r
91 \r
92 /* Standard demo application includes. */\r
93 #include "flop.h"\r
94 #include "semtest.h"\r
95 #include "dynamic.h"\r
96 #include "BlockQ.h"\r
97 #include "blocktim.h"\r
98 #include "countsem.h"\r
99 #include "GenQTest.h"\r
100 #include "recmutex.h"\r
101 #include "death.h"\r
102 #include "partest.h"\r
103 #include "comtest2.h"\r
104 #include "serial.h"\r
105 #include "TimerDemo.h"\r
106 #include "QueueOverwrite.h"\r
107 #include "IntQueue.h"\r
108 #include "EventGroupsDemo.h"\r
109 #include "TaskNotify.h"\r
110 #include "IntSemTest.h"\r
111 #include "StaticAllocation.h"\r
112 #include "AbortDelay.h"\r
113 #include "MessageBufferDemo.h"\r
114 #include "StreamBufferDemo.h"\r
115 #include "StreamBufferInterrupt.h"\r
116 #include "MessageBufferAMP.h"\r
117 \r
118 \r
119 /* Priorities for the demo application tasks. */\r
120 #define mainSEM_TEST_PRIORITY                           ( tskIDLE_PRIORITY + 1UL )\r
121 #define mainBLOCK_Q_PRIORITY                            ( tskIDLE_PRIORITY + 2UL )\r
122 #define mainCREATOR_TASK_PRIORITY                       ( tskIDLE_PRIORITY + 3UL )\r
123 #define mainFLOP_TASK_PRIORITY                          ( tskIDLE_PRIORITY )\r
124 #define mainUART_COMMAND_CONSOLE_STACK_SIZE     ( configMINIMAL_STACK_SIZE * 3UL )\r
125 #define mainCOM_TEST_TASK_PRIORITY                      ( tskIDLE_PRIORITY + 2 )\r
126 #define mainCHECK_TASK_PRIORITY                         ( configMAX_PRIORITIES - 1 )\r
127 #define mainQUEUE_OVERWRITE_PRIORITY            ( tskIDLE_PRIORITY )\r
128 \r
129 /* The priority used by the UART command console task. */\r
130 #define mainUART_COMMAND_CONSOLE_TASK_PRIORITY  ( configMAX_PRIORITIES - 2 )\r
131 \r
132 /* The LED used by the check timer. */\r
133 #define mainCHECK_LED                                           ( 0 )\r
134 \r
135 /* A block time of zero simply means "don't block". */\r
136 #define mainDONT_BLOCK                                          ( 0UL )\r
137 \r
138 /* The period after which the check timer will expire, in ms, provided no errors\r
139 have been reported by any of the standard demo tasks.  ms are converted to the\r
140 equivalent in ticks using the portTICK_PERIOD_MS constant. */\r
141 #define mainNO_ERROR_CHECK_TASK_PERIOD          ( 3000UL / portTICK_PERIOD_MS )\r
142 \r
143 /* The period at which the check timer will expire, in ms, if an error has been\r
144 reported in one of the standard demo tasks.  ms are converted to the equivalent\r
145 in ticks using the portTICK_PERIOD_MS constant. */\r
146 #define mainERROR_CHECK_TASK_PERIOD             ( 200UL / portTICK_PERIOD_MS )\r
147 \r
148 /* Parameters that are passed into the register check tasks solely for the\r
149 purpose of ensuring parameters are passed into tasks correctly. */\r
150 #define mainREG_TEST_TASK_1_PARAMETER           ( ( void * ) 0x12345678 )\r
151 #define mainREG_TEST_TASK_2_PARAMETER           ( ( void * ) 0x87654321 )\r
152 \r
153 /* The base period used by the timer test tasks. */\r
154 #define mainTIMER_TEST_PERIOD                           ( 50 )\r
155 \r
156 /* Base stack size of tasks created in the message buffer demos. */\r
157 #define mainMESSAGE_BUFFER_STACK_SIZE           ( configMINIMAL_STACK_SIZE * 2 )\r
158 \r
159 /*-----------------------------------------------------------*/\r
160 \r
161 \r
162 /*\r
163  * The check task, as described at the top of this file.\r
164  */\r
165 static void prvCheckTask( void *pvParameters );\r
166 \r
167 /*\r
168  * Register check tasks, and the tasks used to write over and check the contents\r
169  * of the FPU registers, as described at the top of this file.  The nature of\r
170  * these files necessitates that they are written in an assembly file, but the\r
171  * entry points are kept in the C file for the convenience of checking the task\r
172  * parameter.\r
173  */\r
174 static void prvRegTestTaskEntry1( void *pvParameters );\r
175 extern void vRegTest1Implementation( void );\r
176 static void prvRegTestTaskEntry2( void *pvParameters );\r
177 extern void vRegTest2Implementation( void );\r
178 \r
179 /*\r
180  * Register commands that can be used with FreeRTOS+CLI.  The commands are\r
181  * defined in CLI-Commands.c and File-Related-CLI-Command.c respectively.\r
182  */\r
183 extern void vRegisterSampleCLICommands( void );\r
184 \r
185 /*\r
186  * The task that manages the FreeRTOS+CLI input and output.\r
187  */\r
188 extern void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority );\r
189 \r
190 /*\r
191  * A high priority task that does nothing other than execute at a pseudo random\r
192  * time to ensure the other test tasks don't just execute in a repeating\r
193  * pattern.\r
194  */\r
195 static void prvPseudoRandomiser( void *pvParameters );\r
196 \r
197 /*-----------------------------------------------------------*/\r
198 \r
199 /* The following two variables are used to communicate the status of the\r
200 register check tasks to the check task.  If the variables keep incrementing,\r
201 then the register check tasks have not discovered any errors.  If a variable\r
202 stops incrementing, then an error has been found. */\r
203 volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
204 \r
205 /* String for display in the web server.  It is set to an error message if the\r
206 check task detects an error.  */\r
207 char *pcStatusMessage = "All tasks running without error";\r
208 /*-----------------------------------------------------------*/\r
209 \r
210 void main_full( void )\r
211 {\r
212         /* Start all the other standard demo/test tasks.  They have no particular\r
213         functionality, but do demonstrate how to use the FreeRTOS API and test the\r
214         kernel port. */\r
215         vStartInterruptQueueTasks();\r
216         vStartDynamicPriorityTasks();\r
217         vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );\r
218         vCreateBlockTimeTasks();\r
219         vStartCountingSemaphoreTasks();\r
220         vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
221         vStartRecursiveMutexTasks();\r
222         vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
223         vStartMathTasks( mainFLOP_TASK_PRIORITY );\r
224         vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
225         vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
226         vStartEventGroupTasks();\r
227         vStartTaskNotifyTask();\r
228         vStartInterruptSemaphoreTasks();\r
229         vStartStaticallyAllocatedTasks();\r
230         vCreateAbortDelayTasks();\r
231         vStartMessageBufferTasks( mainMESSAGE_BUFFER_STACK_SIZE );\r
232         vStartStreamBufferTasks();\r
233         vStartStreamBufferInterruptDemo();\r
234         vStartMessageBufferAMPTasks( mainMESSAGE_BUFFER_STACK_SIZE );\r
235 \r
236         /* Start the tasks that implements the command console on the UART, as\r
237         described above. */\r
238         vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );\r
239 \r
240         /* Register the standard CLI commands. */\r
241         vRegisterSampleCLICommands();\r
242 \r
243         /* Create the register check tasks, as described at the top of this     file */\r
244         xTaskCreate( prvRegTestTaskEntry1, "Reg1", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
245         xTaskCreate( prvRegTestTaskEntry2, "Reg2", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
246 \r
247         /* Create the task that just adds a little random behaviour. */\r
248         xTaskCreate( prvPseudoRandomiser, "Rnd", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );\r
249 \r
250         /* Create the task that performs the 'check' functionality,     as described at\r
251         the top of this file. */\r
252         xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
253 \r
254         /* The set of tasks created by the following function call have to be\r
255         created last as they keep account of the number of tasks they expect to see\r
256         running. */\r
257         vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );\r
258 \r
259         /* Start the scheduler. */\r
260         vTaskStartScheduler();\r
261 \r
262         /* If all is well, the scheduler will now be running, and the following\r
263         line will never be reached.  If the following line does execute, then\r
264         there was either insufficient FreeRTOS heap memory available for the idle\r
265         and/or timer tasks to be created, or vTaskStartScheduler() was called from\r
266         User mode.  See the memory management section on the FreeRTOS web site for\r
267         more details on the FreeRTOS heap http://www.freertos.org/a00111.html.  The\r
268         mode from which main() is called is set in the C start up code and must be\r
269         a privileged mode (not user mode). */\r
270         for( ;; );\r
271 }\r
272 /*-----------------------------------------------------------*/\r
273 \r
274 static void prvCheckTask( void *pvParameters )\r
275 {\r
276 TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;\r
277 TickType_t xLastExecutionTime;\r
278 static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
279 unsigned long ulErrorFound = pdFALSE;\r
280 \r
281         /* Just to stop compiler warnings. */\r
282         ( void ) pvParameters;\r
283 \r
284         /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()\r
285         works correctly. */\r
286         xLastExecutionTime = xTaskGetTickCount();\r
287 \r
288         /* Cycle for ever, delaying then checking all the other tasks are still\r
289         operating without error.  The onboard LED is toggled on each iteration.\r
290         If an error is detected then the delay period is decreased from\r
291         mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD.  This has the\r
292         effect of increasing the rate at which the onboard LED toggles, and in so\r
293         doing gives visual feedback of the system status. */\r
294         for( ;; )\r
295         {\r
296                 /* Delay until it is time to execute again. */\r
297                 vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );\r
298 \r
299                 /* Check all the demo tasks (other than the flash tasks) to ensure\r
300                 that they are all still running, and that none have detected an error. */\r
301                 if( xAreIntQueueTasksStillRunning() != pdTRUE )\r
302                 {\r
303                         ulErrorFound |= 1UL << 0UL;\r
304                 }\r
305 \r
306                 if( xAreMathsTaskStillRunning() != pdTRUE )\r
307                 {\r
308                         ulErrorFound |= 1UL << 1UL;\r
309                 }\r
310 \r
311                 if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
312                 {\r
313                         ulErrorFound |= 1UL << 2UL;\r
314                 }\r
315 \r
316                 if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
317                 {\r
318                         ulErrorFound |= 1UL << 3UL;\r
319                 }\r
320 \r
321                 if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
322                 {\r
323                         ulErrorFound |= 1UL << 4UL;\r
324                 }\r
325 \r
326                 if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
327                 {\r
328                         ulErrorFound |= 1UL << 5UL;\r
329                 }\r
330 \r
331                 if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
332                 {\r
333                         ulErrorFound |= 1UL << 6UL;\r
334                 }\r
335 \r
336                 if( xIsCreateTaskStillRunning() != pdTRUE )\r
337                 {\r
338                         ulErrorFound |= 1UL << 7UL;\r
339                 }\r
340 \r
341                 if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
342                 {\r
343                         ulErrorFound |= 1UL << 8UL;\r
344                 }\r
345 \r
346                 if( xAreTimerDemoTasksStillRunning( ( TickType_t ) mainNO_ERROR_CHECK_TASK_PERIOD ) != pdPASS )\r
347                 {\r
348                         ulErrorFound |= 1UL << 9UL;\r
349                 }\r
350 \r
351                 if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
352                 {\r
353                         ulErrorFound |= 1UL << 10UL;\r
354                 }\r
355 \r
356                 if( xIsQueueOverwriteTaskStillRunning() != pdPASS )\r
357                 {\r
358                         ulErrorFound |= 1UL << 11UL;\r
359                 }\r
360 \r
361                 if( xAreEventGroupTasksStillRunning() != pdPASS )\r
362                 {\r
363                         ulErrorFound |= 1UL << 12UL;\r
364                 }\r
365 \r
366                 if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
367                 {\r
368                         ulErrorFound |= 1UL << 13UL;\r
369                 }\r
370 \r
371                 if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
372                 {\r
373                         ulErrorFound |= 1UL << 14UL;\r
374                 }\r
375 \r
376                 if( xAreStaticAllocationTasksStillRunning() != pdPASS )\r
377                 {\r
378                         ulErrorFound |= 1UL << 15UL;\r
379                 }\r
380 \r
381                 if( xAreAbortDelayTestTasksStillRunning() != pdPASS )\r
382                 {\r
383                         ulErrorFound |= 1UL << 16UL;\r
384                 }\r
385 \r
386                 if( xAreStreamBufferTasksStillRunning() != pdTRUE )\r
387                 {\r
388                         ulErrorFound |= 1UL << 17UL;\r
389                 }\r
390 \r
391                 if( xAreMessageBufferTasksStillRunning() != pdTRUE )\r
392                 {\r
393                         ulErrorFound |= 1UL << 18UL;\r
394                 }\r
395 \r
396                 if( xIsInterruptStreamBufferDemoStillRunning() != pdPASS )\r
397                 {\r
398                         ulErrorFound |= 1UL << 19UL;\r
399                 }\r
400 \r
401                 if( xAreMessageBufferAMPTasksStillRunning() != pdPASS )\r
402                 {\r
403                         ulErrorFound |= 1UL << 20UL;\r
404                 }\r
405 \r
406                 /* Check that the register test 1 task is still running. */\r
407                 if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
408                 {\r
409                         ulErrorFound |= 1UL << 21UL;\r
410                 }\r
411                 ulLastRegTest1Value = ulRegTest1LoopCounter;\r
412 \r
413                 /* Check that the register test 2 task is still running. */\r
414                 if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
415                 {\r
416                         ulErrorFound |= 1UL << 22UL;\r
417                 }\r
418                 ulLastRegTest2Value = ulRegTest2LoopCounter;\r
419 \r
420                 /* Toggle the check LED to give an indication of the system status.  If\r
421                 the LED toggles every mainNO_ERROR_CHECK_TASK_PERIOD milliseconds then\r
422                 everything is ok.  A faster toggle indicates an error. */\r
423                 vParTestToggleLED( mainCHECK_LED );\r
424 \r
425                 if( ulErrorFound != pdFALSE )\r
426                 {\r
427                         /* An error has been detected in one of the tasks - flash the LED\r
428                         at a higher frequency to give visible feedback that something has\r
429                         gone wrong (it might just be that the loop back connector required\r
430                         by the comtest tasks has not been fitted). */\r
431                         xDelayPeriod = mainERROR_CHECK_TASK_PERIOD;\r
432                         pcStatusMessage = "Error found in at least one task.";\r
433                 }\r
434         }\r
435 }\r
436 /*-----------------------------------------------------------*/\r
437 \r
438 char *pcMainGetTaskStatusMessage( void )\r
439 {\r
440         return pcStatusMessage;\r
441 }\r
442 /*-----------------------------------------------------------*/\r
443 \r
444 static void prvRegTestTaskEntry1( void *pvParameters )\r
445 {\r
446         /* Although the regtest task is written in assembler, its entry point is\r
447         written in C for convenience of checking the task parameter is being passed\r
448         in correctly. */\r
449         if( pvParameters == mainREG_TEST_TASK_1_PARAMETER )\r
450         {\r
451                 /* The reg test task also tests the floating point registers.  Tasks\r
452                 that use the floating point unit must call vPortTaskUsesFPU() before\r
453                 any floating point instructions are executed. */\r
454                 vPortTaskUsesFPU();\r
455 \r
456                 /* Start the part of the test that is written in assembler. */\r
457                 vRegTest1Implementation();\r
458         }\r
459 \r
460         /* The following line will only execute if the task parameter is found to\r
461         be incorrect.  The check timer will detect that the regtest loop counter is\r
462         not being incremented and flag an error. */\r
463         vTaskDelete( NULL );\r
464 }\r
465 /*-----------------------------------------------------------*/\r
466 \r
467 static void prvRegTestTaskEntry2( void *pvParameters )\r
468 {\r
469         /* Although the regtest task is written in assembler, its entry point is\r
470         written in C for convenience of checking the task parameter is being passed\r
471         in correctly. */\r
472         if( pvParameters == mainREG_TEST_TASK_2_PARAMETER )\r
473         {\r
474                 /* The reg test task also tests the floating point registers.  Tasks\r
475                 that use the floating point unit must call vPortTaskUsesFPU() before\r
476                 any floating point instructions are executed. */\r
477                 vPortTaskUsesFPU();\r
478 \r
479                 /* Start the part of the test that is written in assembler. */\r
480                 vRegTest2Implementation();\r
481         }\r
482 \r
483         /* The following line will only execute if the task parameter is found to\r
484         be incorrect.  The check timer will detect that the regtest loop counter is\r
485         not being incremented and flag an error. */\r
486         vTaskDelete( NULL );\r
487 }\r
488 /*-----------------------------------------------------------*/\r
489 \r
490 static void prvPseudoRandomiser( void *pvParameters )\r
491 {\r
492 const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL, ulMinDelay = ( 35 / portTICK_PERIOD_MS );\r
493 volatile uint32_t ulNextRand = ( uint32_t ) &pvParameters, ulValue;\r
494 \r
495         /* This task does nothing other than ensure there is a little bit of\r
496         disruption in the scheduling pattern of the other tasks.  Normally this is\r
497         done by generating interrupts at pseudo random times. */\r
498         for( ;; )\r
499         {\r
500                 ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;\r
501                 ulValue = ( ulNextRand >> 16UL ) & 0xffUL;\r
502 \r
503                 if( ulValue < ulMinDelay )\r
504                 {\r
505                         ulValue = ulMinDelay;\r
506                 }\r
507 \r
508                 vTaskDelay( ulValue );\r
509 \r
510                 while( ulValue > 0 )\r
511                 {\r
512                         __asm volatile( "NOP" );\r
513                         __asm volatile( "NOP" );\r
514                         __asm volatile( "NOP" );\r
515                         __asm volatile( "NOP" );\r
516 \r
517                         ulValue--;\r
518                 }\r
519         }\r
520 }\r
521 \r
522 \r
523 \r
524 \r
525 \r
526 \r