]> begriffs open source - freertos/blob - include/task.h
Add a cap to the queue locks (#435)
[freertos] / include / task.h
1 /*
2  * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3  * Copyright (C) 2021 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * SPDX-License-Identifier: MIT
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy of
8  * this software and associated documentation files (the "Software"), to deal in
9  * the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11  * the Software, and to permit persons to whom the Software is furnished to do so,
12  * subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * https://www.FreeRTOS.org
25  * https://github.com/FreeRTOS
26  *
27  */
28
29
30 #ifndef INC_TASK_H
31 #define INC_TASK_H
32
33 #ifndef INC_FREERTOS_H
34     #error "include FreeRTOS.h must appear in source files before include task.h"
35 #endif
36
37 #include "list.h"
38
39 /* *INDENT-OFF* */
40 #ifdef __cplusplus
41     extern "C" {
42 #endif
43 /* *INDENT-ON* */
44
45 /*-----------------------------------------------------------
46 * MACROS AND DEFINITIONS
47 *----------------------------------------------------------*/
48
49 /*
50  * If tskKERNEL_VERSION_NUMBER ends with + it represents the version in development
51  * after the numbered release.
52  *
53  * The tskKERNEL_VERSION_MAJOR, tskKERNEL_VERSION_MINOR, tskKERNEL_VERSION_BUILD
54  * values will reflect the last released version number.
55  */
56 #define tskKERNEL_VERSION_NUMBER       "V10.4.4+"
57 #define tskKERNEL_VERSION_MAJOR        10
58 #define tskKERNEL_VERSION_MINOR        4
59 #define tskKERNEL_VERSION_BUILD        4
60
61 /* MPU region parameters passed in ulParameters
62  * of MemoryRegion_t struct. */
63 #define tskMPU_REGION_READ_ONLY        ( 1UL << 0UL )
64 #define tskMPU_REGION_READ_WRITE       ( 1UL << 1UL )
65 #define tskMPU_REGION_EXECUTE_NEVER    ( 1UL << 2UL )
66 #define tskMPU_REGION_NORMAL_MEMORY    ( 1UL << 3UL )
67 #define tskMPU_REGION_DEVICE_MEMORY    ( 1UL << 4UL )
68
69 /* The direct to task notification feature used to have only a single notification
70  * per task.  Now there is an array of notifications per task that is dimensioned by
71  * configTASK_NOTIFICATION_ARRAY_ENTRIES.  For backward compatibility, any use of the
72  * original direct to task notification defaults to using the first index in the
73  * array. */
74 #define tskDEFAULT_INDEX_TO_NOTIFY     ( 0 )
75
76 /**
77  * task. h
78  *
79  * Type by which tasks are referenced.  For example, a call to xTaskCreate
80  * returns (via a pointer parameter) an TaskHandle_t variable that can then
81  * be used as a parameter to vTaskDelete to delete the task.
82  *
83  * \defgroup TaskHandle_t TaskHandle_t
84  * \ingroup Tasks
85  */
86 struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
87 typedef struct tskTaskControlBlock * TaskHandle_t;
88
89 /*
90  * Defines the prototype to which the application task hook function must
91  * conform.
92  */
93 typedef BaseType_t (* TaskHookFunction_t)( void * );
94
95 /* Task states returned by eTaskGetState. */
96 typedef enum
97 {
98     eRunning = 0, /* A task is querying the state of itself, so must be running. */
99     eReady,       /* The task being queried is in a ready or pending ready list. */
100     eBlocked,     /* The task being queried is in the Blocked state. */
101     eSuspended,   /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
102     eDeleted,     /* The task being queried has been deleted, but its TCB has not yet been freed. */
103     eInvalid      /* Used as an 'invalid state' value. */
104 } eTaskState;
105
106 /* Actions that can be performed when vTaskNotify() is called. */
107 typedef enum
108 {
109     eNoAction = 0,            /* Notify the task without updating its notify value. */
110     eSetBits,                 /* Set bits in the task's notification value. */
111     eIncrement,               /* Increment the task's notification value. */
112     eSetValueWithOverwrite,   /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
113     eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */
114 } eNotifyAction;
115
116 /*
117  * Used internally only.
118  */
119 typedef struct xTIME_OUT
120 {
121     BaseType_t xOverflowCount;
122     TickType_t xTimeOnEntering;
123 } TimeOut_t;
124
125 /*
126  * Defines the memory ranges allocated to the task when an MPU is used.
127  */
128 typedef struct xMEMORY_REGION
129 {
130     void * pvBaseAddress;
131     uint32_t ulLengthInBytes;
132     uint32_t ulParameters;
133 } MemoryRegion_t;
134
135 /*
136  * Parameters required to create an MPU protected task.
137  */
138 typedef struct xTASK_PARAMETERS
139 {
140     TaskFunction_t pvTaskCode;
141     const char * pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
142     configSTACK_DEPTH_TYPE usStackDepth;
143     void * pvParameters;
144     UBaseType_t uxPriority;
145     StackType_t * puxStackBuffer;
146     MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
147     #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
148         StaticTask_t * const pxTaskBuffer;
149     #endif
150 } TaskParameters_t;
151
152 /* Used with the uxTaskGetSystemState() function to return the state of each task
153  * in the system. */
154 typedef struct xTASK_STATUS
155 {
156     TaskHandle_t xHandle;                         /* The handle of the task to which the rest of the information in the structure relates. */
157     const char * pcTaskName;                      /* A pointer to the task's name.  This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
158     UBaseType_t xTaskNumber;                      /* A number unique to the task. */
159     eTaskState eCurrentState;                     /* The state in which the task existed when the structure was populated. */
160     UBaseType_t uxCurrentPriority;                /* The priority at which the task was running (may be inherited) when the structure was populated. */
161     UBaseType_t 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. */
162     configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock.  See https://www.FreeRTOS.org/rtos-run-time-stats.html.  Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
163     StackType_t * pxStackBase;                    /* Points to the lowest address of the task's stack area. */
164     configSTACK_DEPTH_TYPE 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. */
165 } TaskStatus_t;
166
167 /* Possible return values for eTaskConfirmSleepModeStatus(). */
168 typedef enum
169 {
170     eAbortSleep = 0,           /* A task has been made ready or a context switch pended since portSUPPRESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */
171     eStandardSleep,            /* Enter a sleep mode that will not last any longer than the expected idle time. */
172     #if ( INCLUDE_vTaskSuspend == 1 )
173         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. */
174     #endif /* INCLUDE_vTaskSuspend */
175 } eSleepModeStatus;
176
177 /**
178  * Defines the priority used by the idle task.  This must not be modified.
179  *
180  * \ingroup TaskUtils
181  */
182 #define tskIDLE_PRIORITY    ( ( UBaseType_t ) 0U )
183
184 /**
185  * task. h
186  *
187  * Macro for forcing a context switch.
188  *
189  * \defgroup taskYIELD taskYIELD
190  * \ingroup SchedulerControl
191  */
192 #define taskYIELD()                        portYIELD()
193
194 /**
195  * task. h
196  *
197  * Macro to mark the start of a critical code region.  Preemptive context
198  * switches cannot occur when in a critical region.
199  *
200  * NOTE: This may alter the stack (depending on the portable implementation)
201  * so must be used with care!
202  *
203  * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
204  * \ingroup SchedulerControl
205  */
206 #define taskENTER_CRITICAL()               portENTER_CRITICAL()
207 #define taskENTER_CRITICAL_FROM_ISR()      portSET_INTERRUPT_MASK_FROM_ISR()
208
209 /**
210  * task. h
211  *
212  * Macro to mark the end of a critical code region.  Preemptive context
213  * switches cannot occur when in a critical region.
214  *
215  * NOTE: This may alter the stack (depending on the portable implementation)
216  * so must be used with care!
217  *
218  * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
219  * \ingroup SchedulerControl
220  */
221 #define taskEXIT_CRITICAL()                portEXIT_CRITICAL()
222 #define taskEXIT_CRITICAL_FROM_ISR( x )    portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
223
224 /**
225  * task. h
226  *
227  * Macro to disable all maskable interrupts.
228  *
229  * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
230  * \ingroup SchedulerControl
231  */
232 #define taskDISABLE_INTERRUPTS()           portDISABLE_INTERRUPTS()
233
234 /**
235  * task. h
236  *
237  * Macro to enable microcontroller interrupts.
238  *
239  * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
240  * \ingroup SchedulerControl
241  */
242 #define taskENABLE_INTERRUPTS()            portENABLE_INTERRUPTS()
243
244 /* Definitions returned by xTaskGetSchedulerState().  taskSCHEDULER_SUSPENDED is
245  * 0 to generate more optimal code when configASSERT() is defined as the constant
246  * is used in assert() statements. */
247 #define taskSCHEDULER_SUSPENDED      ( ( BaseType_t ) 0 )
248 #define taskSCHEDULER_NOT_STARTED    ( ( BaseType_t ) 1 )
249 #define taskSCHEDULER_RUNNING        ( ( BaseType_t ) 2 )
250
251
252 /*-----------------------------------------------------------
253 * TASK CREATION API
254 *----------------------------------------------------------*/
255
256 /**
257  * task. h
258  * @code{c}
259  * BaseType_t xTaskCreate(
260  *                            TaskFunction_t pxTaskCode,
261  *                            const char *pcName,
262  *                            configSTACK_DEPTH_TYPE usStackDepth,
263  *                            void *pvParameters,
264  *                            UBaseType_t uxPriority,
265  *                            TaskHandle_t *pxCreatedTask
266  *                        );
267  * @endcode
268  *
269  * Create a new task and add it to the list of tasks that are ready to run.
270  *
271  * Internally, within the FreeRTOS implementation, tasks use two blocks of
272  * memory.  The first block is used to hold the task's data structures.  The
273  * second block is used by the task as its stack.  If a task is created using
274  * xTaskCreate() then both blocks of memory are automatically dynamically
275  * allocated inside the xTaskCreate() function.  (see
276  * https://www.FreeRTOS.org/a00111.html).  If a task is created using
277  * xTaskCreateStatic() then the application writer must provide the required
278  * memory.  xTaskCreateStatic() therefore allows a task to be created without
279  * using any dynamic memory allocation.
280  *
281  * See xTaskCreateStatic() for a version that does not use any dynamic memory
282  * allocation.
283  *
284  * xTaskCreate() can only be used to create a task that has unrestricted
285  * access to the entire microcontroller memory map.  Systems that include MPU
286  * support can alternatively create an MPU constrained task using
287  * xTaskCreateRestricted().
288  *
289  * @param pxTaskCode Pointer to the task entry function.  Tasks
290  * must be implemented to never return (i.e. continuous loop).
291  *
292  * @param pcName A descriptive name for the task.  This is mainly used to
293  * facilitate debugging.  Max length defined by configMAX_TASK_NAME_LEN - default
294  * is 16.
295  *
296  * @param usStackDepth The size of the task stack specified as the number of
297  * variables the stack can hold - not the number of bytes.  For example, if
298  * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
299  * will be allocated for stack storage.
300  *
301  * @param pvParameters Pointer that will be used as the parameter for the task
302  * being created.
303  *
304  * @param uxPriority The priority at which the task should run.  Systems that
305  * include MPU support can optionally create tasks in a privileged (system)
306  * mode by setting bit portPRIVILEGE_BIT of the priority parameter.  For
307  * example, to create a privileged task at priority 2 the uxPriority parameter
308  * should be set to ( 2 | portPRIVILEGE_BIT ).
309  *
310  * @param pxCreatedTask Used to pass back a handle by which the created task
311  * can be referenced.
312  *
313  * @return pdPASS if the task was successfully created and added to a ready
314  * list, otherwise an error code defined in the file projdefs.h
315  *
316  * Example usage:
317  * @code{c}
318  * // Task to be created.
319  * void vTaskCode( void * pvParameters )
320  * {
321  *   for( ;; )
322  *   {
323  *       // Task code goes here.
324  *   }
325  * }
326  *
327  * // Function that creates a task.
328  * void vOtherFunction( void )
329  * {
330  * static uint8_t ucParameterToPass;
331  * TaskHandle_t xHandle = NULL;
332  *
333  *   // Create the task, storing the handle.  Note that the passed parameter ucParameterToPass
334  *   // must exist for the lifetime of the task, so in this case is declared static.  If it was just an
335  *   // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
336  *   // the new task attempts to access it.
337  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
338  *   configASSERT( xHandle );
339  *
340  *   // Use the handle to delete the task.
341  *   if( xHandle != NULL )
342  *   {
343  *      vTaskDelete( xHandle );
344  *   }
345  * }
346  * @endcode
347  * \defgroup xTaskCreate xTaskCreate
348  * \ingroup Tasks
349  */
350 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
351     BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
352                             const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
353                             const configSTACK_DEPTH_TYPE usStackDepth,
354                             void * const pvParameters,
355                             UBaseType_t uxPriority,
356                             TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
357 #endif
358
359 /**
360  * task. h
361  * @code{c}
362  * TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
363  *                               const char *pcName,
364  *                               uint32_t ulStackDepth,
365  *                               void *pvParameters,
366  *                               UBaseType_t uxPriority,
367  *                               StackType_t *puxStackBuffer,
368  *                               StaticTask_t *pxTaskBuffer );
369  * @endcode
370  *
371  * Create a new task and add it to the list of tasks that are ready to run.
372  *
373  * Internally, within the FreeRTOS implementation, tasks use two blocks of
374  * memory.  The first block is used to hold the task's data structures.  The
375  * second block is used by the task as its stack.  If a task is created using
376  * xTaskCreate() then both blocks of memory are automatically dynamically
377  * allocated inside the xTaskCreate() function.  (see
378  * https://www.FreeRTOS.org/a00111.html).  If a task is created using
379  * xTaskCreateStatic() then the application writer must provide the required
380  * memory.  xTaskCreateStatic() therefore allows a task to be created without
381  * using any dynamic memory allocation.
382  *
383  * @param pxTaskCode Pointer to the task entry function.  Tasks
384  * must be implemented to never return (i.e. continuous loop).
385  *
386  * @param pcName A descriptive name for the task.  This is mainly used to
387  * facilitate debugging.  The maximum length of the string is defined by
388  * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
389  *
390  * @param ulStackDepth The size of the task stack specified as the number of
391  * variables the stack can hold - not the number of bytes.  For example, if
392  * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes
393  * will be allocated for stack storage.
394  *
395  * @param pvParameters Pointer that will be used as the parameter for the task
396  * being created.
397  *
398  * @param uxPriority The priority at which the task will run.
399  *
400  * @param puxStackBuffer Must point to a StackType_t array that has at least
401  * ulStackDepth indexes - the array will then be used as the task's stack,
402  * removing the need for the stack to be allocated dynamically.
403  *
404  * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
405  * then be used to hold the task's data structures, removing the need for the
406  * memory to be allocated dynamically.
407  *
408  * @return If neither puxStackBuffer nor pxTaskBuffer are NULL, then the task
409  * will be created and a handle to the created task is returned.  If either
410  * puxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
411  * NULL is returned.
412  *
413  * Example usage:
414  * @code{c}
415  *
416  *  // Dimensions of the buffer that the task being created will use as its stack.
417  *  // NOTE:  This is the number of words the stack will hold, not the number of
418  *  // bytes.  For example, if each stack item is 32-bits, and this is set to 100,
419  *  // then 400 bytes (100 * 32-bits) will be allocated.
420  #define STACK_SIZE 200
421  *
422  *  // Structure that will hold the TCB of the task being created.
423  *  StaticTask_t xTaskBuffer;
424  *
425  *  // Buffer that the task being created will use as its stack.  Note this is
426  *  // an array of StackType_t variables.  The size of StackType_t is dependent on
427  *  // the RTOS port.
428  *  StackType_t xStack[ STACK_SIZE ];
429  *
430  *  // Function that implements the task being created.
431  *  void vTaskCode( void * pvParameters )
432  *  {
433  *      // The parameter value is expected to be 1 as 1 is passed in the
434  *      // pvParameters value in the call to xTaskCreateStatic().
435  *      configASSERT( ( uint32_t ) pvParameters == 1UL );
436  *
437  *      for( ;; )
438  *      {
439  *          // Task code goes here.
440  *      }
441  *  }
442  *
443  *  // Function that creates a task.
444  *  void vOtherFunction( void )
445  *  {
446  *      TaskHandle_t xHandle = NULL;
447  *
448  *      // Create the task without using any dynamic memory allocation.
449  *      xHandle = xTaskCreateStatic(
450  *                    vTaskCode,       // Function that implements the task.
451  *                    "NAME",          // Text name for the task.
452  *                    STACK_SIZE,      // Stack size in words, not bytes.
453  *                    ( void * ) 1,    // Parameter passed into the task.
454  *                    tskIDLE_PRIORITY,// Priority at which the task is created.
455  *                    xStack,          // Array to use as the task's stack.
456  *                    &xTaskBuffer );  // Variable to hold the task's data structure.
457  *
458  *      // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
459  *      // been created, and xHandle will be the task's handle.  Use the handle
460  *      // to suspend the task.
461  *      vTaskSuspend( xHandle );
462  *  }
463  * @endcode
464  * \defgroup xTaskCreateStatic xTaskCreateStatic
465  * \ingroup Tasks
466  */
467 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
468     TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
469                                     const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
470                                     const uint32_t ulStackDepth,
471                                     void * const pvParameters,
472                                     UBaseType_t uxPriority,
473                                     StackType_t * const puxStackBuffer,
474                                     StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
475 #endif /* configSUPPORT_STATIC_ALLOCATION */
476
477 /**
478  * task. h
479  * @code{c}
480  * BaseType_t xTaskCreateRestricted( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
481  * @endcode
482  *
483  * Only available when configSUPPORT_DYNAMIC_ALLOCATION is set to 1.
484  *
485  * xTaskCreateRestricted() should only be used in systems that include an MPU
486  * implementation.
487  *
488  * Create a new task and add it to the list of tasks that are ready to run.
489  * The function parameters define the memory regions and associated access
490  * permissions allocated to the task.
491  *
492  * See xTaskCreateRestrictedStatic() for a version that does not use any
493  * dynamic memory allocation.
494  *
495  * @param pxTaskDefinition Pointer to a structure that contains a member
496  * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
497  * documentation) plus an optional stack buffer and the memory region
498  * definitions.
499  *
500  * @param pxCreatedTask Used to pass back a handle by which the created task
501  * can be referenced.
502  *
503  * @return pdPASS if the task was successfully created and added to a ready
504  * list, otherwise an error code defined in the file projdefs.h
505  *
506  * Example usage:
507  * @code{c}
508  * // Create an TaskParameters_t structure that defines the task to be created.
509  * static const TaskParameters_t xCheckTaskParameters =
510  * {
511  *  vATask,     // pvTaskCode - the function that implements the task.
512  *  "ATask",    // pcName - just a text name for the task to assist debugging.
513  *  100,        // usStackDepth - the stack size DEFINED IN WORDS.
514  *  NULL,       // pvParameters - passed into the task function as the function parameters.
515  *  ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
516  *  cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
517  *
518  *  // xRegions - Allocate up to three separate memory regions for access by
519  *  // the task, with appropriate access permissions.  Different processors have
520  *  // different memory alignment requirements - refer to the FreeRTOS documentation
521  *  // for full information.
522  *  {
523  *      // Base address                 Length  Parameters
524  *      { cReadWriteArray,              32,     portMPU_REGION_READ_WRITE },
525  *      { cReadOnlyArray,               32,     portMPU_REGION_READ_ONLY },
526  *      { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }
527  *  }
528  * };
529  *
530  * int main( void )
531  * {
532  * TaskHandle_t xHandle;
533  *
534  *  // Create a task from the const structure defined above.  The task handle
535  *  // is requested (the second parameter is not NULL) but in this case just for
536  *  // demonstration purposes as its not actually used.
537  *  xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
538  *
539  *  // Start the scheduler.
540  *  vTaskStartScheduler();
541  *
542  *  // Will only get here if there was insufficient memory to create the idle
543  *  // and/or timer task.
544  *  for( ;; );
545  * }
546  * @endcode
547  * \defgroup xTaskCreateRestricted xTaskCreateRestricted
548  * \ingroup Tasks
549  */
550 #if ( portUSING_MPU_WRAPPERS == 1 )
551     BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
552                                       TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
553 #endif
554
555 /**
556  * task. h
557  * @code{c}
558  * BaseType_t xTaskCreateRestrictedStatic( TaskParameters_t *pxTaskDefinition, TaskHandle_t *pxCreatedTask );
559  * @endcode
560  *
561  * Only available when configSUPPORT_STATIC_ALLOCATION is set to 1.
562  *
563  * xTaskCreateRestrictedStatic() should only be used in systems that include an
564  * MPU implementation.
565  *
566  * Internally, within the FreeRTOS implementation, tasks use two blocks of
567  * memory.  The first block is used to hold the task's data structures.  The
568  * second block is used by the task as its stack.  If a task is created using
569  * xTaskCreateRestricted() then the stack is provided by the application writer,
570  * and the memory used to hold the task's data structure is automatically
571  * dynamically allocated inside the xTaskCreateRestricted() function.  If a task
572  * is created using xTaskCreateRestrictedStatic() then the application writer
573  * must provide the memory used to hold the task's data structures too.
574  * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be
575  * created without using any dynamic memory allocation.
576  *
577  * @param pxTaskDefinition Pointer to a structure that contains a member
578  * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
579  * documentation) plus an optional stack buffer and the memory region
580  * definitions.  If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure
581  * contains an additional member, which is used to point to a variable of type
582  * StaticTask_t - which is then used to hold the task's data structure.
583  *
584  * @param pxCreatedTask Used to pass back a handle by which the created task
585  * can be referenced.
586  *
587  * @return pdPASS if the task was successfully created and added to a ready
588  * list, otherwise an error code defined in the file projdefs.h
589  *
590  * Example usage:
591  * @code{c}
592  * // Create an TaskParameters_t structure that defines the task to be created.
593  * // The StaticTask_t variable is only included in the structure when
594  * // configSUPPORT_STATIC_ALLOCATION is set to 1.  The PRIVILEGED_DATA macro can
595  * // be used to force the variable into the RTOS kernel's privileged data area.
596  * static PRIVILEGED_DATA StaticTask_t xTaskBuffer;
597  * static const TaskParameters_t xCheckTaskParameters =
598  * {
599  *  vATask,     // pvTaskCode - the function that implements the task.
600  *  "ATask",    // pcName - just a text name for the task to assist debugging.
601  *  100,        // usStackDepth - the stack size DEFINED IN WORDS.
602  *  NULL,       // pvParameters - passed into the task function as the function parameters.
603  *  ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.
604  *  cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.
605  *
606  *  // xRegions - Allocate up to three separate memory regions for access by
607  *  // the task, with appropriate access permissions.  Different processors have
608  *  // different memory alignment requirements - refer to the FreeRTOS documentation
609  *  // for full information.
610  *  {
611  *      // Base address                 Length  Parameters
612  *      { cReadWriteArray,              32,     portMPU_REGION_READ_WRITE },
613  *      { cReadOnlyArray,               32,     portMPU_REGION_READ_ONLY },
614  *      { cPrivilegedOnlyAccessArray,   128,    portMPU_REGION_PRIVILEGED_READ_WRITE }
615  *  }
616  *
617  *  &xTaskBuffer; // Holds the task's data structure.
618  * };
619  *
620  * int main( void )
621  * {
622  * TaskHandle_t xHandle;
623  *
624  *  // Create a task from the const structure defined above.  The task handle
625  *  // is requested (the second parameter is not NULL) but in this case just for
626  *  // demonstration purposes as its not actually used.
627  *  xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );
628  *
629  *  // Start the scheduler.
630  *  vTaskStartScheduler();
631  *
632  *  // Will only get here if there was insufficient memory to create the idle
633  *  // and/or timer task.
634  *  for( ;; );
635  * }
636  * @endcode
637  * \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic
638  * \ingroup Tasks
639  */
640 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
641     BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
642                                             TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
643 #endif
644
645 /**
646  * task. h
647  * @code{c}
648  * void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
649  * @endcode
650  *
651  * Memory regions are assigned to a restricted task when the task is created by
652  * a call to xTaskCreateRestricted().  These regions can be redefined using
653  * vTaskAllocateMPURegions().
654  *
655  * @param xTask The handle of the task being updated.
656  *
657  * @param xRegions A pointer to a MemoryRegion_t structure that contains the
658  * new memory region definitions.
659  *
660  * Example usage:
661  * @code{c}
662  * // Define an array of MemoryRegion_t structures that configures an MPU region
663  * // allowing read/write access for 1024 bytes starting at the beginning of the
664  * // ucOneKByte array.  The other two of the maximum 3 definable regions are
665  * // unused so set to zero.
666  * static const MemoryRegion_t xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =
667  * {
668  *  // Base address     Length      Parameters
669  *  { ucOneKByte,       1024,       portMPU_REGION_READ_WRITE },
670  *  { 0,                0,          0 },
671  *  { 0,                0,          0 }
672  * };
673  *
674  * void vATask( void *pvParameters )
675  * {
676  *  // This task was created such that it has access to certain regions of
677  *  // memory as defined by the MPU configuration.  At some point it is
678  *  // desired that these MPU regions are replaced with that defined in the
679  *  // xAltRegions const struct above.  Use a call to vTaskAllocateMPURegions()
680  *  // for this purpose.  NULL is used as the task handle to indicate that this
681  *  // function should modify the MPU regions of the calling task.
682  *  vTaskAllocateMPURegions( NULL, xAltRegions );
683  *
684  *  // Now the task can continue its function, but from this point on can only
685  *  // access its stack and the ucOneKByte array (unless any other statically
686  *  // defined or shared regions have been declared elsewhere).
687  * }
688  * @endcode
689  * \defgroup xTaskCreateRestricted xTaskCreateRestricted
690  * \ingroup Tasks
691  */
692 void vTaskAllocateMPURegions( TaskHandle_t xTask,
693                               const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
694
695 /**
696  * task. h
697  * @code{c}
698  * void vTaskDelete( TaskHandle_t xTaskToDelete );
699  * @endcode
700  *
701  * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
702  * See the configuration section for more information.
703  *
704  * Remove a task from the RTOS real time kernel's management.  The task being
705  * deleted will be removed from all ready, blocked, suspended and event lists.
706  *
707  * NOTE:  The idle task is responsible for freeing the kernel allocated
708  * memory from tasks that have been deleted.  It is therefore important that
709  * the idle task is not starved of microcontroller processing time if your
710  * application makes any calls to vTaskDelete ().  Memory allocated by the
711  * task code is not automatically freed, and should be freed before the task
712  * is deleted.
713  *
714  * See the demo application file death.c for sample code that utilises
715  * vTaskDelete ().
716  *
717  * @param xTaskToDelete The handle of the task to be deleted.  Passing NULL will
718  * cause the calling task to be deleted.
719  *
720  * Example usage:
721  * @code{c}
722  * void vOtherFunction( void )
723  * {
724  * TaskHandle_t xHandle;
725  *
726  *   // Create the task, storing the handle.
727  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
728  *
729  *   // Use the handle to delete the task.
730  *   vTaskDelete( xHandle );
731  * }
732  * @endcode
733  * \defgroup vTaskDelete vTaskDelete
734  * \ingroup Tasks
735  */
736 void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
737
738 /*-----------------------------------------------------------
739 * TASK CONTROL API
740 *----------------------------------------------------------*/
741
742 /**
743  * task. h
744  * @code{c}
745  * void vTaskDelay( const TickType_t xTicksToDelay );
746  * @endcode
747  *
748  * Delay a task for a given number of ticks.  The actual time that the
749  * task remains blocked depends on the tick rate.  The constant
750  * portTICK_PERIOD_MS can be used to calculate real time from the tick
751  * rate - with the resolution of one tick period.
752  *
753  * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
754  * See the configuration section for more information.
755  *
756  *
757  * vTaskDelay() specifies a time at which the task wishes to unblock relative to
758  * the time at which vTaskDelay() is called.  For example, specifying a block
759  * period of 100 ticks will cause the task to unblock 100 ticks after
760  * vTaskDelay() is called.  vTaskDelay() does not therefore provide a good method
761  * of controlling the frequency of a periodic task as the path taken through the
762  * code, as well as other task and interrupt activity, will affect the frequency
763  * at which vTaskDelay() gets called and therefore the time at which the task
764  * next executes.  See xTaskDelayUntil() for an alternative API function designed
765  * to facilitate fixed frequency execution.  It does this by specifying an
766  * absolute time (rather than a relative time) at which the calling task should
767  * unblock.
768  *
769  * @param xTicksToDelay The amount of time, in tick periods, that
770  * the calling task should block.
771  *
772  * Example usage:
773  *
774  * void vTaskFunction( void * pvParameters )
775  * {
776  * // Block for 500ms.
777  * const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
778  *
779  *   for( ;; )
780  *   {
781  *       // Simply toggle the LED every 500ms, blocking between each toggle.
782  *       vToggleLED();
783  *       vTaskDelay( xDelay );
784  *   }
785  * }
786  *
787  * \defgroup vTaskDelay vTaskDelay
788  * \ingroup TaskCtrl
789  */
790 void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
791
792 /**
793  * task. h
794  * @code{c}
795  * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
796  * @endcode
797  *
798  * INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available.
799  * See the configuration section for more information.
800  *
801  * Delay a task until a specified time.  This function can be used by periodic
802  * tasks to ensure a constant execution frequency.
803  *
804  * This function differs from vTaskDelay () in one important aspect:  vTaskDelay () will
805  * cause a task to block for the specified number of ticks from the time vTaskDelay () is
806  * called.  It is therefore difficult to use vTaskDelay () by itself to generate a fixed
807  * execution frequency as the time between a task starting to execute and that task
808  * calling vTaskDelay () may not be fixed [the task may take a different path though the
809  * code between calls, or may get interrupted or preempted a different number of times
810  * each time it executes].
811  *
812  * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
813  * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
814  * unblock.
815  *
816  * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
817  * time specified in milliseconds with a resolution of one tick period.
818  *
819  * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
820  * task was last unblocked.  The variable must be initialised with the current time
821  * prior to its first use (see the example below).  Following this the variable is
822  * automatically updated within xTaskDelayUntil ().
823  *
824  * @param xTimeIncrement The cycle time period.  The task will be unblocked at
825  * time *pxPreviousWakeTime + xTimeIncrement.  Calling xTaskDelayUntil with the
826  * same xTimeIncrement parameter value will cause the task to execute with
827  * a fixed interface period.
828  *
829  * @return Value which can be used to check whether the task was actually delayed.
830  * Will be pdTRUE if the task way delayed and pdFALSE otherwise.  A task will not
831  * be delayed if the next expected wake time is in the past.
832  *
833  * Example usage:
834  * @code{c}
835  * // Perform an action every 10 ticks.
836  * void vTaskFunction( void * pvParameters )
837  * {
838  * TickType_t xLastWakeTime;
839  * const TickType_t xFrequency = 10;
840  * BaseType_t xWasDelayed;
841  *
842  *     // Initialise the xLastWakeTime variable with the current time.
843  *     xLastWakeTime = xTaskGetTickCount ();
844  *     for( ;; )
845  *     {
846  *         // Wait for the next cycle.
847  *         xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
848  *
849  *         // Perform action here. xWasDelayed value can be used to determine
850  *         // whether a deadline was missed if the code here took too long.
851  *     }
852  * }
853  * @endcode
854  * \defgroup xTaskDelayUntil xTaskDelayUntil
855  * \ingroup TaskCtrl
856  */
857 BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
858                             const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
859
860 /*
861  * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
862  * return a value.
863  */
864 #define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement )           \
865     {                                                                   \
866         ( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \
867     }
868
869
870 /**
871  * task. h
872  * @code{c}
873  * BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
874  * @endcode
875  *
876  * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
877  * function to be available.
878  *
879  * A task will enter the Blocked state when it is waiting for an event.  The
880  * event it is waiting for can be a temporal event (waiting for a time), such
881  * as when vTaskDelay() is called, or an event on an object, such as when
882  * xQueueReceive() or ulTaskNotifyTake() is called.  If the handle of a task
883  * that is in the Blocked state is used in a call to xTaskAbortDelay() then the
884  * task will leave the Blocked state, and return from whichever function call
885  * placed the task into the Blocked state.
886  *
887  * There is no 'FromISR' version of this function as an interrupt would need to
888  * know which object a task was blocked on in order to know which actions to
889  * take.  For example, if the task was blocked on a queue the interrupt handler
890  * would then need to know if the queue was locked.
891  *
892  * @param xTask The handle of the task to remove from the Blocked state.
893  *
894  * @return If the task referenced by xTask was not in the Blocked state then
895  * pdFAIL is returned.  Otherwise pdPASS is returned.
896  *
897  * \defgroup xTaskAbortDelay xTaskAbortDelay
898  * \ingroup TaskCtrl
899  */
900 BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
901
902 /**
903  * task. h
904  * @code{c}
905  * UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
906  * @endcode
907  *
908  * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
909  * See the configuration section for more information.
910  *
911  * Obtain the priority of any task.
912  *
913  * @param xTask Handle of the task to be queried.  Passing a NULL
914  * handle results in the priority of the calling task being returned.
915  *
916  * @return The priority of xTask.
917  *
918  * Example usage:
919  * @code{c}
920  * void vAFunction( void )
921  * {
922  * TaskHandle_t xHandle;
923  *
924  *   // Create a task, storing the handle.
925  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
926  *
927  *   // ...
928  *
929  *   // Use the handle to obtain the priority of the created task.
930  *   // It was created with tskIDLE_PRIORITY, but may have changed
931  *   // it itself.
932  *   if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
933  *   {
934  *       // The task has changed it's priority.
935  *   }
936  *
937  *   // ...
938  *
939  *   // Is our priority higher than the created task?
940  *   if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
941  *   {
942  *       // Our priority (obtained using NULL handle) is higher.
943  *   }
944  * }
945  * @endcode
946  * \defgroup uxTaskPriorityGet uxTaskPriorityGet
947  * \ingroup TaskCtrl
948  */
949 UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
950
951 /**
952  * task. h
953  * @code{c}
954  * UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
955  * @endcode
956  *
957  * A version of uxTaskPriorityGet() that can be used from an ISR.
958  */
959 UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
960
961 /**
962  * task. h
963  * @code{c}
964  * eTaskState eTaskGetState( TaskHandle_t xTask );
965  * @endcode
966  *
967  * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
968  * See the configuration section for more information.
969  *
970  * Obtain the state of any task.  States are encoded by the eTaskState
971  * enumerated type.
972  *
973  * @param xTask Handle of the task to be queried.
974  *
975  * @return The state of xTask at the time the function was called.  Note the
976  * state of the task might change between the function being called, and the
977  * functions return value being tested by the calling task.
978  */
979 eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
980
981 /**
982  * task. h
983  * @code{c}
984  * void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
985  * @endcode
986  *
987  * configUSE_TRACE_FACILITY must be defined as 1 for this function to be
988  * available.  See the configuration section for more information.
989  *
990  * Populates a TaskStatus_t structure with information about a task.
991  *
992  * @param xTask Handle of the task being queried.  If xTask is NULL then
993  * information will be returned about the calling task.
994  *
995  * @param pxTaskStatus A pointer to the TaskStatus_t structure that will be
996  * filled with information about the task referenced by the handle passed using
997  * the xTask parameter.
998  *
999  * @xGetFreeStackSpace The TaskStatus_t structure contains a member to report
1000  * the stack high water mark of the task being queried.  Calculating the stack
1001  * high water mark takes a relatively long time, and can make the system
1002  * temporarily unresponsive - so the xGetFreeStackSpace parameter is provided to
1003  * allow the high water mark checking to be skipped.  The high watermark value
1004  * will only be written to the TaskStatus_t structure if xGetFreeStackSpace is
1005  * not set to pdFALSE;
1006  *
1007  * @param eState The TaskStatus_t structure contains a member to report the
1008  * state of the task being queried.  Obtaining the task state is not as fast as
1009  * a simple assignment - so the eState parameter is provided to allow the state
1010  * information to be omitted from the TaskStatus_t structure.  To obtain state
1011  * information then set eState to eInvalid - otherwise the value passed in
1012  * eState will be reported as the task state in the TaskStatus_t structure.
1013  *
1014  * Example usage:
1015  * @code{c}
1016  * void vAFunction( void )
1017  * {
1018  * TaskHandle_t xHandle;
1019  * TaskStatus_t xTaskDetails;
1020  *
1021  *  // Obtain the handle of a task from its name.
1022  *  xHandle = xTaskGetHandle( "Task_Name" );
1023  *
1024  *  // Check the handle is not NULL.
1025  *  configASSERT( xHandle );
1026  *
1027  *  // Use the handle to obtain further information about the task.
1028  *  vTaskGetInfo( xHandle,
1029  *                &xTaskDetails,
1030  *                pdTRUE, // Include the high water mark in xTaskDetails.
1031  *                eInvalid ); // Include the task state in xTaskDetails.
1032  * }
1033  * @endcode
1034  * \defgroup vTaskGetInfo vTaskGetInfo
1035  * \ingroup TaskCtrl
1036  */
1037 void vTaskGetInfo( TaskHandle_t xTask,
1038                    TaskStatus_t * pxTaskStatus,
1039                    BaseType_t xGetFreeStackSpace,
1040                    eTaskState eState ) PRIVILEGED_FUNCTION;
1041
1042 /**
1043  * task. h
1044  * @code{c}
1045  * void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
1046  * @endcode
1047  *
1048  * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
1049  * See the configuration section for more information.
1050  *
1051  * Set the priority of any task.
1052  *
1053  * A context switch will occur before the function returns if the priority
1054  * being set is higher than the currently executing task.
1055  *
1056  * @param xTask Handle to the task for which the priority is being set.
1057  * Passing a NULL handle results in the priority of the calling task being set.
1058  *
1059  * @param uxNewPriority The priority to which the task will be set.
1060  *
1061  * Example usage:
1062  * @code{c}
1063  * void vAFunction( void )
1064  * {
1065  * TaskHandle_t xHandle;
1066  *
1067  *   // Create a task, storing the handle.
1068  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1069  *
1070  *   // ...
1071  *
1072  *   // Use the handle to raise the priority of the created task.
1073  *   vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
1074  *
1075  *   // ...
1076  *
1077  *   // Use a NULL handle to raise our priority to the same value.
1078  *   vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
1079  * }
1080  * @endcode
1081  * \defgroup vTaskPrioritySet vTaskPrioritySet
1082  * \ingroup TaskCtrl
1083  */
1084 void vTaskPrioritySet( TaskHandle_t xTask,
1085                        UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
1086
1087 /**
1088  * task. h
1089  * @code{c}
1090  * void vTaskSuspend( TaskHandle_t xTaskToSuspend );
1091  * @endcode
1092  *
1093  * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1094  * See the configuration section for more information.
1095  *
1096  * Suspend any task.  When suspended a task will never get any microcontroller
1097  * processing time, no matter what its priority.
1098  *
1099  * Calls to vTaskSuspend are not accumulative -
1100  * i.e. calling vTaskSuspend () twice on the same task still only requires one
1101  * call to vTaskResume () to ready the suspended task.
1102  *
1103  * @param xTaskToSuspend Handle to the task being suspended.  Passing a NULL
1104  * handle will cause the calling task to be suspended.
1105  *
1106  * Example usage:
1107  * @code{c}
1108  * void vAFunction( void )
1109  * {
1110  * TaskHandle_t xHandle;
1111  *
1112  *   // Create a task, storing the handle.
1113  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1114  *
1115  *   // ...
1116  *
1117  *   // Use the handle to suspend the created task.
1118  *   vTaskSuspend( xHandle );
1119  *
1120  *   // ...
1121  *
1122  *   // The created task will not run during this period, unless
1123  *   // another task calls vTaskResume( xHandle ).
1124  *
1125  *   //...
1126  *
1127  *
1128  *   // Suspend ourselves.
1129  *   vTaskSuspend( NULL );
1130  *
1131  *   // We cannot get here unless another task calls vTaskResume
1132  *   // with our handle as the parameter.
1133  * }
1134  * @endcode
1135  * \defgroup vTaskSuspend vTaskSuspend
1136  * \ingroup TaskCtrl
1137  */
1138 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
1139
1140 /**
1141  * task. h
1142  * @code{c}
1143  * void vTaskResume( TaskHandle_t xTaskToResume );
1144  * @endcode
1145  *
1146  * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
1147  * See the configuration section for more information.
1148  *
1149  * Resumes a suspended task.
1150  *
1151  * A task that has been suspended by one or more calls to vTaskSuspend ()
1152  * will be made available for running again by a single call to
1153  * vTaskResume ().
1154  *
1155  * @param xTaskToResume Handle to the task being readied.
1156  *
1157  * Example usage:
1158  * @code{c}
1159  * void vAFunction( void )
1160  * {
1161  * TaskHandle_t xHandle;
1162  *
1163  *   // Create a task, storing the handle.
1164  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
1165  *
1166  *   // ...
1167  *
1168  *   // Use the handle to suspend the created task.
1169  *   vTaskSuspend( xHandle );
1170  *
1171  *   // ...
1172  *
1173  *   // The created task will not run during this period, unless
1174  *   // another task calls vTaskResume( xHandle ).
1175  *
1176  *   //...
1177  *
1178  *
1179  *   // Resume the suspended task ourselves.
1180  *   vTaskResume( xHandle );
1181  *
1182  *   // The created task will once again get microcontroller processing
1183  *   // time in accordance with its priority within the system.
1184  * }
1185  * @endcode
1186  * \defgroup vTaskResume vTaskResume
1187  * \ingroup TaskCtrl
1188  */
1189 void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1190
1191 /**
1192  * task. h
1193  * @code{c}
1194  * void xTaskResumeFromISR( TaskHandle_t xTaskToResume );
1195  * @endcode
1196  *
1197  * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
1198  * available.  See the configuration section for more information.
1199  *
1200  * An implementation of vTaskResume() that can be called from within an ISR.
1201  *
1202  * A task that has been suspended by one or more calls to vTaskSuspend ()
1203  * will be made available for running again by a single call to
1204  * xTaskResumeFromISR ().
1205  *
1206  * xTaskResumeFromISR() should not be used to synchronise a task with an
1207  * interrupt if there is a chance that the interrupt could arrive prior to the
1208  * task being suspended - as this can lead to interrupts being missed. Use of a
1209  * semaphore as a synchronisation mechanism would avoid this eventuality.
1210  *
1211  * @param xTaskToResume Handle to the task being readied.
1212  *
1213  * @return pdTRUE if resuming the task should result in a context switch,
1214  * otherwise pdFALSE. This is used by the ISR to determine if a context switch
1215  * may be required following the ISR.
1216  *
1217  * \defgroup vTaskResumeFromISR vTaskResumeFromISR
1218  * \ingroup TaskCtrl
1219  */
1220 BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1221
1222 /*-----------------------------------------------------------
1223 * SCHEDULER CONTROL
1224 *----------------------------------------------------------*/
1225
1226 /**
1227  * task. h
1228  * @code{c}
1229  * void vTaskStartScheduler( void );
1230  * @endcode
1231  *
1232  * Starts the real time kernel tick processing.  After calling the kernel
1233  * has control over which tasks are executed and when.
1234  *
1235  * See the demo application file main.c for an example of creating
1236  * tasks and starting the kernel.
1237  *
1238  * Example usage:
1239  * @code{c}
1240  * void vAFunction( void )
1241  * {
1242  *   // Create at least one task before starting the kernel.
1243  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1244  *
1245  *   // Start the real time kernel with preemption.
1246  *   vTaskStartScheduler ();
1247  *
1248  *   // Will not get here unless a task calls vTaskEndScheduler ()
1249  * }
1250  * @endcode
1251  *
1252  * \defgroup vTaskStartScheduler vTaskStartScheduler
1253  * \ingroup SchedulerControl
1254  */
1255 void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
1256
1257 /**
1258  * task. h
1259  * @code{c}
1260  * void vTaskEndScheduler( void );
1261  * @endcode
1262  *
1263  * NOTE:  At the time of writing only the x86 real mode port, which runs on a PC
1264  * in place of DOS, implements this function.
1265  *
1266  * Stops the real time kernel tick.  All created tasks will be automatically
1267  * deleted and multitasking (either preemptive or cooperative) will
1268  * stop.  Execution then resumes from the point where vTaskStartScheduler ()
1269  * was called, as if vTaskStartScheduler () had just returned.
1270  *
1271  * See the demo application file main. c in the demo/PC directory for an
1272  * example that uses vTaskEndScheduler ().
1273  *
1274  * vTaskEndScheduler () requires an exit function to be defined within the
1275  * portable layer (see vPortEndScheduler () in port. c for the PC port).  This
1276  * performs hardware specific operations such as stopping the kernel tick.
1277  *
1278  * vTaskEndScheduler () will cause all of the resources allocated by the
1279  * kernel to be freed - but will not free resources allocated by application
1280  * tasks.
1281  *
1282  * Example usage:
1283  * @code{c}
1284  * void vTaskCode( void * pvParameters )
1285  * {
1286  *   for( ;; )
1287  *   {
1288  *       // Task code goes here.
1289  *
1290  *       // At some point we want to end the real time kernel processing
1291  *       // so call ...
1292  *       vTaskEndScheduler ();
1293  *   }
1294  * }
1295  *
1296  * void vAFunction( void )
1297  * {
1298  *   // Create at least one task before starting the kernel.
1299  *   xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
1300  *
1301  *   // Start the real time kernel with preemption.
1302  *   vTaskStartScheduler ();
1303  *
1304  *   // Will only get here when the vTaskCode () task has called
1305  *   // vTaskEndScheduler ().  When we get here we are back to single task
1306  *   // execution.
1307  * }
1308  * @endcode
1309  *
1310  * \defgroup vTaskEndScheduler vTaskEndScheduler
1311  * \ingroup SchedulerControl
1312  */
1313 void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
1314
1315 /**
1316  * task. h
1317  * @code{c}
1318  * void vTaskSuspendAll( void );
1319  * @endcode
1320  *
1321  * Suspends the scheduler without disabling interrupts.  Context switches will
1322  * not occur while the scheduler is suspended.
1323  *
1324  * After calling vTaskSuspendAll () the calling task will continue to execute
1325  * without risk of being swapped out until a call to xTaskResumeAll () has been
1326  * made.
1327  *
1328  * API functions that have the potential to cause a context switch (for example,
1329  * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
1330  * is suspended.
1331  *
1332  * Example usage:
1333  * @code{c}
1334  * void vTask1( void * pvParameters )
1335  * {
1336  *   for( ;; )
1337  *   {
1338  *       // Task code goes here.
1339  *
1340  *       // ...
1341  *
1342  *       // At some point the task wants to perform a long operation during
1343  *       // which it does not want to get swapped out.  It cannot use
1344  *       // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1345  *       // operation may cause interrupts to be missed - including the
1346  *       // ticks.
1347  *
1348  *       // Prevent the real time kernel swapping out the task.
1349  *       vTaskSuspendAll ();
1350  *
1351  *       // Perform the operation here.  There is no need to use critical
1352  *       // sections as we have all the microcontroller processing time.
1353  *       // During this time interrupts will still operate and the kernel
1354  *       // tick count will be maintained.
1355  *
1356  *       // ...
1357  *
1358  *       // The operation is complete.  Restart the kernel.
1359  *       xTaskResumeAll ();
1360  *   }
1361  * }
1362  * @endcode
1363  * \defgroup vTaskSuspendAll vTaskSuspendAll
1364  * \ingroup SchedulerControl
1365  */
1366 void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
1367
1368 /**
1369  * task. h
1370  * @code{c}
1371  * BaseType_t xTaskResumeAll( void );
1372  * @endcode
1373  *
1374  * Resumes scheduler activity after it was suspended by a call to
1375  * vTaskSuspendAll().
1376  *
1377  * xTaskResumeAll() only resumes the scheduler.  It does not unsuspend tasks
1378  * that were previously suspended by a call to vTaskSuspend().
1379  *
1380  * @return If resuming the scheduler caused a context switch then pdTRUE is
1381  *         returned, otherwise pdFALSE is returned.
1382  *
1383  * Example usage:
1384  * @code{c}
1385  * void vTask1( void * pvParameters )
1386  * {
1387  *   for( ;; )
1388  *   {
1389  *       // Task code goes here.
1390  *
1391  *       // ...
1392  *
1393  *       // At some point the task wants to perform a long operation during
1394  *       // which it does not want to get swapped out.  It cannot use
1395  *       // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
1396  *       // operation may cause interrupts to be missed - including the
1397  *       // ticks.
1398  *
1399  *       // Prevent the real time kernel swapping out the task.
1400  *       vTaskSuspendAll ();
1401  *
1402  *       // Perform the operation here.  There is no need to use critical
1403  *       // sections as we have all the microcontroller processing time.
1404  *       // During this time interrupts will still operate and the real
1405  *       // time kernel tick count will be maintained.
1406  *
1407  *       // ...
1408  *
1409  *       // The operation is complete.  Restart the kernel.  We want to force
1410  *       // a context switch - but there is no point if resuming the scheduler
1411  *       // caused a context switch already.
1412  *       if( !xTaskResumeAll () )
1413  *       {
1414  *            taskYIELD ();
1415  *       }
1416  *   }
1417  * }
1418  * @endcode
1419  * \defgroup xTaskResumeAll xTaskResumeAll
1420  * \ingroup SchedulerControl
1421  */
1422 BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
1423
1424 /*-----------------------------------------------------------
1425 * TASK UTILITIES
1426 *----------------------------------------------------------*/
1427
1428 /**
1429  * task. h
1430  * @code{c}
1431  * TickType_t xTaskGetTickCount( void );
1432  * @endcode
1433  *
1434  * @return The count of ticks since vTaskStartScheduler was called.
1435  *
1436  * \defgroup xTaskGetTickCount xTaskGetTickCount
1437  * \ingroup TaskUtils
1438  */
1439 TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
1440
1441 /**
1442  * task. h
1443  * @code{c}
1444  * TickType_t xTaskGetTickCountFromISR( void );
1445  * @endcode
1446  *
1447  * @return The count of ticks since vTaskStartScheduler was called.
1448  *
1449  * This is a version of xTaskGetTickCount() that is safe to be called from an
1450  * ISR - provided that TickType_t is the natural word size of the
1451  * microcontroller being used or interrupt nesting is either not supported or
1452  * not being used.
1453  *
1454  * \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
1455  * \ingroup TaskUtils
1456  */
1457 TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
1458
1459 /**
1460  * task. h
1461  * @code{c}
1462  * uint16_t uxTaskGetNumberOfTasks( void );
1463  * @endcode
1464  *
1465  * @return The number of tasks that the real time kernel is currently managing.
1466  * This includes all ready, blocked and suspended tasks.  A task that
1467  * has been deleted but not yet freed by the idle task will also be
1468  * included in the count.
1469  *
1470  * \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
1471  * \ingroup TaskUtils
1472  */
1473 UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
1474
1475 /**
1476  * task. h
1477  * @code{c}
1478  * char *pcTaskGetName( TaskHandle_t xTaskToQuery );
1479  * @endcode
1480  *
1481  * @return The text (human readable) name of the task referenced by the handle
1482  * xTaskToQuery.  A task can query its own name by either passing in its own
1483  * handle, or by setting xTaskToQuery to NULL.
1484  *
1485  * \defgroup pcTaskGetName pcTaskGetName
1486  * \ingroup TaskUtils
1487  */
1488 char * pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1489
1490 /**
1491  * task. h
1492  * @code{c}
1493  * TaskHandle_t xTaskGetHandle( const char *pcNameToQuery );
1494  * @endcode
1495  *
1496  * NOTE:  This function takes a relatively long time to complete and should be
1497  * used sparingly.
1498  *
1499  * @return The handle of the task that has the human readable name pcNameToQuery.
1500  * NULL is returned if no matching name is found.  INCLUDE_xTaskGetHandle
1501  * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
1502  *
1503  * \defgroup pcTaskGetHandle pcTaskGetHandle
1504  * \ingroup TaskUtils
1505  */
1506 TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1507
1508 /**
1509  * task.h
1510  * @code{c}
1511  * UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );
1512  * @endcode
1513  *
1514  * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for
1515  * this function to be available.
1516  *
1517  * Returns the high water mark of the stack associated with xTask.  That is,
1518  * the minimum free stack space there has been (in words, so on a 32 bit machine
1519  * a value of 1 means 4 bytes) since the task started.  The smaller the returned
1520  * number the closer the task has come to overflowing its stack.
1521  *
1522  * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1523  * same except for their return type.  Using configSTACK_DEPTH_TYPE allows the
1524  * user to determine the return type.  It gets around the problem of the value
1525  * overflowing on 8-bit types without breaking backward compatibility for
1526  * applications that expect an 8-bit return type.
1527  *
1528  * @param xTask Handle of the task associated with the stack to be checked.
1529  * Set xTask to NULL to check the stack of the calling task.
1530  *
1531  * @return The smallest amount of free stack space there has been (in words, so
1532  * actual spaces on the stack rather than bytes) since the task referenced by
1533  * xTask was created.
1534  */
1535 UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1536
1537 /**
1538  * task.h
1539  * @code{c}
1540  * configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );
1541  * @endcode
1542  *
1543  * INCLUDE_uxTaskGetStackHighWaterMark2 must be set to 1 in FreeRTOSConfig.h for
1544  * this function to be available.
1545  *
1546  * Returns the high water mark of the stack associated with xTask.  That is,
1547  * the minimum free stack space there has been (in words, so on a 32 bit machine
1548  * a value of 1 means 4 bytes) since the task started.  The smaller the returned
1549  * number the closer the task has come to overflowing its stack.
1550  *
1551  * uxTaskGetStackHighWaterMark() and uxTaskGetStackHighWaterMark2() are the
1552  * same except for their return type.  Using configSTACK_DEPTH_TYPE allows the
1553  * user to determine the return type.  It gets around the problem of the value
1554  * overflowing on 8-bit types without breaking backward compatibility for
1555  * applications that expect an 8-bit return type.
1556  *
1557  * @param xTask Handle of the task associated with the stack to be checked.
1558  * Set xTask to NULL to check the stack of the calling task.
1559  *
1560  * @return The smallest amount of free stack space there has been (in words, so
1561  * actual spaces on the stack rather than bytes) since the task referenced by
1562  * xTask was created.
1563  */
1564 configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1565
1566 /* When using trace macros it is sometimes necessary to include task.h before
1567  * FreeRTOS.h.  When this is done TaskHookFunction_t will not yet have been defined,
1568  * so the following two prototypes will cause a compilation error.  This can be
1569  * fixed by simply guarding against the inclusion of these two prototypes unless
1570  * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
1571  * constant. */
1572 #ifdef configUSE_APPLICATION_TASK_TAG
1573     #if configUSE_APPLICATION_TASK_TAG == 1
1574
1575 /**
1576  * task.h
1577  * @code{c}
1578  * void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
1579  * @endcode
1580  *
1581  * Sets pxHookFunction to be the task hook function used by the task xTask.
1582  * Passing xTask as NULL has the effect of setting the calling tasks hook
1583  * function.
1584  */
1585         void vTaskSetApplicationTaskTag( TaskHandle_t xTask,
1586                                          TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
1587
1588 /**
1589  * task.h
1590  * @code{c}
1591  * void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
1592  * @endcode
1593  *
1594  * Returns the pxHookFunction value assigned to the task xTask.  Do not
1595  * call from an interrupt service routine - call
1596  * xTaskGetApplicationTaskTagFromISR() instead.
1597  */
1598         TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1599
1600 /**
1601  * task.h
1602  * @code{c}
1603  * void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
1604  * @endcode
1605  *
1606  * Returns the pxHookFunction value assigned to the task xTask.  Can
1607  * be called from an interrupt service routine.
1608  */
1609         TaskHookFunction_t xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1610     #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
1611 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
1612
1613 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
1614
1615 /* Each task contains an array of pointers that is dimensioned by the
1616  * configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h.  The
1617  * kernel does not use the pointers itself, so the application writer can use
1618  * the pointers for any purpose they wish.  The following two functions are
1619  * used to set and query a pointer respectively. */
1620     void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
1621                                             BaseType_t xIndex,
1622                                             void * pvValue ) PRIVILEGED_FUNCTION;
1623     void * pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
1624                                                BaseType_t xIndex ) PRIVILEGED_FUNCTION;
1625
1626 #endif
1627
1628 #if ( configCHECK_FOR_STACK_OVERFLOW > 0 )
1629
1630 /**
1631  * task.h
1632  * @code{c}
1633  * void vApplicationStackOverflowHook( TaskHandle_t xTask char *pcTaskName);
1634  * @endcode
1635  *
1636  * The application stack overflow hook is called when a stack overflow is detected for a task.
1637  *
1638  * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html
1639  *
1640  * @param xTask the task that just exceeded its stack boundaries.
1641  * @param pcTaskName A character string containing the name of the offending task.
1642  */
1643     void vApplicationStackOverflowHook( TaskHandle_t xTask,
1644                                         char * pcTaskName );
1645
1646 #endif
1647
1648 #if  ( configUSE_TICK_HOOK > 0 )
1649
1650 /**
1651  *  task.h
1652  * @code{c}
1653  * void vApplicationTickHook( void );
1654  * @endcode
1655  *
1656  * This hook function is called in the system tick handler after any OS work is completed.
1657  */
1658     void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
1659
1660 #endif
1661
1662 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1663
1664 /**
1665  * task.h
1666  * @code{c}
1667  * void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
1668  * @endcode
1669  *
1670  * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB.  This function is required when
1671  * configSUPPORT_STATIC_ALLOCATION is set.  For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
1672  *
1673  * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
1674  * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for the idle task
1675  * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
1676  */
1677     void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
1678                                         StackType_t ** ppxIdleTaskStackBuffer,
1679                                         uint32_t * pulIdleTaskStackSize ); /*lint !e526 Symbol not defined as it is an application callback. */
1680 #endif
1681
1682 /**
1683  * task.h
1684  * @code{c}
1685  * BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
1686  * @endcode
1687  *
1688  * Calls the hook function associated with xTask.  Passing xTask as NULL has
1689  * the effect of calling the Running tasks (the calling task) hook function.
1690  *
1691  * pvParameter is passed to the hook function for the task to interpret as it
1692  * wants.  The return value is the value returned by the task hook function
1693  * registered by the user.
1694  */
1695 BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
1696                                          void * pvParameter ) PRIVILEGED_FUNCTION;
1697
1698 /**
1699  * xTaskGetIdleTaskHandle() is only available if
1700  * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.
1701  *
1702  * Simply returns the handle of the idle task.  It is not valid to call
1703  * xTaskGetIdleTaskHandle() before the scheduler has been started.
1704  */
1705 TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
1706
1707 /**
1708  * configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for
1709  * uxTaskGetSystemState() to be available.
1710  *
1711  * uxTaskGetSystemState() populates an TaskStatus_t structure for each task in
1712  * the system.  TaskStatus_t structures contain, among other things, members
1713  * for the task handle, task name, task priority, task state, and total amount
1714  * of run time consumed by the task.  See the TaskStatus_t structure
1715  * definition in this file for the full member list.
1716  *
1717  * NOTE:  This function is intended for debugging use only as its use results in
1718  * the scheduler remaining suspended for an extended period.
1719  *
1720  * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
1721  * The array must contain at least one TaskStatus_t structure for each task
1722  * that is under the control of the RTOS.  The number of tasks under the control
1723  * of the RTOS can be determined using the uxTaskGetNumberOfTasks() API function.
1724  *
1725  * @param uxArraySize The size of the array pointed to by the pxTaskStatusArray
1726  * parameter.  The size is specified as the number of indexes in the array, or
1727  * the number of TaskStatus_t structures contained in the array, not by the
1728  * number of bytes in the array.
1729  *
1730  * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
1731  * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
1732  * total run time (as defined by the run time stats clock, see
1733  * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted.
1734  * pulTotalRunTime can be set to NULL to omit the total run time information.
1735  *
1736  * @return The number of TaskStatus_t structures that were populated by
1737  * uxTaskGetSystemState().  This should equal the number returned by the
1738  * uxTaskGetNumberOfTasks() API function, but will be zero if the value passed
1739  * in the uxArraySize parameter was too small.
1740  *
1741  * Example usage:
1742  * @code{c}
1743  *  // This example demonstrates how a human readable table of run time stats
1744  *  // information is generated from raw data provided by uxTaskGetSystemState().
1745  *  // The human readable table is written to pcWriteBuffer
1746  *  void vTaskGetRunTimeStats( char *pcWriteBuffer )
1747  *  {
1748  *  TaskStatus_t *pxTaskStatusArray;
1749  *  volatile UBaseType_t uxArraySize, x;
1750  *  configRUN_TIME_COUNTER_TYPE ulTotalRunTime, ulStatsAsPercentage;
1751  *
1752  *      // Make sure the write buffer does not contain a string.
1753  * pcWriteBuffer = 0x00;
1754  *
1755  *      // Take a snapshot of the number of tasks in case it changes while this
1756  *      // function is executing.
1757  *      uxArraySize = uxTaskGetNumberOfTasks();
1758  *
1759  *      // Allocate a TaskStatus_t structure for each task.  An array could be
1760  *      // allocated statically at compile time.
1761  *      pxTaskStatusArray = pvPortMalloc( uxArraySize * sizeof( TaskStatus_t ) );
1762  *
1763  *      if( pxTaskStatusArray != NULL )
1764  *      {
1765  *          // Generate raw status information about each task.
1766  *          uxArraySize = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, &ulTotalRunTime );
1767  *
1768  *          // For percentage calculations.
1769  *          ulTotalRunTime /= 100UL;
1770  *
1771  *          // Avoid divide by zero errors.
1772  *          if( ulTotalRunTime > 0 )
1773  *          {
1774  *              // For each populated position in the pxTaskStatusArray array,
1775  *              // format the raw data as human readable ASCII data
1776  *              for( x = 0; x < uxArraySize; x++ )
1777  *              {
1778  *                  // What percentage of the total run time has the task used?
1779  *                  // This will always be rounded down to the nearest integer.
1780  *                  // ulTotalRunTimeDiv100 has already been divided by 100.
1781  *                  ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalRunTime;
1782  *
1783  *                  if( ulStatsAsPercentage > 0UL )
1784  *                  {
1785  *                      sprintf( pcWriteBuffer, "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
1786  *                  }
1787  *                  else
1788  *                  {
1789  *                      // If the percentage is zero here then the task has
1790  *                      // consumed less than 1% of the total run time.
1791  *                      sprintf( pcWriteBuffer, "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );
1792  *                  }
1793  *
1794  *                  pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );
1795  *              }
1796  *          }
1797  *
1798  *          // The array is no longer needed, free the memory it consumes.
1799  *          vPortFree( pxTaskStatusArray );
1800  *      }
1801  *  }
1802  *  @endcode
1803  */
1804 UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
1805                                   const UBaseType_t uxArraySize,
1806                                   configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
1807
1808 /**
1809  * task. h
1810  * @code{c}
1811  * void vTaskList( char *pcWriteBuffer );
1812  * @endcode
1813  *
1814  * configUSE_TRACE_FACILITY and configUSE_STATS_FORMATTING_FUNCTIONS must
1815  * both be defined as 1 for this function to be available.  See the
1816  * configuration section of the FreeRTOS.org website for more information.
1817  *
1818  * NOTE 1: This function will disable interrupts for its duration.  It is
1819  * not intended for normal application runtime use but as a debug aid.
1820  *
1821  * Lists all the current tasks, along with their current state and stack
1822  * usage high water mark.
1823  *
1824  * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
1825  * suspended ('S').
1826  *
1827  * PLEASE NOTE:
1828  *
1829  * This function is provided for convenience only, and is used by many of the
1830  * demo applications.  Do not consider it to be part of the scheduler.
1831  *
1832  * vTaskList() calls uxTaskGetSystemState(), then formats part of the
1833  * uxTaskGetSystemState() output into a human readable table that displays task:
1834  * names, states, priority, stack usage and task number.
1835  * Stack usage specified as the number of unused StackType_t words stack can hold
1836  * on top of stack - not the number of bytes.
1837  *
1838  * vTaskList() has a dependency on the sprintf() C library function that might
1839  * bloat the code size, use a lot of stack, and provide different results on
1840  * different platforms.  An alternative, tiny, third party, and limited
1841  * functionality implementation of sprintf() is provided in many of the
1842  * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
1843  * printf-stdarg.c does not provide a full snprintf() implementation!).
1844  *
1845  * It is recommended that production systems call uxTaskGetSystemState()
1846  * directly to get access to raw stats data, rather than indirectly through a
1847  * call to vTaskList().
1848  *
1849  * @param pcWriteBuffer A buffer into which the above mentioned details
1850  * will be written, in ASCII form.  This buffer is assumed to be large
1851  * enough to contain the generated report.  Approximately 40 bytes per
1852  * task should be sufficient.
1853  *
1854  * \defgroup vTaskList vTaskList
1855  * \ingroup TaskUtils
1856  */
1857 void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1858
1859 /**
1860  * task. h
1861  * @code{c}
1862  * void vTaskGetRunTimeStats( char *pcWriteBuffer );
1863  * @endcode
1864  *
1865  * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
1866  * must both be defined as 1 for this function to be available.  The application
1867  * must also then provide definitions for
1868  * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
1869  * to configure a peripheral timer/counter and return the timers current count
1870  * value respectively.  The counter should be at least 10 times the frequency of
1871  * the tick count.
1872  *
1873  * NOTE 1: This function will disable interrupts for its duration.  It is
1874  * not intended for normal application runtime use but as a debug aid.
1875  *
1876  * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
1877  * accumulated execution time being stored for each task.  The resolution
1878  * of the accumulated time value depends on the frequency of the timer
1879  * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
1880  * Calling vTaskGetRunTimeStats() writes the total execution time of each
1881  * task into a buffer, both as an absolute count value and as a percentage
1882  * of the total system execution time.
1883  *
1884  * NOTE 2:
1885  *
1886  * This function is provided for convenience only, and is used by many of the
1887  * demo applications.  Do not consider it to be part of the scheduler.
1888  *
1889  * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
1890  * uxTaskGetSystemState() output into a human readable table that displays the
1891  * amount of time each task has spent in the Running state in both absolute and
1892  * percentage terms.
1893  *
1894  * vTaskGetRunTimeStats() has a dependency on the sprintf() C library function
1895  * that might bloat the code size, use a lot of stack, and provide different
1896  * results on different platforms.  An alternative, tiny, third party, and
1897  * limited functionality implementation of sprintf() is provided in many of the
1898  * FreeRTOS/Demo sub-directories in a file called printf-stdarg.c (note
1899  * printf-stdarg.c does not provide a full snprintf() implementation!).
1900  *
1901  * It is recommended that production systems call uxTaskGetSystemState() directly
1902  * to get access to raw stats data, rather than indirectly through a call to
1903  * vTaskGetRunTimeStats().
1904  *
1905  * @param pcWriteBuffer A buffer into which the execution times will be
1906  * written, in ASCII form.  This buffer is assumed to be large enough to
1907  * contain the generated report.  Approximately 40 bytes per task should
1908  * be sufficient.
1909  *
1910  * \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
1911  * \ingroup TaskUtils
1912  */
1913 void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1914
1915 /**
1916  * task. h
1917  * @code{c}
1918  * configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void );
1919  * configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void );
1920  * @endcode
1921  *
1922  * configGENERATE_RUN_TIME_STATS, configUSE_STATS_FORMATTING_FUNCTIONS and
1923  * INCLUDE_xTaskGetIdleTaskHandle must all be defined as 1 for these functions
1924  * to be available.  The application must also then provide definitions for
1925  * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
1926  * to configure a peripheral timer/counter and return the timers current count
1927  * value respectively.  The counter should be at least 10 times the frequency of
1928  * the tick count.
1929  *
1930  * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
1931  * accumulated execution time being stored for each task.  The resolution
1932  * of the accumulated time value depends on the frequency of the timer
1933  * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
1934  * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
1935  * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()
1936  * returns the total execution time of just the idle task and
1937  * ulTaskGetIdleRunTimePercent() returns the percentage of the CPU time used by
1938  * just the idle task.
1939  *
1940  * Note the amount of idle time is only a good measure of the slack time in a
1941  * system if there are no other tasks executing at the idle priority, tickless
1942  * idle is not used, and configIDLE_SHOULD_YIELD is set to 0.
1943  *
1944  * @return The total run time of the idle task or the percentage of the total
1945  * run time consumed by the idle task.  This is the amount of time the
1946  * idle task has actually been executing.  The unit of time is dependent on the
1947  * frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
1948  * portGET_RUN_TIME_COUNTER_VALUE() macros.
1949  *
1950  * \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
1951  * \ingroup TaskUtils
1952  */
1953 configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
1954 configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimePercent( void ) PRIVILEGED_FUNCTION;
1955
1956 /**
1957  * task. h
1958  * @code{c}
1959  * BaseType_t xTaskNotifyIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction );
1960  * BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );
1961  * @endcode
1962  *
1963  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
1964  *
1965  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
1966  * functions to be available.
1967  *
1968  * Sends a direct to task notification to a task, with an optional value and
1969  * action.
1970  *
1971  * Each task has a private array of "notification values" (or 'notifications'),
1972  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
1973  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
1974  * array, and (for backward compatibility) defaults to 1 if left undefined.
1975  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
1976  *
1977  * Events can be sent to a task using an intermediary object.  Examples of such
1978  * objects are queues, semaphores, mutexes and event groups.  Task notifications
1979  * are a method of sending an event directly to a task without the need for such
1980  * an intermediary object.
1981  *
1982  * A notification sent to a task can optionally perform an action, such as
1983  * update, overwrite or increment one of the task's notification values.  In
1984  * that way task notifications can be used to send data to a task, or be used as
1985  * light weight and fast binary or counting semaphores.
1986  *
1987  * A task can use xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() to
1988  * [optionally] block to wait for a notification to be pending.  The task does
1989  * not consume any CPU time while it is in the Blocked state.
1990  *
1991  * A notification sent to a task will remain pending until it is cleared by the
1992  * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
1993  * un-indexed equivalents).  If the task was already in the Blocked state to
1994  * wait for a notification when the notification arrives then the task will
1995  * automatically be removed from the Blocked state (unblocked) and the
1996  * notification cleared.
1997  *
1998  * **NOTE** Each notification within the array operates independently - a task
1999  * can only block on one notification within the array at a time and will not be
2000  * unblocked by a notification sent to any other array index.
2001  *
2002  * Backward compatibility information:
2003  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2004  * all task notification API functions operated on that value. Replacing the
2005  * single notification value with an array of notification values necessitated a
2006  * new set of API functions that could address specific notifications within the
2007  * array.  xTaskNotify() is the original API function, and remains backward
2008  * compatible by always operating on the notification value at index 0 in the
2009  * array. Calling xTaskNotify() is equivalent to calling xTaskNotifyIndexed()
2010  * with the uxIndexToNotify parameter set to 0.
2011  *
2012  * @param xTaskToNotify The handle of the task being notified.  The handle to a
2013  * task can be returned from the xTaskCreate() API function used to create the
2014  * task, and the handle of the currently running task can be obtained by calling
2015  * xTaskGetCurrentTaskHandle().
2016  *
2017  * @param uxIndexToNotify The index within the target task's array of
2018  * notification values to which the notification is to be sent.  uxIndexToNotify
2019  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotify() does
2020  * not have this parameter and always sends notifications to index 0.
2021  *
2022  * @param ulValue Data that can be sent with the notification.  How the data is
2023  * used depends on the value of the eAction parameter.
2024  *
2025  * @param eAction Specifies how the notification updates the task's notification
2026  * value, if at all.  Valid values for eAction are as follows:
2027  *
2028  * eSetBits -
2029  * The target notification value is bitwise ORed with ulValue.
2030  * xTaskNotifyIndexed() always returns pdPASS in this case.
2031  *
2032  * eIncrement -
2033  * The target notification value is incremented.  ulValue is not used and
2034  * xTaskNotifyIndexed() always returns pdPASS in this case.
2035  *
2036  * eSetValueWithOverwrite -
2037  * The target notification value is set to the value of ulValue, even if the
2038  * task being notified had not yet processed the previous notification at the
2039  * same array index (the task already had a notification pending at that index).
2040  * xTaskNotifyIndexed() always returns pdPASS in this case.
2041  *
2042  * eSetValueWithoutOverwrite -
2043  * If the task being notified did not already have a notification pending at the
2044  * same array index then the target notification value is set to ulValue and
2045  * xTaskNotifyIndexed() will return pdPASS.  If the task being notified already
2046  * had a notification pending at the same array index then no action is
2047  * performed and pdFAIL is returned.
2048  *
2049  * eNoAction -
2050  * The task receives a notification at the specified array index without the
2051  * notification value at that index being updated.  ulValue is not used and
2052  * xTaskNotifyIndexed() always returns pdPASS in this case.
2053  *
2054  * pulPreviousNotificationValue -
2055  * Can be used to pass out the subject task's notification value before any
2056  * bits are modified by the notify function.
2057  *
2058  * @return Dependent on the value of eAction.  See the description of the
2059  * eAction parameter.
2060  *
2061  * \defgroup xTaskNotifyIndexed xTaskNotifyIndexed
2062  * \ingroup TaskNotifications
2063  */
2064 BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify,
2065                                UBaseType_t uxIndexToNotify,
2066                                uint32_t ulValue,
2067                                eNotifyAction eAction,
2068                                uint32_t * pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
2069 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) \
2070     xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL )
2071 #define xTaskNotifyIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction ) \
2072     xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL )
2073
2074 /**
2075  * task. h
2076  * @code{c}
2077  * BaseType_t xTaskNotifyAndQueryIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
2078  * BaseType_t xTaskNotifyAndQuery( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotifyValue );
2079  * @endcode
2080  *
2081  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2082  *
2083  * xTaskNotifyAndQueryIndexed() performs the same operation as
2084  * xTaskNotifyIndexed() with the addition that it also returns the subject
2085  * task's prior notification value (the notification value at the time the
2086  * function is called rather than when the function returns) in the additional
2087  * pulPreviousNotifyValue parameter.
2088  *
2089  * xTaskNotifyAndQuery() performs the same operation as xTaskNotify() with the
2090  * addition that it also returns the subject task's prior notification value
2091  * (the notification value as it was at the time the function is called, rather
2092  * than when the function returns) in the additional pulPreviousNotifyValue
2093  * parameter.
2094  *
2095  * \defgroup xTaskNotifyAndQueryIndexed xTaskNotifyAndQueryIndexed
2096  * \ingroup TaskNotifications
2097  */
2098 #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2099     xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2100 #define xTaskNotifyAndQueryIndexed( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotifyValue ) \
2101     xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
2102
2103 /**
2104  * task. h
2105  * @code{c}
2106  * BaseType_t xTaskNotifyIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
2107  * BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken );
2108  * @endcode
2109  *
2110  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2111  *
2112  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2113  * functions to be available.
2114  *
2115  * A version of xTaskNotifyIndexed() that can be used from an interrupt service
2116  * routine (ISR).
2117  *
2118  * Each task has a private array of "notification values" (or 'notifications'),
2119  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2120  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2121  * array, and (for backward compatibility) defaults to 1 if left undefined.
2122  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2123  *
2124  * Events can be sent to a task using an intermediary object.  Examples of such
2125  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2126  * are a method of sending an event directly to a task without the need for such
2127  * an intermediary object.
2128  *
2129  * A notification sent to a task can optionally perform an action, such as
2130  * update, overwrite or increment one of the task's notification values.  In
2131  * that way task notifications can be used to send data to a task, or be used as
2132  * light weight and fast binary or counting semaphores.
2133  *
2134  * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2135  * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2136  * to wait for a notification value to have a non-zero value.  The task does
2137  * not consume any CPU time while it is in the Blocked state.
2138  *
2139  * A notification sent to a task will remain pending until it is cleared by the
2140  * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2141  * un-indexed equivalents).  If the task was already in the Blocked state to
2142  * wait for a notification when the notification arrives then the task will
2143  * automatically be removed from the Blocked state (unblocked) and the
2144  * notification cleared.
2145  *
2146  * **NOTE** Each notification within the array operates independently - a task
2147  * can only block on one notification within the array at a time and will not be
2148  * unblocked by a notification sent to any other array index.
2149  *
2150  * Backward compatibility information:
2151  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2152  * all task notification API functions operated on that value. Replacing the
2153  * single notification value with an array of notification values necessitated a
2154  * new set of API functions that could address specific notifications within the
2155  * array.  xTaskNotifyFromISR() is the original API function, and remains
2156  * backward compatible by always operating on the notification value at index 0
2157  * within the array. Calling xTaskNotifyFromISR() is equivalent to calling
2158  * xTaskNotifyIndexedFromISR() with the uxIndexToNotify parameter set to 0.
2159  *
2160  * @param uxIndexToNotify The index within the target task's array of
2161  * notification values to which the notification is to be sent.  uxIndexToNotify
2162  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotifyFromISR()
2163  * does not have this parameter and always sends notifications to index 0.
2164  *
2165  * @param xTaskToNotify The handle of the task being notified.  The handle to a
2166  * task can be returned from the xTaskCreate() API function used to create the
2167  * task, and the handle of the currently running task can be obtained by calling
2168  * xTaskGetCurrentTaskHandle().
2169  *
2170  * @param ulValue Data that can be sent with the notification.  How the data is
2171  * used depends on the value of the eAction parameter.
2172  *
2173  * @param eAction Specifies how the notification updates the task's notification
2174  * value, if at all.  Valid values for eAction are as follows:
2175  *
2176  * eSetBits -
2177  * The task's notification value is bitwise ORed with ulValue.  xTaskNotify()
2178  * always returns pdPASS in this case.
2179  *
2180  * eIncrement -
2181  * The task's notification value is incremented.  ulValue is not used and
2182  * xTaskNotify() always returns pdPASS in this case.
2183  *
2184  * eSetValueWithOverwrite -
2185  * The task's notification value is set to the value of ulValue, even if the
2186  * task being notified had not yet processed the previous notification (the
2187  * task already had a notification pending).  xTaskNotify() always returns
2188  * pdPASS in this case.
2189  *
2190  * eSetValueWithoutOverwrite -
2191  * If the task being notified did not already have a notification pending then
2192  * the task's notification value is set to ulValue and xTaskNotify() will
2193  * return pdPASS.  If the task being notified already had a notification
2194  * pending then no action is performed and pdFAIL is returned.
2195  *
2196  * eNoAction -
2197  * The task receives a notification without its notification value being
2198  * updated.  ulValue is not used and xTaskNotify() always returns pdPASS in
2199  * this case.
2200  *
2201  * @param pxHigherPriorityTaskWoken  xTaskNotifyFromISR() will set
2202  * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
2203  * task to which the notification was sent to leave the Blocked state, and the
2204  * unblocked task has a priority higher than the currently running task.  If
2205  * xTaskNotifyFromISR() sets this value to pdTRUE then a context switch should
2206  * be requested before the interrupt is exited.  How a context switch is
2207  * requested from an ISR is dependent on the port - see the documentation page
2208  * for the port in use.
2209  *
2210  * @return Dependent on the value of eAction.  See the description of the
2211  * eAction parameter.
2212  *
2213  * \defgroup xTaskNotifyIndexedFromISR xTaskNotifyIndexedFromISR
2214  * \ingroup TaskNotifications
2215  */
2216 BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
2217                                       UBaseType_t uxIndexToNotify,
2218                                       uint32_t ulValue,
2219                                       eNotifyAction eAction,
2220                                       uint32_t * pulPreviousNotificationValue,
2221                                       BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
2222 #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2223     xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2224 #define xTaskNotifyIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) \
2225     xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
2226
2227 /**
2228  * task. h
2229  * @code{c}
2230  * BaseType_t xTaskNotifyAndQueryIndexedFromISR( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
2231  * BaseType_t xTaskNotifyAndQueryFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken );
2232  * @endcode
2233  *
2234  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2235  *
2236  * xTaskNotifyAndQueryIndexedFromISR() performs the same operation as
2237  * xTaskNotifyIndexedFromISR() with the addition that it also returns the
2238  * subject task's prior notification value (the notification value at the time
2239  * the function is called rather than at the time the function returns) in the
2240  * additional pulPreviousNotifyValue parameter.
2241  *
2242  * xTaskNotifyAndQueryFromISR() performs the same operation as
2243  * xTaskNotifyFromISR() with the addition that it also returns the subject
2244  * task's prior notification value (the notification value at the time the
2245  * function is called rather than at the time the function returns) in the
2246  * additional pulPreviousNotifyValue parameter.
2247  *
2248  * \defgroup xTaskNotifyAndQueryIndexedFromISR xTaskNotifyAndQueryIndexedFromISR
2249  * \ingroup TaskNotifications
2250  */
2251 #define xTaskNotifyAndQueryIndexedFromISR( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2252     xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2253 #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) \
2254     xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
2255
2256 /**
2257  * task. h
2258  * @code{c}
2259  * BaseType_t xTaskNotifyWaitIndexed( UBaseType_t uxIndexToWaitOn, uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2260  *
2261  * BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait );
2262  * @endcode
2263  *
2264  * Waits for a direct to task notification to be pending at a given index within
2265  * an array of direct to task notifications.
2266  *
2267  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2268  *
2269  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
2270  * function to be available.
2271  *
2272  * Each task has a private array of "notification values" (or 'notifications'),
2273  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2274  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2275  * array, and (for backward compatibility) defaults to 1 if left undefined.
2276  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2277  *
2278  * Events can be sent to a task using an intermediary object.  Examples of such
2279  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2280  * are a method of sending an event directly to a task without the need for such
2281  * an intermediary object.
2282  *
2283  * A notification sent to a task can optionally perform an action, such as
2284  * update, overwrite or increment one of the task's notification values.  In
2285  * that way task notifications can be used to send data to a task, or be used as
2286  * light weight and fast binary or counting semaphores.
2287  *
2288  * A notification sent to a task will remain pending until it is cleared by the
2289  * task calling xTaskNotifyWaitIndexed() or ulTaskNotifyTakeIndexed() (or their
2290  * un-indexed equivalents).  If the task was already in the Blocked state to
2291  * wait for a notification when the notification arrives then the task will
2292  * automatically be removed from the Blocked state (unblocked) and the
2293  * notification cleared.
2294  *
2295  * A task can use xTaskNotifyWaitIndexed() to [optionally] block to wait for a
2296  * notification to be pending, or ulTaskNotifyTakeIndexed() to [optionally] block
2297  * to wait for a notification value to have a non-zero value.  The task does
2298  * not consume any CPU time while it is in the Blocked state.
2299  *
2300  * **NOTE** Each notification within the array operates independently - a task
2301  * can only block on one notification within the array at a time and will not be
2302  * unblocked by a notification sent to any other array index.
2303  *
2304  * Backward compatibility information:
2305  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2306  * all task notification API functions operated on that value. Replacing the
2307  * single notification value with an array of notification values necessitated a
2308  * new set of API functions that could address specific notifications within the
2309  * array.  xTaskNotifyWait() is the original API function, and remains backward
2310  * compatible by always operating on the notification value at index 0 in the
2311  * array. Calling xTaskNotifyWait() is equivalent to calling
2312  * xTaskNotifyWaitIndexed() with the uxIndexToWaitOn parameter set to 0.
2313  *
2314  * @param uxIndexToWaitOn The index within the calling task's array of
2315  * notification values on which the calling task will wait for a notification to
2316  * be received.  uxIndexToWaitOn must be less than
2317  * configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotifyWait() does
2318  * not have this parameter and always waits for notifications on index 0.
2319  *
2320  * @param ulBitsToClearOnEntry Bits that are set in ulBitsToClearOnEntry value
2321  * will be cleared in the calling task's notification value before the task
2322  * checks to see if any notifications are pending, and optionally blocks if no
2323  * notifications are pending.  Setting ulBitsToClearOnEntry to ULONG_MAX (if
2324  * limits.h is included) or 0xffffffffUL (if limits.h is not included) will have
2325  * the effect of resetting the task's notification value to 0.  Setting
2326  * ulBitsToClearOnEntry to 0 will leave the task's notification value unchanged.
2327  *
2328  * @param ulBitsToClearOnExit If a notification is pending or received before
2329  * the calling task exits the xTaskNotifyWait() function then the task's
2330  * notification value (see the xTaskNotify() API function) is passed out using
2331  * the pulNotificationValue parameter.  Then any bits that are set in
2332  * ulBitsToClearOnExit will be cleared in the task's notification value (note
2333  * *pulNotificationValue is set before any bits are cleared).  Setting
2334  * ulBitsToClearOnExit to ULONG_MAX (if limits.h is included) or 0xffffffffUL
2335  * (if limits.h is not included) will have the effect of resetting the task's
2336  * notification value to 0 before the function exits.  Setting
2337  * ulBitsToClearOnExit to 0 will leave the task's notification value unchanged
2338  * when the function exits (in which case the value passed out in
2339  * pulNotificationValue will match the task's notification value).
2340  *
2341  * @param pulNotificationValue Used to pass the task's notification value out
2342  * of the function.  Note the value passed out will not be effected by the
2343  * clearing of any bits caused by ulBitsToClearOnExit being non-zero.
2344  *
2345  * @param xTicksToWait The maximum amount of time that the task should wait in
2346  * the Blocked state for a notification to be received, should a notification
2347  * not already be pending when xTaskNotifyWait() was called.  The task
2348  * will not consume any processing time while it is in the Blocked state.  This
2349  * is specified in kernel ticks, the macro pdMS_TO_TICKS( value_in_ms ) can be
2350  * used to convert a time specified in milliseconds to a time specified in
2351  * ticks.
2352  *
2353  * @return If a notification was received (including notifications that were
2354  * already pending when xTaskNotifyWait was called) then pdPASS is
2355  * returned.  Otherwise pdFAIL is returned.
2356  *
2357  * \defgroup xTaskNotifyWaitIndexed xTaskNotifyWaitIndexed
2358  * \ingroup TaskNotifications
2359  */
2360 BaseType_t xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
2361                                    uint32_t ulBitsToClearOnEntry,
2362                                    uint32_t ulBitsToClearOnExit,
2363                                    uint32_t * pulNotificationValue,
2364                                    TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2365 #define xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2366     xTaskGenericNotifyWait( tskDEFAULT_INDEX_TO_NOTIFY, ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2367 #define xTaskNotifyWaitIndexed( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ) \
2368     xTaskGenericNotifyWait( ( uxIndexToWaitOn ), ( ulBitsToClearOnEntry ), ( ulBitsToClearOnExit ), ( pulNotificationValue ), ( xTicksToWait ) )
2369
2370 /**
2371  * task. h
2372  * @code{c}
2373  * BaseType_t xTaskNotifyGiveIndexed( TaskHandle_t xTaskToNotify, UBaseType_t uxIndexToNotify );
2374  * BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );
2375  * @endcode
2376  *
2377  * Sends a direct to task notification to a particular index in the target
2378  * task's notification array in a manner similar to giving a counting semaphore.
2379  *
2380  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
2381  *
2382  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2383  * macros to be available.
2384  *
2385  * Each task has a private array of "notification values" (or 'notifications'),
2386  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2387  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2388  * array, and (for backward compatibility) defaults to 1 if left undefined.
2389  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2390  *
2391  * Events can be sent to a task using an intermediary object.  Examples of such
2392  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2393  * are a method of sending an event directly to a task without the need for such
2394  * an intermediary object.
2395  *
2396  * A notification sent to a task can optionally perform an action, such as
2397  * update, overwrite or increment one of the task's notification values.  In
2398  * that way task notifications can be used to send data to a task, or be used as
2399  * light weight and fast binary or counting semaphores.
2400  *
2401  * xTaskNotifyGiveIndexed() is a helper macro intended for use when task
2402  * notifications are used as light weight and faster binary or counting
2403  * semaphore equivalents.  Actual FreeRTOS semaphores are given using the
2404  * xSemaphoreGive() API function, the equivalent action that instead uses a task
2405  * notification is xTaskNotifyGiveIndexed().
2406  *
2407  * When task notifications are being used as a binary or counting semaphore
2408  * equivalent then the task being notified should wait for the notification
2409  * using the ulTaskNotifyTakeIndexed() API function rather than the
2410  * xTaskNotifyWaitIndexed() API function.
2411  *
2412  * **NOTE** Each notification within the array operates independently - a task
2413  * can only block on one notification within the array at a time and will not be
2414  * unblocked by a notification sent to any other array index.
2415  *
2416  * Backward compatibility information:
2417  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2418  * all task notification API functions operated on that value. Replacing the
2419  * single notification value with an array of notification values necessitated a
2420  * new set of API functions that could address specific notifications within the
2421  * array.  xTaskNotifyGive() is the original API function, and remains backward
2422  * compatible by always operating on the notification value at index 0 in the
2423  * array. Calling xTaskNotifyGive() is equivalent to calling
2424  * xTaskNotifyGiveIndexed() with the uxIndexToNotify parameter set to 0.
2425  *
2426  * @param xTaskToNotify The handle of the task being notified.  The handle to a
2427  * task can be returned from the xTaskCreate() API function used to create the
2428  * task, and the handle of the currently running task can be obtained by calling
2429  * xTaskGetCurrentTaskHandle().
2430  *
2431  * @param uxIndexToNotify The index within the target task's array of
2432  * notification values to which the notification is to be sent.  uxIndexToNotify
2433  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotifyGive()
2434  * does not have this parameter and always sends notifications to index 0.
2435  *
2436  * @return xTaskNotifyGive() is a macro that calls xTaskNotify() with the
2437  * eAction parameter set to eIncrement - so pdPASS is always returned.
2438  *
2439  * \defgroup xTaskNotifyGiveIndexed xTaskNotifyGiveIndexed
2440  * \ingroup TaskNotifications
2441  */
2442 #define xTaskNotifyGive( xTaskToNotify ) \
2443     xTaskGenericNotify( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( 0 ), eIncrement, NULL )
2444 #define xTaskNotifyGiveIndexed( xTaskToNotify, uxIndexToNotify ) \
2445     xTaskGenericNotify( ( xTaskToNotify ), ( uxIndexToNotify ), ( 0 ), eIncrement, NULL )
2446
2447 /**
2448  * task. h
2449  * @code{c}
2450  * void vTaskNotifyGiveIndexedFromISR( TaskHandle_t xTaskHandle, UBaseType_t uxIndexToNotify, BaseType_t *pxHigherPriorityTaskWoken );
2451  * void vTaskNotifyGiveFromISR( TaskHandle_t xTaskHandle, BaseType_t *pxHigherPriorityTaskWoken );
2452  * @endcode
2453  *
2454  * A version of xTaskNotifyGiveIndexed() that can be called from an interrupt
2455  * service routine (ISR).
2456  *
2457  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for more details.
2458  *
2459  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this macro
2460  * to be available.
2461  *
2462  * Each task has a private array of "notification values" (or 'notifications'),
2463  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2464  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2465  * array, and (for backward compatibility) defaults to 1 if left undefined.
2466  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2467  *
2468  * Events can be sent to a task using an intermediary object.  Examples of such
2469  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2470  * are a method of sending an event directly to a task without the need for such
2471  * an intermediary object.
2472  *
2473  * A notification sent to a task can optionally perform an action, such as
2474  * update, overwrite or increment one of the task's notification values.  In
2475  * that way task notifications can be used to send data to a task, or be used as
2476  * light weight and fast binary or counting semaphores.
2477  *
2478  * vTaskNotifyGiveIndexedFromISR() is intended for use when task notifications
2479  * are used as light weight and faster binary or counting semaphore equivalents.
2480  * Actual FreeRTOS semaphores are given from an ISR using the
2481  * xSemaphoreGiveFromISR() API function, the equivalent action that instead uses
2482  * a task notification is vTaskNotifyGiveIndexedFromISR().
2483  *
2484  * When task notifications are being used as a binary or counting semaphore
2485  * equivalent then the task being notified should wait for the notification
2486  * using the ulTaskNotifyTakeIndexed() API function rather than the
2487  * xTaskNotifyWaitIndexed() API function.
2488  *
2489  * **NOTE** Each notification within the array operates independently - a task
2490  * can only block on one notification within the array at a time and will not be
2491  * unblocked by a notification sent to any other array index.
2492  *
2493  * Backward compatibility information:
2494  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2495  * all task notification API functions operated on that value. Replacing the
2496  * single notification value with an array of notification values necessitated a
2497  * new set of API functions that could address specific notifications within the
2498  * array.  xTaskNotifyFromISR() is the original API function, and remains
2499  * backward compatible by always operating on the notification value at index 0
2500  * within the array. Calling xTaskNotifyGiveFromISR() is equivalent to calling
2501  * xTaskNotifyGiveIndexedFromISR() with the uxIndexToNotify parameter set to 0.
2502  *
2503  * @param xTaskToNotify The handle of the task being notified.  The handle to a
2504  * task can be returned from the xTaskCreate() API function used to create the
2505  * task, and the handle of the currently running task can be obtained by calling
2506  * xTaskGetCurrentTaskHandle().
2507  *
2508  * @param uxIndexToNotify The index within the target task's array of
2509  * notification values to which the notification is to be sent.  uxIndexToNotify
2510  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2511  * xTaskNotifyGiveFromISR() does not have this parameter and always sends
2512  * notifications to index 0.
2513  *
2514  * @param pxHigherPriorityTaskWoken  vTaskNotifyGiveFromISR() will set
2515  * *pxHigherPriorityTaskWoken to pdTRUE if sending the notification caused the
2516  * task to which the notification was sent to leave the Blocked state, and the
2517  * unblocked task has a priority higher than the currently running task.  If
2518  * vTaskNotifyGiveFromISR() sets this value to pdTRUE then a context switch
2519  * should be requested before the interrupt is exited.  How a context switch is
2520  * requested from an ISR is dependent on the port - see the documentation page
2521  * for the port in use.
2522  *
2523  * \defgroup vTaskNotifyGiveIndexedFromISR vTaskNotifyGiveIndexedFromISR
2524  * \ingroup TaskNotifications
2525  */
2526 void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
2527                                     UBaseType_t uxIndexToNotify,
2528                                     BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
2529 #define vTaskNotifyGiveFromISR( xTaskToNotify, pxHigherPriorityTaskWoken ) \
2530     vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( pxHigherPriorityTaskWoken ) );
2531 #define vTaskNotifyGiveIndexedFromISR( xTaskToNotify, uxIndexToNotify, pxHigherPriorityTaskWoken ) \
2532     vTaskGenericNotifyGiveFromISR( ( xTaskToNotify ), ( uxIndexToNotify ), ( pxHigherPriorityTaskWoken ) );
2533
2534 /**
2535  * task. h
2536  * @code{c}
2537  * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
2538  *
2539  * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
2540  * @endcode
2541  *
2542  * Waits for a direct to task notification on a particular index in the calling
2543  * task's notification array in a manner similar to taking a counting semaphore.
2544  *
2545  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2546  *
2547  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for this
2548  * function to be available.
2549  *
2550  * Each task has a private array of "notification values" (or 'notifications'),
2551  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2552  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2553  * array, and (for backward compatibility) defaults to 1 if left undefined.
2554  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2555  *
2556  * Events can be sent to a task using an intermediary object.  Examples of such
2557  * objects are queues, semaphores, mutexes and event groups.  Task notifications
2558  * are a method of sending an event directly to a task without the need for such
2559  * an intermediary object.
2560  *
2561  * A notification sent to a task can optionally perform an action, such as
2562  * update, overwrite or increment one of the task's notification values.  In
2563  * that way task notifications can be used to send data to a task, or be used as
2564  * light weight and fast binary or counting semaphores.
2565  *
2566  * ulTaskNotifyTakeIndexed() is intended for use when a task notification is
2567  * used as a faster and lighter weight binary or counting semaphore alternative.
2568  * Actual FreeRTOS semaphores are taken using the xSemaphoreTake() API function,
2569  * the equivalent action that instead uses a task notification is
2570  * ulTaskNotifyTakeIndexed().
2571  *
2572  * When a task is using its notification value as a binary or counting semaphore
2573  * other tasks should send notifications to it using the xTaskNotifyGiveIndexed()
2574  * macro, or xTaskNotifyIndex() function with the eAction parameter set to
2575  * eIncrement.
2576  *
2577  * ulTaskNotifyTakeIndexed() can either clear the task's notification value at
2578  * the array index specified by the uxIndexToWaitOn parameter to zero on exit,
2579  * in which case the notification value acts like a binary semaphore, or
2580  * decrement the notification value on exit, in which case the notification
2581  * value acts like a counting semaphore.
2582  *
2583  * A task can use ulTaskNotifyTakeIndexed() to [optionally] block to wait for
2584  * a notification.  The task does not consume any CPU time while it is in the
2585  * Blocked state.
2586  *
2587  * Where as xTaskNotifyWaitIndexed() will return when a notification is pending,
2588  * ulTaskNotifyTakeIndexed() will return when the task's notification value is
2589  * not zero.
2590  *
2591  * **NOTE** Each notification within the array operates independently - a task
2592  * can only block on one notification within the array at a time and will not be
2593  * unblocked by a notification sent to any other array index.
2594  *
2595  * Backward compatibility information:
2596  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2597  * all task notification API functions operated on that value. Replacing the
2598  * single notification value with an array of notification values necessitated a
2599  * new set of API functions that could address specific notifications within the
2600  * array.  ulTaskNotifyTake() is the original API function, and remains backward
2601  * compatible by always operating on the notification value at index 0 in the
2602  * array. Calling ulTaskNotifyTake() is equivalent to calling
2603  * ulTaskNotifyTakeIndexed() with the uxIndexToWaitOn parameter set to 0.
2604  *
2605  * @param uxIndexToWaitOn The index within the calling task's array of
2606  * notification values on which the calling task will wait for a notification to
2607  * be non-zero.  uxIndexToWaitOn must be less than
2608  * configTASK_NOTIFICATION_ARRAY_ENTRIES.  xTaskNotifyTake() does
2609  * not have this parameter and always waits for notifications on index 0.
2610  *
2611  * @param xClearCountOnExit if xClearCountOnExit is pdFALSE then the task's
2612  * notification value is decremented when the function exits.  In this way the
2613  * notification value acts like a counting semaphore.  If xClearCountOnExit is
2614  * not pdFALSE then the task's notification value is cleared to zero when the
2615  * function exits.  In this way the notification value acts like a binary
2616  * semaphore.
2617  *
2618  * @param xTicksToWait The maximum amount of time that the task should wait in
2619  * the Blocked state for the task's notification value to be greater than zero,
2620  * should the count not already be greater than zero when
2621  * ulTaskNotifyTake() was called.  The task will not consume any processing
2622  * time while it is in the Blocked state.  This is specified in kernel ticks,
2623  * the macro pdMS_TO_TICKS( value_in_ms ) can be used to convert a time
2624  * specified in milliseconds to a time specified in ticks.
2625  *
2626  * @return The task's notification count before it is either cleared to zero or
2627  * decremented (see the xClearCountOnExit parameter).
2628  *
2629  * \defgroup ulTaskNotifyTakeIndexed ulTaskNotifyTakeIndexed
2630  * \ingroup TaskNotifications
2631  */
2632 uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
2633                                   BaseType_t xClearCountOnExit,
2634                                   TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2635 #define ulTaskNotifyTake( xClearCountOnExit, xTicksToWait ) \
2636     ulTaskGenericNotifyTake( ( tskDEFAULT_INDEX_TO_NOTIFY ), ( xClearCountOnExit ), ( xTicksToWait ) )
2637 #define ulTaskNotifyTakeIndexed( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ) \
2638     ulTaskGenericNotifyTake( ( uxIndexToWaitOn ), ( xClearCountOnExit ), ( xTicksToWait ) )
2639
2640 /**
2641  * task. h
2642  * @code{c}
2643  * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear );
2644  *
2645  * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
2646  * @endcode
2647  *
2648  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2649  *
2650  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2651  * functions to be available.
2652  *
2653  * Each task has a private array of "notification values" (or 'notifications'),
2654  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2655  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2656  * array, and (for backward compatibility) defaults to 1 if left undefined.
2657  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2658  *
2659  * If a notification is sent to an index within the array of notifications then
2660  * the notification at that index is said to be 'pending' until it is read or
2661  * explicitly cleared by the receiving task.  xTaskNotifyStateClearIndexed()
2662  * is the function that clears a pending notification without reading the
2663  * notification value.  The notification value at the same array index is not
2664  * altered.  Set xTask to NULL to clear the notification state of the calling
2665  * task.
2666  *
2667  * Backward compatibility information:
2668  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2669  * all task notification API functions operated on that value. Replacing the
2670  * single notification value with an array of notification values necessitated a
2671  * new set of API functions that could address specific notifications within the
2672  * array.  xTaskNotifyStateClear() is the original API function, and remains
2673  * backward compatible by always operating on the notification value at index 0
2674  * within the array. Calling xTaskNotifyStateClear() is equivalent to calling
2675  * xTaskNotifyStateClearIndexed() with the uxIndexToNotify parameter set to 0.
2676  *
2677  * @param xTask The handle of the RTOS task that will have a notification state
2678  * cleared.  Set xTask to NULL to clear a notification state in the calling
2679  * task.  To obtain a task's handle create the task using xTaskCreate() and
2680  * make use of the pxCreatedTask parameter, or create the task using
2681  * xTaskCreateStatic() and store the returned value, or use the task's name in
2682  * a call to xTaskGetHandle().
2683  *
2684  * @param uxIndexToClear The index within the target task's array of
2685  * notification values to act upon.  For example, setting uxIndexToClear to 1
2686  * will clear the state of the notification at index 1 within the array.
2687  * uxIndexToClear must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2688  * ulTaskNotifyStateClear() does not have this parameter and always acts on the
2689  * notification at index 0.
2690  *
2691  * @return pdTRUE if the task's notification state was set to
2692  * eNotWaitingNotification, otherwise pdFALSE.
2693  *
2694  * \defgroup xTaskNotifyStateClearIndexed xTaskNotifyStateClearIndexed
2695  * \ingroup TaskNotifications
2696  */
2697 BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask,
2698                                          UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION;
2699 #define xTaskNotifyStateClear( xTask ) \
2700     xTaskGenericNotifyStateClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ) )
2701 #define xTaskNotifyStateClearIndexed( xTask, uxIndexToClear ) \
2702     xTaskGenericNotifyStateClear( ( xTask ), ( uxIndexToClear ) )
2703
2704 /**
2705  * task. h
2706  * @code{c}
2707  * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear );
2708  *
2709  * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
2710  * @endcode
2711  *
2712  * See https://www.FreeRTOS.org/RTOS-task-notifications.html for details.
2713  *
2714  * configUSE_TASK_NOTIFICATIONS must be undefined or defined as 1 for these
2715  * functions to be available.
2716  *
2717  * Each task has a private array of "notification values" (or 'notifications'),
2718  * each of which is a 32-bit unsigned integer (uint32_t).  The constant
2719  * configTASK_NOTIFICATION_ARRAY_ENTRIES sets the number of indexes in the
2720  * array, and (for backward compatibility) defaults to 1 if left undefined.
2721  * Prior to FreeRTOS V10.4.0 there was only one notification value per task.
2722  *
2723  * ulTaskNotifyValueClearIndexed() clears the bits specified by the
2724  * ulBitsToClear bit mask in the notification value at array index uxIndexToClear
2725  * of the task referenced by xTask.
2726  *
2727  * Backward compatibility information:
2728  * Prior to FreeRTOS V10.4.0 each task had a single "notification value", and
2729  * all task notification API functions operated on that value. Replacing the
2730  * single notification value with an array of notification values necessitated a
2731  * new set of API functions that could address specific notifications within the
2732  * array.  ulTaskNotifyValueClear() is the original API function, and remains
2733  * backward compatible by always operating on the notification value at index 0
2734  * within the array. Calling ulTaskNotifyValueClear() is equivalent to calling
2735  * ulTaskNotifyValueClearIndexed() with the uxIndexToClear parameter set to 0.
2736  *
2737  * @param xTask The handle of the RTOS task that will have bits in one of its
2738  * notification values cleared. Set xTask to NULL to clear bits in a
2739  * notification value of the calling task.  To obtain a task's handle create the
2740  * task using xTaskCreate() and make use of the pxCreatedTask parameter, or
2741  * create the task using xTaskCreateStatic() and store the returned value, or
2742  * use the task's name in a call to xTaskGetHandle().
2743  *
2744  * @param uxIndexToClear The index within the target task's array of
2745  * notification values in which to clear the bits.  uxIndexToClear
2746  * must be less than configTASK_NOTIFICATION_ARRAY_ENTRIES.
2747  * ulTaskNotifyValueClear() does not have this parameter and always clears bits
2748  * in the notification value at index 0.
2749  *
2750  * @param ulBitsToClear Bit mask of the bits to clear in the notification value of
2751  * xTask. Set a bit to 1 to clear the corresponding bits in the task's notification
2752  * value. Set ulBitsToClear to 0xffffffff (UINT_MAX on 32-bit architectures) to clear
2753  * the notification value to 0.  Set ulBitsToClear to 0 to query the task's
2754  * notification value without clearing any bits.
2755  *
2756  *
2757  * @return The value of the target task's notification value before the bits
2758  * specified by ulBitsToClear were cleared.
2759  * \defgroup ulTaskNotifyValueClear ulTaskNotifyValueClear
2760  * \ingroup TaskNotifications
2761  */
2762 uint32_t ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
2763                                         UBaseType_t uxIndexToClear,
2764                                         uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
2765 #define ulTaskNotifyValueClear( xTask, ulBitsToClear ) \
2766     ulTaskGenericNotifyValueClear( ( xTask ), ( tskDEFAULT_INDEX_TO_NOTIFY ), ( ulBitsToClear ) )
2767 #define ulTaskNotifyValueClearIndexed( xTask, uxIndexToClear, ulBitsToClear ) \
2768     ulTaskGenericNotifyValueClear( ( xTask ), ( uxIndexToClear ), ( ulBitsToClear ) )
2769
2770 /**
2771  * task.h
2772  * @code{c}
2773  * void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut );
2774  * @endcode
2775  *
2776  * Capture the current time for future use with xTaskCheckForTimeOut().
2777  *
2778  * @param pxTimeOut Pointer to a timeout object into which the current time
2779  * is to be captured.  The captured time includes the tick count and the number
2780  * of times the tick count has overflowed since the system first booted.
2781  * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState
2782  * \ingroup TaskCtrl
2783  */
2784 void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
2785
2786 /**
2787  * task.h
2788  * @code{c}
2789  * BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );
2790  * @endcode
2791  *
2792  * Determines if pxTicksToWait ticks has passed since a time was captured
2793  * using a call to vTaskSetTimeOutState().  The captured time includes the tick
2794  * count and the number of times the tick count has overflowed.
2795  *
2796  * @param pxTimeOut The time status as captured previously using
2797  * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated
2798  * to reflect the current time status.
2799  * @param pxTicksToWait The number of ticks to check for timeout i.e. if
2800  * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by
2801  * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.
2802  * If the timeout has not occurred, pxTicksToWait is updated to reflect the
2803  * number of remaining ticks.
2804  *
2805  * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is
2806  * returned and pxTicksToWait is updated to reflect the number of remaining
2807  * ticks.
2808  *
2809  * @see https://www.FreeRTOS.org/xTaskCheckForTimeOut.html
2810  *
2811  * Example Usage:
2812  * @code{c}
2813  *  // Driver library function used to receive uxWantedBytes from an Rx buffer
2814  *  // that is filled by a UART interrupt. If there are not enough bytes in the
2815  *  // Rx buffer then the task enters the Blocked state until it is notified that
2816  *  // more data has been placed into the buffer. If there is still not enough
2817  *  // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()
2818  *  // is used to re-calculate the Block time to ensure the total amount of time
2819  *  // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This
2820  *  // continues until either the buffer contains at least uxWantedBytes bytes,
2821  *  // or the total amount of time spent in the Blocked state reaches
2822  *  // MAX_TIME_TO_WAIT - at which point the task reads however many bytes are
2823  *  // available up to a maximum of uxWantedBytes.
2824  *
2825  *  size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )
2826  *  {
2827  *  size_t uxReceived = 0;
2828  *  TickType_t xTicksToWait = MAX_TIME_TO_WAIT;
2829  *  TimeOut_t xTimeOut;
2830  *
2831  *      // Initialize xTimeOut.  This records the time at which this function
2832  *      // was entered.
2833  *      vTaskSetTimeOutState( &xTimeOut );
2834  *
2835  *      // Loop until the buffer contains the wanted number of bytes, or a
2836  *      // timeout occurs.
2837  *      while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )
2838  *      {
2839  *          // The buffer didn't contain enough data so this task is going to
2840  *          // enter the Blocked state. Adjusting xTicksToWait to account for
2841  *          // any time that has been spent in the Blocked state within this
2842  *          // function so far to ensure the total amount of time spent in the
2843  *          // Blocked state does not exceed MAX_TIME_TO_WAIT.
2844  *          if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )
2845  *          {
2846  *              //Timed out before the wanted number of bytes were available,
2847  *              // exit the loop.
2848  *              break;
2849  *          }
2850  *
2851  *          // Wait for a maximum of xTicksToWait ticks to be notified that the
2852  *          // receive interrupt has placed more data into the buffer.
2853  *          ulTaskNotifyTake( pdTRUE, xTicksToWait );
2854  *      }
2855  *
2856  *      // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.
2857  *      // The actual number of bytes read (which might be less than
2858  *      // uxWantedBytes) is returned.
2859  *      uxReceived = UART_read_from_receive_buffer( pxUARTInstance,
2860  *                                                  pucBuffer,
2861  *                                                  uxWantedBytes );
2862  *
2863  *      return uxReceived;
2864  *  }
2865  * @endcode
2866  * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut
2867  * \ingroup TaskCtrl
2868  */
2869 BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
2870                                  TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
2871
2872 /**
2873  * task.h
2874  * @code{c}
2875  * BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );
2876  * @endcode
2877  *
2878  * This function corrects the tick count value after the application code has held
2879  * interrupts disabled for an extended period resulting in tick interrupts having
2880  * been missed.
2881  *
2882  * This function is similar to vTaskStepTick(), however, unlike
2883  * vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a
2884  * time at which a task should be removed from the blocked state.  That means
2885  * tasks may have to be removed from the blocked state as the tick count is
2886  * moved.
2887  *
2888  * @param xTicksToCatchUp The number of tick interrupts that have been missed due to
2889  * interrupts being disabled.  Its value is not computed automatically, so must be
2890  * computed by the application writer.
2891  *
2892  * @return pdTRUE if moving the tick count forward resulted in a task leaving the
2893  * blocked state and a context switch being performed.  Otherwise pdFALSE.
2894  *
2895  * \defgroup xTaskCatchUpTicks xTaskCatchUpTicks
2896  * \ingroup TaskCtrl
2897  */
2898 BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;
2899
2900
2901 /*-----------------------------------------------------------
2902 * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
2903 *----------------------------------------------------------*/
2904
2905 /*
2906  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY
2907  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
2908  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2909  *
2910  * Called from the real time kernel tick (either preemptive or cooperative),
2911  * this increments the tick count and checks if any tasks that are blocked
2912  * for a finite period required removing from a blocked list and placing on
2913  * a ready list.  If a non-zero value is returned then a context switch is
2914  * required because either:
2915  *   + A task was removed from a blocked list because its timeout had expired,
2916  *     or
2917  *   + Time slicing is in use and there is a task of equal priority to the
2918  *     currently running task.
2919  */
2920 BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
2921
2922 /*
2923  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN
2924  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2925  *
2926  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2927  *
2928  * Removes the calling task from the ready list and places it both
2929  * on the list of tasks waiting for a particular event, and the
2930  * list of delayed tasks.  The task will be removed from both lists
2931  * and replaced on the ready list should either the event occur (and
2932  * there be no higher priority tasks waiting on the same event) or
2933  * the delay period expires.
2934  *
2935  * The 'unordered' version replaces the event list item value with the
2936  * xItemValue value, and inserts the list item at the end of the list.
2937  *
2938  * The 'ordered' version uses the existing event list item value (which is the
2939  * owning task's priority) to insert the list item into the event list in task
2940  * priority order.
2941  *
2942  * @param pxEventList The list containing tasks that are blocked waiting
2943  * for the event to occur.
2944  *
2945  * @param xItemValue The item value to use for the event list item when the
2946  * event list is not ordered by task priority.
2947  *
2948  * @param xTicksToWait The maximum amount of time that the task should wait
2949  * for the event to occur.  This is specified in kernel ticks, the constant
2950  * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
2951  * period.
2952  */
2953 void vTaskPlaceOnEventList( List_t * const pxEventList,
2954                             const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2955 void vTaskPlaceOnUnorderedEventList( List_t * pxEventList,
2956                                      const TickType_t xItemValue,
2957                                      const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2958
2959 /*
2960  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN
2961  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2962  *
2963  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2964  *
2965  * This function performs nearly the same function as vTaskPlaceOnEventList().
2966  * The difference being that this function does not permit tasks to block
2967  * indefinitely, whereas vTaskPlaceOnEventList() does.
2968  *
2969  */
2970 void vTaskPlaceOnEventListRestricted( List_t * const pxEventList,
2971                                       TickType_t xTicksToWait,
2972                                       const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
2973
2974 /*
2975  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN
2976  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2977  *
2978  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2979  *
2980  * Removes a task from both the specified event list and the list of blocked
2981  * tasks, and places it on a ready queue.
2982  *
2983  * xTaskRemoveFromEventList()/vTaskRemoveFromUnorderedEventList() will be called
2984  * if either an event occurs to unblock a task, or the block timeout period
2985  * expires.
2986  *
2987  * xTaskRemoveFromEventList() is used when the event list is in task priority
2988  * order.  It removes the list item from the head of the event list as that will
2989  * have the highest priority owning task of all the tasks on the event list.
2990  * vTaskRemoveFromUnorderedEventList() is used when the event list is not
2991  * ordered and the event list items hold something other than the owning tasks
2992  * priority.  In this case the event list item value is updated to the value
2993  * passed in the xItemValue parameter.
2994  *
2995  * @return pdTRUE if the task being removed has a higher priority than the task
2996  * making the call, otherwise pdFALSE.
2997  */
2998 BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
2999 void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem,
3000                                         const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
3001
3002 /*
3003  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY
3004  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
3005  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
3006  *
3007  * Sets the pointer to the current TCB to the TCB of the highest priority task
3008  * that is ready to run.
3009  */
3010 portDONT_DISCARD void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
3011
3012 /*
3013  * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE.  THEY ARE USED BY
3014  * THE EVENT BITS MODULE.
3015  */
3016 TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
3017
3018 /*
3019  * Return the handle of the calling task.
3020  */
3021 TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
3022
3023 /*
3024  * Shortcut used by the queue implementation to prevent unnecessary call to
3025  * taskYIELD();
3026  */
3027 void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
3028
3029 /*
3030  * Returns the scheduler state as taskSCHEDULER_RUNNING,
3031  * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
3032  */
3033 BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
3034
3035 /*
3036  * Raises the priority of the mutex holder to that of the calling task should
3037  * the mutex holder have a priority less than the calling task.
3038  */
3039 BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
3040
3041 /*
3042  * Set the priority of a task back to its proper priority in the case that it
3043  * inherited a higher priority while it was holding a semaphore.
3044  */
3045 BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
3046
3047 /*
3048  * If a higher priority task attempting to obtain a mutex caused a lower
3049  * priority task to inherit the higher priority task's priority - but the higher
3050  * priority task then timed out without obtaining the mutex, then the lower
3051  * priority task will disinherit the priority again - but only down as far as
3052  * the highest priority task that is still waiting for the mutex (if there were
3053  * more than one task waiting for the mutex).
3054  */
3055 void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder,
3056                                           UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION;
3057
3058 /*
3059  * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
3060  */
3061 UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
3062
3063 /*
3064  * Set the uxTaskNumber of the task referenced by the xTask parameter to
3065  * uxHandle.
3066  */
3067 void vTaskSetTaskNumber( TaskHandle_t xTask,
3068                          const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
3069
3070 /*
3071  * Only available when configUSE_TICKLESS_IDLE is set to 1.
3072  * If tickless mode is being used, or a low power mode is implemented, then
3073  * the tick interrupt will not execute during idle periods.  When this is the
3074  * case, the tick count value maintained by the scheduler needs to be kept up
3075  * to date with the actual execution time by being skipped forward by a time
3076  * equal to the idle period.
3077  */
3078 void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
3079
3080 /*
3081  * Only available when configUSE_TICKLESS_IDLE is set to 1.
3082  * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
3083  * specific sleep function to determine if it is ok to proceed with the sleep,
3084  * and if it is ok to proceed, if it is ok to sleep indefinitely.
3085  *
3086  * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
3087  * called with the scheduler suspended, not from within a critical section.  It
3088  * is therefore possible for an interrupt to request a context switch between
3089  * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
3090  * entered.  eTaskConfirmSleepModeStatus() should be called from a short
3091  * critical section between the timer being stopped and the sleep mode being
3092  * entered to ensure it is ok to proceed into the sleep mode.
3093  */
3094 eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
3095
3096 /*
3097  * For internal use only.  Increment the mutex held count when a mutex is
3098  * taken and return the handle of the task that has taken the mutex.
3099  */
3100 TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
3101
3102 /*
3103  * For internal use only.  Same as vTaskSetTimeOutState(), but without a critical
3104  * section.
3105  */
3106 void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
3107
3108
3109 /* *INDENT-OFF* */
3110 #ifdef __cplusplus
3111     }
3112 #endif
3113 /* *INDENT-ON* */
3114 #endif /* INC_TASK_H */