]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/include/task.h
288c783fe203d2b5c9809aafcb47f8aea2226821
[freertos] / FreeRTOS / Source / include / task.h
1 /*\r
2     FreeRTOS V7.6.0 - Copyright (C) 2013 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     ***************************************************************************\r
8      *                                                                       *\r
9      *    FreeRTOS provides completely free yet professionally developed,    *\r
10      *    robust, strictly quality controlled, supported, and cross          *\r
11      *    platform software that has become a de facto standard.             *\r
12      *                                                                       *\r
13      *    Help yourself get started quickly and support the FreeRTOS         *\r
14      *    project by purchasing a FreeRTOS tutorial book, reference          *\r
15      *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
16      *                                                                       *\r
17      *    Thank you!                                                         *\r
18      *                                                                       *\r
19     ***************************************************************************\r
20 \r
21     This file is part of the FreeRTOS distribution.\r
22 \r
23     FreeRTOS is free software; you can redistribute it and/or modify it under\r
24     the terms of the GNU General Public License (version 2) as published by the\r
25     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
26 \r
27     >>! NOTE: The modification to the GPL is included to allow you to distribute\r
28     >>! a combined work that includes FreeRTOS without being obliged to provide\r
29     >>! the source code for proprietary components outside of the FreeRTOS\r
30     >>! kernel.\r
31 \r
32     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
33     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
34     FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
35     link: http://www.freertos.org/a00114.html\r
36 \r
37     1 tab == 4 spaces!\r
38 \r
39     ***************************************************************************\r
40      *                                                                       *\r
41      *    Having a problem?  Start by reading the FAQ "My application does   *\r
42      *    not run, what could be wrong?"                                     *\r
43      *                                                                       *\r
44      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
45      *                                                                       *\r
46     ***************************************************************************\r
47 \r
48     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
49     license and Real Time Engineers Ltd. contact details.\r
50 \r
51     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
52     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
53     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
54 \r
55     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
56     Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
57     licenses offer ticketed support, indemnification and middleware.\r
58 \r
59     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
60     engineered and independently SIL3 certified version for use in safety and\r
61     mission critical applications that require provable dependability.\r
62 \r
63     1 tab == 4 spaces!\r
64 */\r
65 \r
66 \r
67 #ifndef INC_TASK_H\r
68 #define INC_TASK_H\r
69 \r
70 #ifndef INC_FREERTOS_H\r
71         #error "include FreeRTOS.h must appear in source files before include task.h"\r
72 #endif\r
73 \r
74 #include "list.h"\r
75 \r
76 #ifdef __cplusplus\r
77 extern "C" {\r
78 #endif\r
79 \r
80 /*-----------------------------------------------------------\r
81  * MACROS AND DEFINITIONS\r
82  *----------------------------------------------------------*/\r
83 \r
84 #define tskKERNEL_VERSION_NUMBER "V7.6.0"\r
85 \r
86 /**\r
87  * task. h\r
88  *\r
89  * Type by which tasks are referenced.  For example, a call to xTaskCreate\r
90  * returns (via a pointer parameter) an xTaskHandle variable that can then\r
91  * be used as a parameter to vTaskDelete to delete the task.\r
92  *\r
93  * \defgroup xTaskHandle xTaskHandle\r
94  * \ingroup Tasks\r
95  */\r
96 typedef void * xTaskHandle;\r
97 \r
98 /* Task states returned by eTaskGetState. */\r
99 typedef enum\r
100 {\r
101         eRunning = 0,   /* A task is querying the state of itself, so must be running. */\r
102         eReady,                 /* The task being queried is in a read or pending ready list. */\r
103         eBlocked,               /* The task being queried is in the Blocked state. */\r
104         eSuspended,             /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */\r
105         eDeleted                /* The task being queried has been deleted, but its TCB has not yet been freed. */\r
106 } eTaskState;\r
107 \r
108 /*\r
109  * Used internally only.\r
110  */\r
111 typedef struct xTIME_OUT\r
112 {\r
113         portBASE_TYPE xOverflowCount;\r
114         portTickType  xTimeOnEntering;\r
115 } xTimeOutType;\r
116 \r
117 /*\r
118  * Defines the memory ranges allocated to the task when an MPU is used.\r
119  */\r
120 typedef struct xMEMORY_REGION\r
121 {\r
122         void *pvBaseAddress;\r
123         unsigned long ulLengthInBytes;\r
124         unsigned long ulParameters;\r
125 } xMemoryRegion;\r
126 \r
127 /*\r
128  * Parameters required to create an MPU protected task.\r
129  */\r
130 typedef struct xTASK_PARAMETERS\r
131 {\r
132         pdTASK_CODE pvTaskCode;\r
133         const signed char * const pcName;\r
134         unsigned short usStackDepth;\r
135         void *pvParameters;\r
136         unsigned portBASE_TYPE uxPriority;\r
137         portSTACK_TYPE *puxStackBuffer;\r
138         xMemoryRegion xRegions[ portNUM_CONFIGURABLE_REGIONS ];\r
139 } xTaskParameters;\r
140 \r
141 /* Used with the uxTaskGetSystemState() function to return the state of each task\r
142 in the system. */\r
143 typedef struct xTASK_STATUS\r
144 {\r
145         xTaskHandle xHandle;                                            /* The handle of the task to which the rest of the information in the structure relates. */\r
146         const signed char *pcTaskName;                          /* A pointer to the task's name.  This value will be invalid if the task was deleted since the structure was populated! */\r
147         unsigned portBASE_TYPE xTaskNumber;                     /* A number unique to the task. */\r
148         eTaskState eCurrentState;                                       /* The state in which the task existed when the structure was populated. */\r
149         unsigned portBASE_TYPE uxCurrentPriority;       /* The priority at which the task was running (may be inherited) when the structure was populated. */\r
150         unsigned portBASE_TYPE uxBasePriority;          /* The priority to which the task will return if the task's current priority has been inherited to avoid unbounded priority inversion when obtaining a mutex.  Only valid if configUSE_MUTEXES is defined as 1 in FreeRTOSConfig.h. */\r
151         unsigned long ulRunTimeCounter;                         /* The total run time allocated to the task so far, as defined by the run time stats clock.  See http://www.freertos.org/rtos-run-time-stats.html.  Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */\r
152         unsigned short usStackHighWaterMark;            /* The minimum amount of stack space that has remained for the task since the task was created.  The closer this value is to zero the closer the task has come to overflowing its stack. */\r
153 } xTaskStatusType;\r
154 \r
155 /* Possible return values for eTaskConfirmSleepModeStatus(). */\r
156 typedef enum\r
157 {\r
158         eAbortSleep = 0,                /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */\r
159         eStandardSleep,                 /* Enter a sleep mode that will not last any longer than the expected idle time. */\r
160         eNoTasksWaitingTimeout  /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */\r
161 } eSleepModeStatus;\r
162 \r
163 \r
164 /**\r
165  * Defines the priority used by the idle task.  This must not be modified.\r
166  *\r
167  * \ingroup TaskUtils\r
168  */\r
169 #define tskIDLE_PRIORITY                        ( ( unsigned portBASE_TYPE ) 0U )\r
170 \r
171 /**\r
172  * task. h\r
173  *\r
174  * Macro for forcing a context switch.\r
175  *\r
176  * \defgroup taskYIELD taskYIELD\r
177  * \ingroup SchedulerControl\r
178  */\r
179 #define taskYIELD()                                     portYIELD()\r
180 \r
181 /**\r
182  * task. h\r
183  *\r
184  * Macro to mark the start of a critical code region.  Preemptive context\r
185  * switches cannot occur when in a critical region.\r
186  *\r
187  * NOTE: This may alter the stack (depending on the portable implementation)\r
188  * so must be used with care!\r
189  *\r
190  * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL\r
191  * \ingroup SchedulerControl\r
192  */\r
193 #define taskENTER_CRITICAL()            portENTER_CRITICAL()\r
194 \r
195 /**\r
196  * task. h\r
197  *\r
198  * Macro to mark the end of a critical code region.  Preemptive context\r
199  * switches cannot occur when in a critical region.\r
200  *\r
201  * NOTE: This may alter the stack (depending on the portable implementation)\r
202  * so must be used with care!\r
203  *\r
204  * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL\r
205  * \ingroup SchedulerControl\r
206  */\r
207 #define taskEXIT_CRITICAL()                     portEXIT_CRITICAL()\r
208 \r
209 /**\r
210  * task. h\r
211  *\r
212  * Macro to disable all maskable interrupts.\r
213  *\r
214  * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS\r
215  * \ingroup SchedulerControl\r
216  */\r
217 #define taskDISABLE_INTERRUPTS()        portDISABLE_INTERRUPTS()\r
218 \r
219 /**\r
220  * task. h\r
221  *\r
222  * Macro to enable microcontroller interrupts.\r
223  *\r
224  * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS\r
225  * \ingroup SchedulerControl\r
226  */\r
227 #define taskENABLE_INTERRUPTS()         portENABLE_INTERRUPTS()\r
228 \r
229 /* Definitions returned by xTaskGetSchedulerState().  taskSCHEDULER_SUSPENDED is\r
230 0 to generate more optimal code when configASSERT() is defined as the constant\r
231 is used in assert() statements. */\r
232 #define taskSCHEDULER_SUSPENDED         ( ( portBASE_TYPE ) 0 )\r
233 #define taskSCHEDULER_NOT_STARTED       ( ( portBASE_TYPE ) 1 )\r
234 #define taskSCHEDULER_RUNNING           ( ( portBASE_TYPE ) 2 )\r
235 \r
236 \r
237 /*-----------------------------------------------------------\r
238  * TASK CREATION API\r
239  *----------------------------------------------------------*/\r
240 \r
241 /**\r
242  * task. h\r
243  *<pre>\r
244  portBASE_TYPE xTaskCreate(\r
245                                                           pdTASK_CODE pvTaskCode,\r
246                                                           const signed char * const pcName,\r
247                                                           unsigned short usStackDepth,\r
248                                                           void *pvParameters,\r
249                                                           unsigned portBASE_TYPE uxPriority,\r
250                                                           xTaskHandle *pvCreatedTask\r
251                                                   );</pre>\r
252  *\r
253  * Create a new task and add it to the list of tasks that are ready to run.\r
254  *\r
255  * xTaskCreate() can only be used to create a task that has unrestricted\r
256  * access to the entire microcontroller memory map.  Systems that include MPU\r
257  * support can alternatively create an MPU constrained task using\r
258  * xTaskCreateRestricted().\r
259  *\r
260  * @param pvTaskCode Pointer to the task entry function.  Tasks\r
261  * must be implemented to never return (i.e. continuous loop).\r
262  *\r
263  * @param pcName A descriptive name for the task.  This is mainly used to\r
264  * facilitate debugging.  Max length defined by configMAX_TASK_NAME_LEN - default\r
265  * is 16.\r
266  *\r
267  * @param usStackDepth The size of the task stack specified as the number of\r
268  * variables the stack can hold - not the number of bytes.  For example, if\r
269  * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes\r
270  * will be allocated for stack storage.\r
271  *\r
272  * @param pvParameters Pointer that will be used as the parameter for the task\r
273  * being created.\r
274  *\r
275  * @param uxPriority The priority at which the task should run.  Systems that\r
276  * include MPU support can optionally create tasks in a privileged (system)\r
277  * mode by setting bit portPRIVILEGE_BIT of the priority parameter.  For\r
278  * example, to create a privileged task at priority 2 the uxPriority parameter\r
279  * should be set to ( 2 | portPRIVILEGE_BIT ).\r
280  *\r
281  * @param pvCreatedTask Used to pass back a handle by which the created task\r
282  * can be referenced.\r
283  *\r
284  * @return pdPASS if the task was successfully created and added to a ready\r
285  * list, otherwise an error code defined in the file projdefs.h\r
286  *\r
287  * Example usage:\r
288    <pre>\r
289  // Task to be created.\r
290  void vTaskCode( void * pvParameters )\r
291  {\r
292          for( ;; )\r
293          {\r
294                  // Task code goes here.\r
295          }\r
296  }\r
297 \r
298  // Function that creates a task.\r
299  void vOtherFunction( void )\r
300  {\r
301  static unsigned char ucParameterToPass;\r
302  xTaskHandle xHandle = NULL;\r
303 \r
304          // Create the task, storing the handle.  Note that the passed parameter ucParameterToPass\r
305          // must exist for the lifetime of the task, so in this case is declared static.  If it was just an\r
306          // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time\r
307          // the new task attempts to access it.\r
308          xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );\r
309      configASSERT( xHandle );\r
310 \r
311          // Use the handle to delete the task.\r
312      if( xHandle != NULL )\r
313      {\r
314              vTaskDelete( xHandle );\r
315      }\r
316  }\r
317    </pre>\r
318  * \defgroup xTaskCreate xTaskCreate\r
319  * \ingroup Tasks\r
320  */\r
321 #define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) )\r
322 \r
323 /**\r
324  * task. h\r
325  *<pre>\r
326  portBASE_TYPE xTaskCreateRestricted( xTaskParameters *pxTaskDefinition, xTaskHandle *pxCreatedTask );</pre>\r
327  *\r
328  * xTaskCreateRestricted() should only be used in systems that include an MPU\r
329  * implementation.\r
330  *\r
331  * Create a new task and add it to the list of tasks that are ready to run.\r
332  * The function parameters define the memory regions and associated access\r
333  * permissions allocated to the task.\r
334  *\r
335  * @param pxTaskDefinition Pointer to a structure that contains a member\r
336  * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API\r
337  * documentation) plus an optional stack buffer and the memory region\r
338  * definitions.\r
339  *\r
340  * @param pxCreatedTask Used to pass back a handle by which the created task\r
341  * can be referenced.\r
342  *\r
343  * @return pdPASS if the task was successfully created and added to a ready\r
344  * list, otherwise an error code defined in the file projdefs.h\r
345  *\r
346  * Example usage:\r
347    <pre>\r
348 // Create an xTaskParameters structure that defines the task to be created.\r
349 static const xTaskParameters xCheckTaskParameters =\r
350 {\r
351         vATask,         // pvTaskCode - the function that implements the task.\r
352         "ATask",        // pcName - just a text name for the task to assist debugging.\r
353         100,            // usStackDepth - the stack size DEFINED IN WORDS.\r
354         NULL,           // pvParameters - passed into the task function as the function parameters.\r
355         ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.\r
356         cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.\r
357 \r
358         // xRegions - Allocate up to three separate memory regions for access by\r
359         // the task, with appropriate access permissions.  Different processors have\r
360         // different memory alignment requirements - refer to the FreeRTOS documentation\r
361         // for full information.\r
362         {\r
363                 // Base address                                 Length  Parameters\r
364         { cReadWriteArray,                              32,             portMPU_REGION_READ_WRITE },\r
365         { cReadOnlyArray,                               32,             portMPU_REGION_READ_ONLY },\r
366         { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }\r
367         }\r
368 };\r
369 \r
370 int main( void )\r
371 {\r
372 xTaskHandle xHandle;\r
373 \r
374         // Create a task from the const structure defined above.  The task handle\r
375         // is requested (the second parameter is not NULL) but in this case just for\r
376         // demonstration purposes as its not actually used.\r
377         xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );\r
378 \r
379         // Start the scheduler.\r
380         vTaskStartScheduler();\r
381 \r
382         // Will only get here if there was insufficient memory to create the idle\r
383         // and/or timer task.\r
384         for( ;; );\r
385 }\r
386    </pre>\r
387  * \defgroup xTaskCreateRestricted xTaskCreateRestricted\r
388  * \ingroup Tasks\r
389  */\r
390 #define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) )\r
391 \r
392 /**\r
393  * task. h\r
394  *<pre>\r
395  void vTaskAllocateMPURegions( xTaskHandle xTask, const xMemoryRegion * const pxRegions );</pre>\r
396  *\r
397  * Memory regions are assigned to a restricted task when the task is created by\r
398  * a call to xTaskCreateRestricted().  These regions can be redefined using\r
399  * vTaskAllocateMPURegions().\r
400  *\r
401  * @param xTask The handle of the task being updated.\r
402  *\r
403  * @param xRegions A pointer to an xMemoryRegion structure that contains the\r
404  * new memory region definitions.\r
405  *\r
406  * Example usage:\r
407    <pre>\r
408 // Define an array of xMemoryRegion structures that configures an MPU region\r
409 // allowing read/write access for 1024 bytes starting at the beginning of the\r
410 // ucOneKByte array.  The other two of the maximum 3 definable regions are\r
411 // unused so set to zero.\r
412 static const xMemoryRegion xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =\r
413 {\r
414         // Base address         Length          Parameters\r
415         { ucOneKByte,           1024,           portMPU_REGION_READ_WRITE },\r
416         { 0,                            0,                      0 },\r
417         { 0,                            0,                      0 }\r
418 };\r
419 \r
420 void vATask( void *pvParameters )\r
421 {\r
422         // This task was created such that it has access to certain regions of\r
423         // memory as defined by the MPU configuration.  At some point it is\r
424         // desired that these MPU regions are replaced with that defined in the\r
425         // xAltRegions const struct above.  Use a call to vTaskAllocateMPURegions()\r
426         // for this purpose.  NULL is used as the task handle to indicate that this\r
427         // function should modify the MPU regions of the calling task.\r
428         vTaskAllocateMPURegions( NULL, xAltRegions );\r
429 \r
430         // Now the task can continue its function, but from this point on can only\r
431         // access its stack and the ucOneKByte array (unless any other statically\r
432         // defined or shared regions have been declared elsewhere).\r
433 }\r
434    </pre>\r
435  * \defgroup xTaskCreateRestricted xTaskCreateRestricted\r
436  * \ingroup Tasks\r
437  */\r
438 void vTaskAllocateMPURegions( xTaskHandle xTask, const xMemoryRegion * const pxRegions ) PRIVILEGED_FUNCTION;\r
439 \r
440 /**\r
441  * task. h\r
442  * <pre>void vTaskDelete( xTaskHandle xTask );</pre>\r
443  *\r
444  * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.\r
445  * See the configuration section for more information.\r
446  *\r
447  * Remove a task from the RTOS real time kernel's management.  The task being\r
448  * deleted will be removed from all ready, blocked, suspended and event lists.\r
449  *\r
450  * NOTE:  The idle task is responsible for freeing the kernel allocated\r
451  * memory from tasks that have been deleted.  It is therefore important that\r
452  * the idle task is not starved of microcontroller processing time if your\r
453  * application makes any calls to vTaskDelete ().  Memory allocated by the\r
454  * task code is not automatically freed, and should be freed before the task\r
455  * is deleted.\r
456  *\r
457  * See the demo application file death.c for sample code that utilises\r
458  * vTaskDelete ().\r
459  *\r
460  * @param xTask The handle of the task to be deleted.  Passing NULL will\r
461  * cause the calling task to be deleted.\r
462  *\r
463  * Example usage:\r
464    <pre>\r
465  void vOtherFunction( void )\r
466  {\r
467  xTaskHandle xHandle;\r
468 \r
469          // Create the task, storing the handle.\r
470          xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
471 \r
472          // Use the handle to delete the task.\r
473          vTaskDelete( xHandle );\r
474  }\r
475    </pre>\r
476  * \defgroup vTaskDelete vTaskDelete\r
477  * \ingroup Tasks\r
478  */\r
479 void vTaskDelete( xTaskHandle xTaskToDelete ) PRIVILEGED_FUNCTION;\r
480 \r
481 /*-----------------------------------------------------------\r
482  * TASK CONTROL API\r
483  *----------------------------------------------------------*/\r
484 \r
485 /**\r
486  * task. h\r
487  * <pre>void vTaskDelay( const portTickType xTicksToDelay );</pre>\r
488  *\r
489  * Delay a task for a given number of ticks.  The actual time that the\r
490  * task remains blocked depends on the tick rate.  The constant\r
491  * portTICK_RATE_MS can be used to calculate real time from the tick\r
492  * rate - with the resolution of one tick period.\r
493  *\r
494  * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.\r
495  * See the configuration section for more information.\r
496  *\r
497  *\r
498  * vTaskDelay() specifies a time at which the task wishes to unblock relative to\r
499  * the time at which vTaskDelay() is called.  For example, specifying a block\r
500  * period of 100 ticks will cause the task to unblock 100 ticks after\r
501  * vTaskDelay() is called.  vTaskDelay() does not therefore provide a good method\r
502  * of controlling the frequency of a periodic task as the path taken through the\r
503  * code, as well as other task and interrupt activity, will effect the frequency\r
504  * at which vTaskDelay() gets called and therefore the time at which the task\r
505  * next executes.  See vTaskDelayUntil() for an alternative API function designed\r
506  * to facilitate fixed frequency execution.  It does this by specifying an\r
507  * absolute time (rather than a relative time) at which the calling task should\r
508  * unblock.\r
509  *\r
510  * @param xTicksToDelay The amount of time, in tick periods, that\r
511  * the calling task should block.\r
512  *\r
513  * Example usage:\r
514 \r
515  void vTaskFunction( void * pvParameters )\r
516  {\r
517  // Block for 500ms.\r
518  const portTickType xDelay = 500 / portTICK_RATE_MS;\r
519 \r
520          for( ;; )\r
521          {\r
522                  // Simply toggle the LED every 500ms, blocking between each toggle.\r
523                  vToggleLED();\r
524                  vTaskDelay( xDelay );\r
525          }\r
526  }\r
527 \r
528  * \defgroup vTaskDelay vTaskDelay\r
529  * \ingroup TaskCtrl\r
530  */\r
531 void vTaskDelay( const portTickType xTicksToDelay ) PRIVILEGED_FUNCTION;\r
532 \r
533 /**\r
534  * task. h\r
535  * <pre>void vTaskDelayUntil( portTickType *pxPreviousWakeTime, const portTickType xTimeIncrement );</pre>\r
536  *\r
537  * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available.\r
538  * See the configuration section for more information.\r
539  *\r
540  * Delay a task until a specified time.  This function can be used by periodic\r
541  * tasks to ensure a constant execution frequency.\r
542  *\r
543  * This function differs from vTaskDelay () in one important aspect:  vTaskDelay () will\r
544  * cause a task to block for the specified number of ticks from the time vTaskDelay () is\r
545  * called.  It is therefore difficult to use vTaskDelay () by itself to generate a fixed\r
546  * execution frequency as the time between a task starting to execute and that task\r
547  * calling vTaskDelay () may not be fixed [the task may take a different path though the\r
548  * code between calls, or may get interrupted or preempted a different number of times\r
549  * each time it executes].\r
550  *\r
551  * Whereas vTaskDelay () specifies a wake time relative to the time at which the function\r
552  * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to\r
553  * unblock.\r
554  *\r
555  * The constant portTICK_RATE_MS can be used to calculate real time from the tick\r
556  * rate - with the resolution of one tick period.\r
557  *\r
558  * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the\r
559  * task was last unblocked.  The variable must be initialised with the current time\r
560  * prior to its first use (see the example below).  Following this the variable is\r
561  * automatically updated within vTaskDelayUntil ().\r
562  *\r
563  * @param xTimeIncrement The cycle time period.  The task will be unblocked at\r
564  * time *pxPreviousWakeTime + xTimeIncrement.  Calling vTaskDelayUntil with the\r
565  * same xTimeIncrement parameter value will cause the task to execute with\r
566  * a fixed interface period.\r
567  *\r
568  * Example usage:\r
569    <pre>\r
570  // Perform an action every 10 ticks.\r
571  void vTaskFunction( void * pvParameters )\r
572  {\r
573  portTickType xLastWakeTime;\r
574  const portTickType xFrequency = 10;\r
575 \r
576          // Initialise the xLastWakeTime variable with the current time.\r
577          xLastWakeTime = xTaskGetTickCount ();\r
578          for( ;; )\r
579          {\r
580                  // Wait for the next cycle.\r
581                  vTaskDelayUntil( &xLastWakeTime, xFrequency );\r
582 \r
583                  // Perform action here.\r
584          }\r
585  }\r
586    </pre>\r
587  * \defgroup vTaskDelayUntil vTaskDelayUntil\r
588  * \ingroup TaskCtrl\r
589  */\r
590 void vTaskDelayUntil( portTickType * const pxPreviousWakeTime, const portTickType xTimeIncrement ) PRIVILEGED_FUNCTION;\r
591 \r
592 /**\r
593  * task. h\r
594  * <pre>unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle xTask );</pre>\r
595  *\r
596  * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.\r
597  * See the configuration section for more information.\r
598  *\r
599  * Obtain the priority of any task.\r
600  *\r
601  * @param xTask Handle of the task to be queried.  Passing a NULL\r
602  * handle results in the priority of the calling task being returned.\r
603  *\r
604  * @return The priority of xTask.\r
605  *\r
606  * Example usage:\r
607    <pre>\r
608  void vAFunction( void )\r
609  {\r
610  xTaskHandle xHandle;\r
611 \r
612          // Create a task, storing the handle.\r
613          xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
614 \r
615          // ...\r
616 \r
617          // Use the handle to obtain the priority of the created task.\r
618          // It was created with tskIDLE_PRIORITY, but may have changed\r
619          // it itself.\r
620          if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )\r
621          {\r
622                  // The task has changed it's priority.\r
623          }\r
624 \r
625          // ...\r
626 \r
627          // Is our priority higher than the created task?\r
628          if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )\r
629          {\r
630                  // Our priority (obtained using NULL handle) is higher.\r
631          }\r
632  }\r
633    </pre>\r
634  * \defgroup uxTaskPriorityGet uxTaskPriorityGet\r
635  * \ingroup TaskCtrl\r
636  */\r
637 unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle xTask ) PRIVILEGED_FUNCTION;\r
638 \r
639 /**\r
640  * task. h\r
641  * <pre>eTaskState eTaskGetState( xTaskHandle xTask );</pre>\r
642  *\r
643  * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.\r
644  * See the configuration section for more information.\r
645  *\r
646  * Obtain the state of any task.  States are encoded by the eTaskState\r
647  * enumerated type.\r
648  *\r
649  * @param xTask Handle of the task to be queried.\r
650  *\r
651  * @return The state of xTask at the time the function was called.  Note the\r
652  * state of the task might change between the function being called, and the\r
653  * functions return value being tested by the calling task.\r
654  */\r
655 eTaskState eTaskGetState( xTaskHandle xTask ) PRIVILEGED_FUNCTION;\r
656 \r
657 /**\r
658  * task. h\r
659  * <pre>void vTaskPrioritySet( xTaskHandle xTask, unsigned portBASE_TYPE uxNewPriority );</pre>\r
660  *\r
661  * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.\r
662  * See the configuration section for more information.\r
663  *\r
664  * Set the priority of any task.\r
665  *\r
666  * A context switch will occur before the function returns if the priority\r
667  * being set is higher than the currently executing task.\r
668  *\r
669  * @param xTask Handle to the task for which the priority is being set.\r
670  * Passing a NULL handle results in the priority of the calling task being set.\r
671  *\r
672  * @param uxNewPriority The priority to which the task will be set.\r
673  *\r
674  * Example usage:\r
675    <pre>\r
676  void vAFunction( void )\r
677  {\r
678  xTaskHandle xHandle;\r
679 \r
680          // Create a task, storing the handle.\r
681          xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
682 \r
683          // ...\r
684 \r
685          // Use the handle to raise the priority of the created task.\r
686          vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );\r
687 \r
688          // ...\r
689 \r
690          // Use a NULL handle to raise our priority to the same value.\r
691          vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );\r
692  }\r
693    </pre>\r
694  * \defgroup vTaskPrioritySet vTaskPrioritySet\r
695  * \ingroup TaskCtrl\r
696  */\r
697 void vTaskPrioritySet( xTaskHandle xTask, unsigned portBASE_TYPE uxNewPriority ) PRIVILEGED_FUNCTION;\r
698 \r
699 /**\r
700  * task. h\r
701  * <pre>void vTaskSuspend( xTaskHandle xTaskToSuspend );</pre>\r
702  *\r
703  * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.\r
704  * See the configuration section for more information.\r
705  *\r
706  * Suspend any task.  When suspended a task will never get any microcontroller\r
707  * processing time, no matter what its priority.\r
708  *\r
709  * Calls to vTaskSuspend are not accumulative -\r
710  * i.e. calling vTaskSuspend () twice on the same task still only requires one\r
711  * call to vTaskResume () to ready the suspended task.\r
712  *\r
713  * @param xTaskToSuspend Handle to the task being suspended.  Passing a NULL\r
714  * handle will cause the calling task to be suspended.\r
715  *\r
716  * Example usage:\r
717    <pre>\r
718  void vAFunction( void )\r
719  {\r
720  xTaskHandle xHandle;\r
721 \r
722          // Create a task, storing the handle.\r
723          xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
724 \r
725          // ...\r
726 \r
727          // Use the handle to suspend the created task.\r
728          vTaskSuspend( xHandle );\r
729 \r
730          // ...\r
731 \r
732          // The created task will not run during this period, unless\r
733          // another task calls vTaskResume( xHandle ).\r
734 \r
735          //...\r
736 \r
737 \r
738          // Suspend ourselves.\r
739          vTaskSuspend( NULL );\r
740 \r
741          // We cannot get here unless another task calls vTaskResume\r
742          // with our handle as the parameter.\r
743  }\r
744    </pre>\r
745  * \defgroup vTaskSuspend vTaskSuspend\r
746  * \ingroup TaskCtrl\r
747  */\r
748 void vTaskSuspend( xTaskHandle xTaskToSuspend ) PRIVILEGED_FUNCTION;\r
749 \r
750 /**\r
751  * task. h\r
752  * <pre>void vTaskResume( xTaskHandle xTaskToResume );</pre>\r
753  *\r
754  * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.\r
755  * See the configuration section for more information.\r
756  *\r
757  * Resumes a suspended task.\r
758  *\r
759  * A task that has been suspended by one or more calls to vTaskSuspend ()\r
760  * will be made available for running again by a single call to\r
761  * vTaskResume ().\r
762  *\r
763  * @param xTaskToResume Handle to the task being readied.\r
764  *\r
765  * Example usage:\r
766    <pre>\r
767  void vAFunction( void )\r
768  {\r
769  xTaskHandle xHandle;\r
770 \r
771          // Create a task, storing the handle.\r
772          xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
773 \r
774          // ...\r
775 \r
776          // Use the handle to suspend the created task.\r
777          vTaskSuspend( xHandle );\r
778 \r
779          // ...\r
780 \r
781          // The created task will not run during this period, unless\r
782          // another task calls vTaskResume( xHandle ).\r
783 \r
784          //...\r
785 \r
786 \r
787          // Resume the suspended task ourselves.\r
788          vTaskResume( xHandle );\r
789 \r
790          // The created task will once again get microcontroller processing\r
791          // time in accordance with its priority within the system.\r
792  }\r
793    </pre>\r
794  * \defgroup vTaskResume vTaskResume\r
795  * \ingroup TaskCtrl\r
796  */\r
797 void vTaskResume( xTaskHandle xTaskToResume ) PRIVILEGED_FUNCTION;\r
798 \r
799 /**\r
800  * task. h\r
801  * <pre>void xTaskResumeFromISR( xTaskHandle xTaskToResume );</pre>\r
802  *\r
803  * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be\r
804  * available.  See the configuration section for more information.\r
805  *\r
806  * An implementation of vTaskResume() that can be called from within an ISR.\r
807  *\r
808  * A task that has been suspended by one or more calls to vTaskSuspend ()\r
809  * will be made available for running again by a single call to\r
810  * xTaskResumeFromISR ().\r
811  *\r
812  * xTaskResumeFromISR() should not be used to synchronise a task with an\r
813  * interrupt if there is a chance that the interrupt could arrive prior to the\r
814  * task being suspended - as this can lead to interrupts being missed. Use of a\r
815  * semaphore as a synchronisation mechanism would avoid this eventuality.\r
816  *\r
817  * @param xTaskToResume Handle to the task being readied.\r
818  *\r
819  * @return pdTRUE if resuming the task should result in a context switch,\r
820  * otherwise pdFALSE. This is used by the ISR to determine if a context switch\r
821  * may be required following the ISR.\r
822  *\r
823  * \defgroup vTaskResumeFromISR vTaskResumeFromISR\r
824  * \ingroup TaskCtrl\r
825  */\r
826 portBASE_TYPE xTaskResumeFromISR( xTaskHandle xTaskToResume ) PRIVILEGED_FUNCTION;\r
827 \r
828 /*-----------------------------------------------------------\r
829  * SCHEDULER CONTROL\r
830  *----------------------------------------------------------*/\r
831 \r
832 /**\r
833  * task. h\r
834  * <pre>void vTaskStartScheduler( void );</pre>\r
835  *\r
836  * Starts the real time kernel tick processing.  After calling the kernel\r
837  * has control over which tasks are executed and when.\r
838  *\r
839  * See the demo application file main.c for an example of creating\r
840  * tasks and starting the kernel.\r
841  *\r
842  * Example usage:\r
843    <pre>\r
844  void vAFunction( void )\r
845  {\r
846          // Create at least one task before starting the kernel.\r
847          xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
848 \r
849          // Start the real time kernel with preemption.\r
850          vTaskStartScheduler ();\r
851 \r
852          // Will not get here unless a task calls vTaskEndScheduler ()\r
853  }\r
854    </pre>\r
855  *\r
856  * \defgroup vTaskStartScheduler vTaskStartScheduler\r
857  * \ingroup SchedulerControl\r
858  */\r
859 void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;\r
860 \r
861 /**\r
862  * task. h\r
863  * <pre>void vTaskEndScheduler( void );</pre>\r
864  *\r
865  * NOTE:  At the time of writing only the x86 real mode port, which runs on a PC\r
866  * in place of DOS, implements this function.\r
867  *\r
868  * Stops the real time kernel tick.  All created tasks will be automatically\r
869  * deleted and multitasking (either preemptive or cooperative) will\r
870  * stop.  Execution then resumes from the point where vTaskStartScheduler ()\r
871  * was called, as if vTaskStartScheduler () had just returned.\r
872  *\r
873  * See the demo application file main. c in the demo/PC directory for an\r
874  * example that uses vTaskEndScheduler ().\r
875  *\r
876  * vTaskEndScheduler () requires an exit function to be defined within the\r
877  * portable layer (see vPortEndScheduler () in port. c for the PC port).  This\r
878  * performs hardware specific operations such as stopping the kernel tick.\r
879  *\r
880  * vTaskEndScheduler () will cause all of the resources allocated by the\r
881  * kernel to be freed - but will not free resources allocated by application\r
882  * tasks.\r
883  *\r
884  * Example usage:\r
885    <pre>\r
886  void vTaskCode( void * pvParameters )\r
887  {\r
888          for( ;; )\r
889          {\r
890                  // Task code goes here.\r
891 \r
892                  // At some point we want to end the real time kernel processing\r
893                  // so call ...\r
894                  vTaskEndScheduler ();\r
895          }\r
896  }\r
897 \r
898  void vAFunction( void )\r
899  {\r
900          // Create at least one task before starting the kernel.\r
901          xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
902 \r
903          // Start the real time kernel with preemption.\r
904          vTaskStartScheduler ();\r
905 \r
906          // Will only get here when the vTaskCode () task has called\r
907          // vTaskEndScheduler ().  When we get here we are back to single task\r
908          // execution.\r
909  }\r
910    </pre>\r
911  *\r
912  * \defgroup vTaskEndScheduler vTaskEndScheduler\r
913  * \ingroup SchedulerControl\r
914  */\r
915 void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;\r
916 \r
917 /**\r
918  * task. h\r
919  * <pre>void vTaskSuspendAll( void );</pre>\r
920  *\r
921  * Suspends the scheduler without disabling interrupts.  Context switches will\r
922  * not occur while the scheduler is suspended.\r
923  *\r
924  * After calling vTaskSuspendAll () the calling task will continue to execute\r
925  * without risk of being swapped out until a call to xTaskResumeAll () has been\r
926  * made.\r
927  *\r
928  * API functions that have the potential to cause a context switch (for example,\r
929  * vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler\r
930  * is suspended.\r
931  *\r
932  * Example usage:\r
933    <pre>\r
934  void vTask1( void * pvParameters )\r
935  {\r
936          for( ;; )\r
937          {\r
938                  // Task code goes here.\r
939 \r
940                  // ...\r
941 \r
942                  // At some point the task wants to perform a long operation during\r
943                  // which it does not want to get swapped out.  It cannot use\r
944                  // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the\r
945                  // operation may cause interrupts to be missed - including the\r
946                  // ticks.\r
947 \r
948                  // Prevent the real time kernel swapping out the task.\r
949                  vTaskSuspendAll ();\r
950 \r
951                  // Perform the operation here.  There is no need to use critical\r
952                  // sections as we have all the microcontroller processing time.\r
953                  // During this time interrupts will still operate and the kernel\r
954                  // tick count will be maintained.\r
955 \r
956                  // ...\r
957 \r
958                  // The operation is complete.  Restart the kernel.\r
959                  xTaskResumeAll ();\r
960          }\r
961  }\r
962    </pre>\r
963  * \defgroup vTaskSuspendAll vTaskSuspendAll\r
964  * \ingroup SchedulerControl\r
965  */\r
966 void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;\r
967 \r
968 /**\r
969  * task. h\r
970  * <pre>char xTaskResumeAll( void );</pre>\r
971  *\r
972  * Resumes scheduler activity after it was suspended by a call to\r
973  * vTaskSuspendAll().\r
974  *\r
975  * xTaskResumeAll() only resumes the scheduler.  It does not unsuspend tasks\r
976  * that were previously suspended by a call to vTaskSuspend().\r
977  *\r
978  * @return If resuming the scheduler caused a context switch then pdTRUE is\r
979  *                returned, otherwise pdFALSE is returned.\r
980  *\r
981  * Example usage:\r
982    <pre>\r
983  void vTask1( void * pvParameters )\r
984  {\r
985          for( ;; )\r
986          {\r
987                  // Task code goes here.\r
988 \r
989                  // ...\r
990 \r
991                  // At some point the task wants to perform a long operation during\r
992                  // which it does not want to get swapped out.  It cannot use\r
993                  // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the\r
994                  // operation may cause interrupts to be missed - including the\r
995                  // ticks.\r
996 \r
997                  // Prevent the real time kernel swapping out the task.\r
998                  vTaskSuspendAll ();\r
999 \r
1000                  // Perform the operation here.  There is no need to use critical\r
1001                  // sections as we have all the microcontroller processing time.\r
1002                  // During this time interrupts will still operate and the real\r
1003                  // time kernel tick count will be maintained.\r
1004 \r
1005                  // ...\r
1006 \r
1007                  // The operation is complete.  Restart the kernel.  We want to force\r
1008                  // a context switch - but there is no point if resuming the scheduler\r
1009                  // caused a context switch already.\r
1010                  if( !xTaskResumeAll () )\r
1011                  {\r
1012                           taskYIELD ();\r
1013                  }\r
1014          }\r
1015  }\r
1016    </pre>\r
1017  * \defgroup xTaskResumeAll xTaskResumeAll\r
1018  * \ingroup SchedulerControl\r
1019  */\r
1020 signed portBASE_TYPE xTaskResumeAll( void ) PRIVILEGED_FUNCTION;\r
1021 \r
1022 /**\r
1023  * task. h\r
1024  * <pre>signed portBASE_TYPE xTaskIsTaskSuspended( const xTaskHandle xTask );</pre>\r
1025  *\r
1026  * Utility task that simply returns pdTRUE if the task referenced by xTask is\r
1027  * currently in the Suspended state, or pdFALSE if the task referenced by xTask\r
1028  * is in any other state.\r
1029  *\r
1030  */\r
1031 signed portBASE_TYPE xTaskIsTaskSuspended( const xTaskHandle xTask ) PRIVILEGED_FUNCTION;\r
1032 \r
1033 /*-----------------------------------------------------------\r
1034  * TASK UTILITIES\r
1035  *----------------------------------------------------------*/\r
1036 \r
1037 /**\r
1038  * task. h\r
1039  * <PRE>portTickType xTaskGetTickCount( void );</PRE>\r
1040  *\r
1041  * @return The count of ticks since vTaskStartScheduler was called.\r
1042  *\r
1043  * \defgroup xTaskGetTickCount xTaskGetTickCount\r
1044  * \ingroup TaskUtils\r
1045  */\r
1046 portTickType xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;\r
1047 \r
1048 /**\r
1049  * task. h\r
1050  * <PRE>portTickType xTaskGetTickCountFromISR( void );</PRE>\r
1051  *\r
1052  * @return The count of ticks since vTaskStartScheduler was called.\r
1053  *\r
1054  * This is a version of xTaskGetTickCount() that is safe to be called from an\r
1055  * ISR - provided that portTickType is the natural word size of the\r
1056  * microcontroller being used or interrupt nesting is either not supported or\r
1057  * not being used.\r
1058  *\r
1059  * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR\r
1060  * \ingroup TaskUtils\r
1061  */\r
1062 portTickType xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;\r
1063 \r
1064 /**\r
1065  * task. h\r
1066  * <PRE>unsigned short uxTaskGetNumberOfTasks( void );</PRE>\r
1067  *\r
1068  * @return The number of tasks that the real time kernel is currently managing.\r
1069  * This includes all ready, blocked and suspended tasks.  A task that\r
1070  * has been deleted but not yet freed by the idle task will also be\r
1071  * included in the count.\r
1072  *\r
1073  * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks\r
1074  * \ingroup TaskUtils\r
1075  */\r
1076 unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;\r
1077 \r
1078 /**\r
1079  * task. h\r
1080  * <PRE>signed char *pcTaskGetTaskName( xTaskHandle xTaskToQuery );</PRE>\r
1081  *\r
1082  * @return The text (human readable) name of the task referenced by the handle\r
1083  * xTaskToQuery.  A task can query its own name by either passing in its own\r
1084  * handle, or by setting xTaskToQuery to NULL.  INCLUDE_pcTaskGetTaskName must be\r
1085  * set to 1 in FreeRTOSConfig.h for pcTaskGetTaskName() to be available.\r
1086  *\r
1087  * \defgroup pcTaskGetTaskName pcTaskGetTaskName\r
1088  * \ingroup TaskUtils\r
1089  */\r
1090 signed char *pcTaskGetTaskName( xTaskHandle xTaskToQuery );\r
1091 \r
1092 /**\r
1093  * task.h\r
1094  * <PRE>unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask );</PRE>\r
1095  *\r
1096  * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for\r
1097  * this function to be available.\r
1098  *\r
1099  * Returns the high water mark of the stack associated with xTask.  That is,\r
1100  * the minimum free stack space there has been (in words, so on a 32 bit machine\r
1101  * a value of 1 means 4 bytes) since the task started.  The smaller the returned\r
1102  * number the closer the task has come to overflowing its stack.\r
1103  *\r
1104  * @param xTask Handle of the task associated with the stack to be checked.\r
1105  * Set xTask to NULL to check the stack of the calling task.\r
1106  *\r
1107  * @return The smallest amount of free stack space there has been (in words, so\r
1108  * actual spaces on the stack rather than bytes) since the task referenced by\r
1109  * xTask was created.\r
1110  */\r
1111 unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask ) PRIVILEGED_FUNCTION;\r
1112 \r
1113 /* When using trace macros it is sometimes necessary to include task.h before\r
1114 FreeRTOS.h.  When this is done pdTASK_HOOK_CODE will not yet have been defined,\r
1115 so the following two prototypes will cause a compilation error.  This can be\r
1116 fixed by simply guarding against the inclusion of these two prototypes unless\r
1117 they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration\r
1118 constant. */\r
1119 #ifdef configUSE_APPLICATION_TASK_TAG\r
1120         #if configUSE_APPLICATION_TASK_TAG == 1\r
1121                 /**\r
1122                  * task.h\r
1123                  * <pre>void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction );</pre>\r
1124                  *\r
1125                  * Sets pxHookFunction to be the task hook function used by the task xTask.\r
1126                  * Passing xTask as NULL has the effect of setting the calling tasks hook\r
1127                  * function.\r
1128                  */\r
1129                 void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction ) PRIVILEGED_FUNCTION;\r
1130 \r
1131                 /**\r
1132                  * task.h\r
1133                  * <pre>void xTaskGetApplicationTaskTag( xTaskHandle xTask );</pre>\r
1134                  *\r
1135                  * Returns the pxHookFunction value assigned to the task xTask.\r
1136                  */\r
1137                 pdTASK_HOOK_CODE xTaskGetApplicationTaskTag( xTaskHandle xTask ) PRIVILEGED_FUNCTION;\r
1138         #endif /* configUSE_APPLICATION_TASK_TAG ==1 */\r
1139 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */\r
1140 \r
1141 /**\r
1142  * task.h\r
1143  * <pre>portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter );</pre>\r
1144  *\r
1145  * Calls the hook function associated with xTask.  Passing xTask as NULL has\r
1146  * the effect of calling the Running tasks (the calling task) hook function.\r
1147  *\r
1148  * pvParameter is passed to the hook function for the task to interpret as it\r
1149  * wants.  The return value is the value returned by the task hook function\r
1150  * registered by the user.\r
1151  */\r
1152 portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter ) PRIVILEGED_FUNCTION;\r
1153 \r
1154 /**\r
1155  * xTaskGetIdleTaskHandle() is only available if\r
1156  * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.\r
1157  *\r
1158  * Simply returns the handle of the idle task.  It is not valid to call\r
1159  * xTaskGetIdleTaskHandle() before the scheduler has been started.\r
1160  */\r
1161 xTaskHandle xTaskGetIdleTaskHandle( void );\r
1162 \r
1163 /**\r
1164  * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for\r
1165  * uxTaskGetSystemState() to be available.\r
1166  *\r
1167  * uxTaskGetSystemState() populates an xTaskStatusType structure for each task in\r
1168  * the system.  xTaskStatusType structures contain, among other things, members\r
1169  * for the task handle, task name, task priority, task state, and total amount\r
1170  * of run time consumed by the task.  See the xTaskStatusType structure\r
1171  * definition in this file for the full member list.\r
1172  *\r
1173  * NOTE:  This function is intended for debugging use only as its use results in\r
1174  * the scheduler remaining suspended for an extended period.\r
1175  *\r
1176  * @param pxTaskStatusArray A pointer to an array of xTaskStatusType structures.\r
1177  * The array must contain at least one xTaskStatusType structure for each task\r
1178  * that is under the control of the RTOS.  The number of tasks under the control\r
1179  * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.\r
1180  *\r
1181  * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray\r
1182  * parameter.  The size is specified as the number of indexes in the array, or\r
1183  * the number of xTaskStatusType structures contained in the array, not by the\r
1184  * number of bytes in the array.\r
1185  *\r
1186  * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in\r
1187  * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the\r
1188  * total run time (as defined by the run time stats clock, see\r
1189  * http://www.freertos.org/rtos-run-time-stats.html) since the target booted.\r
1190  * pulTotalRunTime can be set to NULL to omit the total run time information.\r
1191  *\r
1192  * @return The number of xTaskStatusType structures that were populated by\r
1193  * uxTaskGetSystemState().  This should equal the number returned by the\r
1194  * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed\r
1195  * in the uxArraySize parameter was too small.\r
1196  *\r
1197  * Example usage:\r
1198    <pre>\r
1199     // This example demonstrates how a human readable table of run time stats\r
1200         // information is generated from raw data provided by uxTaskGetSystemState().\r
1201         // The human readable table is written to pcWriteBuffer\r
1202         void vTaskGetRunTimeStats( signed char *pcWriteBuffer )\r
1203         {\r
1204         xTaskStatusType *pxTaskStatusArray;\r
1205         volatile unsigned portBASE_TYPE uxArraySize, x;\r
1206         unsigned long ulTotalRunTime, ulStatsAsPercentage;\r
1207 \r
1208                 // Make sure the write buffer does not contain a string.\r
1209                 *pcWriteBuffer = 0x00;\r
1210 \r
1211                 // Take a snapshot of the number of tasks in case it changes while this\r
1212                 // function is executing.\r
1213                 uxArraySize = uxTaskGetNumberOfTasks();\r
1214 \r
1215                 // Allocate a xTaskStatusType structure for each task.  An array could be\r
1216                 // allocated statically at compile time.\r
1217                 pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( xTaskStatusType ) );\r
1218 \r
1219                 if( pxTaskStatusArray != NULL )\r
1220                 {\r
1221                         // Generate raw status information about each task.\r
1222                         uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );\r
1223 \r
1224                         // For percentage calculations.\r
1225                         ulTotalRunTime /= 100UL;\r
1226 \r
1227                         // Avoid divide by zero errors.\r
1228                         if( ulTotalRunTime > 0 )\r
1229                         {\r
1230                                 // For each populated position in the pxTaskStatusArray array,\r
1231                                 // format the raw data as human readable ASCII data\r
1232                                 for( x = 0; x < uxArraySize; x++ )\r
1233                                 {\r
1234                                         // What percentage of the total run time has the task used?\r
1235                                         // This will always be rounded down to the nearest integer.\r
1236                                         // ulTotalRunTimeDiv100 has already been divided by 100.\r
1237                                         ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;\r
1238 \r
1239                                         if( ulStatsAsPercentage > 0UL )\r
1240                                         {\r
1241                                                 sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );\r
1242                                         }\r
1243                                         else\r
1244                                         {\r
1245                                                 // If the percentage is zero here then the task has\r
1246                                                 // consumed less than 1% of the total run time.\r
1247                                                 sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );\r
1248                                         }\r
1249 \r
1250                                         pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );\r
1251                                 }\r
1252                         }\r
1253 \r
1254                         // The array is no longer needed, free the memory it consumes.\r
1255                         vPortFree( pxTaskStatusArray );\r
1256                 }\r
1257         }\r
1258         </pre>\r
1259  */\r
1260 unsigned portBASE_TYPE uxTaskGetSystemState( xTaskStatusType *pxTaskStatusArray, unsigned portBASE_TYPE uxArraySize, unsigned long *pulTotalRunTime );\r
1261 \r
1262 /**\r
1263  * task. h\r
1264  * <PRE>void vTaskList( char *pcWriteBuffer );</PRE>\r
1265  *\r
1266  * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must\r
1267  * both be defined as 1 for this function to be available.  See the\r
1268  * configuration section of the FreeRTOS.org website for more information.\r
1269  *\r
1270  * NOTE 1: This function will disable interrupts for its duration.  It is\r
1271  * not intended for normal application runtime use but as a debug aid.\r
1272  *\r
1273  * Lists all the current tasks, along with their current state and stack\r
1274  * usage high water mark.\r
1275  *\r
1276  * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or\r
1277  * suspended ('S').\r
1278  *\r
1279  * PLEASE NOTE:\r
1280  *\r
1281  * This function is provided for convenience only, and is used by many of the\r
1282  * demo applications.  Do not consider it to be part of the scheduler.\r
1283  *\r
1284  * vTaskList() calls uxTaskGetSystemState(), then formats part of the\r
1285  * uxTaskGetSystemState() output into a human readable table that displays task\r
1286  * names, states and stack usage.\r
1287  *\r
1288  * vTaskList() has a dependency on the sprintf() C library function that might\r
1289  * bloat the code size, use a lot of stack, and provide different results on\r
1290  * different platforms.  An alternative, tiny, third party, and limited\r
1291  * functionality implementation of sprintf() is provided in many of the\r
1292  * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note\r
1293  * printf-stdarg.c does not provide a full snprintf() implementation!).\r
1294  *\r
1295  * It is recommended that production systems call uxTaskGetSystemState()\r
1296  * directly to get access to raw stats data, rather than indirectly through a\r
1297  * call to vTaskList().\r
1298  *\r
1299  * @param pcWriteBuffer A buffer into which the above mentioned details\r
1300  * will be written, in ASCII form.  This buffer is assumed to be large\r
1301  * enough to contain the generated report.  Approximately 40 bytes per\r
1302  * task should be sufficient.\r
1303  *\r
1304  * \defgroup vTaskList vTaskList\r
1305  * \ingroup TaskUtils\r
1306  */\r
1307 void vTaskList( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION;\r
1308 \r
1309 /**\r
1310  * task. h\r
1311  * <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>\r
1312  *\r
1313  * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS\r
1314  * must both be defined as 1 for this function to be available.  The application\r
1315  * must also then provide definitions for\r
1316  * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()\r
1317  * to configure a peripheral timer/counter and return the timers current count\r
1318  * value respectively.  The counter should be at least 10 times the frequency of\r
1319  * the tick count.\r
1320  *\r
1321  * NOTE 1: This function will disable interrupts for its duration.  It is\r
1322  * not intended for normal application runtime use but as a debug aid.\r
1323  *\r
1324  * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total\r
1325  * accumulated execution time being stored for each task.  The resolution\r
1326  * of the accumulated time value depends on the frequency of the timer\r
1327  * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.\r
1328  * Calling vTaskGetRunTimeStats() writes the total execution time of each\r
1329  * task into a buffer, both as an absolute count value and as a percentage\r
1330  * of the total system execution time.\r
1331  *\r
1332  * NOTE 2:\r
1333  *\r
1334  * This function is provided for convenience only, and is used by many of the\r
1335  * demo applications.  Do not consider it to be part of the scheduler.\r
1336  *\r
1337  * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the\r
1338  * uxTaskGetSystemState() output into a human readable table that displays the\r
1339  * amount of time each task has spent in the Running state in both absolute and\r
1340  * percentage terms.\r
1341  *\r
1342  * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function\r
1343  * that might bloat the code size, use a lot of stack, and provide different\r
1344  * results on different platforms.  An alternative, tiny, third party, and\r
1345  * limited functionality implementation of sprintf() is provided in many of the\r
1346  * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note\r
1347  * printf-stdarg.c does not provide a full snprintf() implementation!).\r
1348  *\r
1349  * It is recommended that production systems call uxTaskGetSystemState() directly\r
1350  * to get access to raw stats data, rather than indirectly through a call to\r
1351  * vTaskGetRunTimeStats().\r
1352  *\r
1353  * @param pcWriteBuffer A buffer into which the execution times will be\r
1354  * written, in ASCII form.  This buffer is assumed to be large enough to\r
1355  * contain the generated report.  Approximately 40 bytes per task should\r
1356  * be sufficient.\r
1357  *\r
1358  * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats\r
1359  * \ingroup TaskUtils\r
1360  */\r
1361 void vTaskGetRunTimeStats( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION;\r
1362 \r
1363 /*-----------------------------------------------------------\r
1364  * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES\r
1365  *----------------------------------------------------------*/\r
1366 \r
1367 /*\r
1368  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY\r
1369  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS\r
1370  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
1371  *\r
1372  * Called from the real time kernel tick (either preemptive or cooperative),\r
1373  * this increments the tick count and checks if any tasks that are blocked\r
1374  * for a finite period required removing from a blocked list and placing on\r
1375  * a ready list.  If a non-zero value is returned then a context switch is\r
1376  * required because either:\r
1377  *   + A task was removed from a blocked list because its timeout had expired,\r
1378  *     or\r
1379  *   + Time slicing is in use and there is a task of equal priority to the\r
1380  *     currently running task.\r
1381  */\r
1382 portBASE_TYPE xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;\r
1383 \r
1384 /*\r
1385  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
1386  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
1387  *\r
1388  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.\r
1389  *\r
1390  * Removes the calling task from the ready list and places it both\r
1391  * on the list of tasks waiting for a particular event, and the\r
1392  * list of delayed tasks.  The task will be removed from both lists\r
1393  * and replaced on the ready list should either the event occur (and\r
1394  * there be no higher priority tasks waiting on the same event) or\r
1395  * the delay period expires.\r
1396  *\r
1397  * The 'unordered' version replaces the event list item value with the\r
1398  * xItemValue value, and inserts the list item at the end of the list.\r
1399  *\r
1400  * The 'ordered' version uses the existing event list item value (which is the\r
1401  * owning tasks priority) to insert the list item into the event list is task\r
1402  * priority order.\r
1403  *\r
1404  * @param pxEventList The list containing tasks that are blocked waiting\r
1405  * for the event to occur.\r
1406  *\r
1407  * @param xItemValue The item value to use for the event list item when the\r
1408  * event list is not ordered by task priority.\r
1409  *\r
1410  * @param xTicksToWait The maximum amount of time that the task should wait\r
1411  * for the event to occur.  This is specified in kernel ticks,the constant\r
1412  * portTICK_RATE_MS can be used to convert kernel ticks into a real time\r
1413  * period.\r
1414  */\r
1415 void vTaskPlaceOnEventList( xList * const pxEventList, const portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
1416 void vTaskPlaceOnUnorderedEventList( xList * pxEventList, portTickType xItemValue, const portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
1417 \r
1418 /*\r
1419  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
1420  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
1421  *\r
1422  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.\r
1423  *\r
1424  * This function performs nearly the same function as vTaskPlaceOnEventList().\r
1425  * The difference being that this function does not permit tasks to block\r
1426  * indefinitely, whereas vTaskPlaceOnEventList() does.\r
1427  *\r
1428  */\r
1429 void vTaskPlaceOnEventListRestricted( xList * const pxEventList, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
1430 \r
1431 /*\r
1432  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
1433  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
1434  *\r
1435  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.\r
1436  *\r
1437  * Removes a task from both the specified event list and the list of blocked\r
1438  * tasks, and places it on a ready queue.\r
1439  *\r
1440  * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called\r
1441  * if either an event occurs to unblock a task, or the block timeout period\r
1442  * expires.\r
1443  *\r
1444  * xTaskRemoveFromEventList() is used when the event list is in task priority\r
1445  * order.  It removes the list item from the head of the event list as that will\r
1446  * have the highest priority owning task of all the tasks on the event list.\r
1447  * xTaskRemoveFromUnorderedEventList() is used when the event list is not\r
1448  * ordered and the event list items hold something other than the owning tasks\r
1449  * priority.  In this case the event list item value is updated to the value\r
1450  * passed in the xItemValue parameter.\r
1451  *\r
1452  * @return pdTRUE if the task being removed has a higher priority than the task\r
1453  * making the call, otherwise pdFALSE.\r
1454  */\r
1455 signed portBASE_TYPE xTaskRemoveFromEventList( const xList * const pxEventList ) PRIVILEGED_FUNCTION;\r
1456 signed portBASE_TYPE xTaskRemoveFromUnorderedEventList( xListItem * pxEventListItem, portTickType xItemValue ) PRIVILEGED_FUNCTION;\r
1457 \r
1458 /*\r
1459  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY\r
1460  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS\r
1461  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
1462  *\r
1463  * Sets the pointer to the current TCB to the TCB of the highest priority task\r
1464  * that is ready to run.\r
1465  */\r
1466 void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;\r
1467 \r
1468 /*\r
1469  * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE.  THEY ARE USED BY\r
1470  * THE EVENT BITS MODULE.\r
1471  */\r
1472 portTickType uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;\r
1473 \r
1474 /*\r
1475  * Return the handle of the calling task.\r
1476  */\r
1477 xTaskHandle xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;\r
1478 \r
1479 /*\r
1480  * Capture the current time status for future reference.\r
1481  */\r
1482 void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut ) PRIVILEGED_FUNCTION;\r
1483 \r
1484 /*\r
1485  * Compare the time status now with that previously captured to see if the\r
1486  * timeout has expired.\r
1487  */\r
1488 portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType * const pxTicksToWait ) PRIVILEGED_FUNCTION;\r
1489 \r
1490 /*\r
1491  * Shortcut used by the queue implementation to prevent unnecessary call to\r
1492  * taskYIELD();\r
1493  */\r
1494 void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;\r
1495 \r
1496 /*\r
1497  * Returns the scheduler state as taskSCHEDULER_RUNNING,\r
1498  * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.\r
1499  */\r
1500 portBASE_TYPE xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;\r
1501 \r
1502 /*\r
1503  * Raises the priority of the mutex holder to that of the calling task should\r
1504  * the mutex holder have a priority less than the calling task.\r
1505  */\r
1506 void vTaskPriorityInherit( xTaskHandle const pxMutexHolder ) PRIVILEGED_FUNCTION;\r
1507 \r
1508 /*\r
1509  * Set the priority of a task back to its proper priority in the case that it\r
1510  * inherited a higher priority while it was holding a semaphore.\r
1511  */\r
1512 void vTaskPriorityDisinherit( xTaskHandle const pxMutexHolder ) PRIVILEGED_FUNCTION;\r
1513 \r
1514 /*\r
1515  * Generic version of the task creation function which is in turn called by the\r
1516  * xTaskCreate() and xTaskCreateRestricted() macros.\r
1517  */\r
1518 signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions ) PRIVILEGED_FUNCTION;\r
1519 \r
1520 /*\r
1521  * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.\r
1522  */\r
1523 unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask ) PRIVILEGED_FUNCTION;\r
1524 \r
1525 /*\r
1526  * Set the uxTaskNumber of the task referenced by the xTask parameter to\r
1527  * uxHandle.\r
1528  */\r
1529 void vTaskSetTaskNumber( xTaskHandle xTask, unsigned portBASE_TYPE uxHandle ) PRIVILEGED_FUNCTION;\r
1530 \r
1531 /*\r
1532  * Only available when configUSE_TICKLESS_IDLE is set to 1.\r
1533  * If tickless mode is being used, or a low power mode is implemented, then\r
1534  * the tick interrupt will not execute during idle periods.  When this is the\r
1535  * case, the tick count value maintained by the scheduler needs to be kept up\r
1536  * to date with the actual execution time by being skipped forward by a time\r
1537  * equal to the idle period.\r
1538  */\r
1539 void vTaskStepTick( portTickType xTicksToJump ) PRIVILEGED_FUNCTION;\r
1540 \r
1541 /*\r
1542  * Only avilable when configUSE_TICKLESS_IDLE is set to 1.\r
1543  * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port\r
1544  * specific sleep function to determine if it is ok to proceed with the sleep,\r
1545  * and if it is ok to proceed, if it is ok to sleep indefinitely.\r
1546  *\r
1547  * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only\r
1548  * called with the scheduler suspended, not from within a critical section.  It\r
1549  * is therefore possible for an interrupt to request a context switch between\r
1550  * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being\r
1551  * entered.  eTaskConfirmSleepModeStatus() should be called from a short\r
1552  * critical section between the timer being stopped and the sleep mode being\r
1553  * entered to ensure it is ok to proceed into the sleep mode.\r
1554  */\r
1555 eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;\r
1556 \r
1557 #ifdef __cplusplus\r
1558 }\r
1559 #endif\r
1560 #endif /* INC_TASK_H */\r
1561 \r
1562 \r
1563 \r