task.h
Go to the documentation of this file.
1 /*
2  FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
3  All rights reserved
4 
5  VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6 
7  This file is part of the FreeRTOS distribution.
8 
9  FreeRTOS is free software; you can redistribute it and/or modify it under
10  the terms of the GNU General Public License (version 2) as published by the
11  Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
12 
13  ***************************************************************************
14  >>! NOTE: The modification to the GPL is included to allow you to !<<
15  >>! distribute a combined work that includes FreeRTOS without being !<<
16  >>! obliged to provide the source code for proprietary components !<<
17  >>! outside of the FreeRTOS kernel. !<<
18  ***************************************************************************
19 
20  FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22  FOR A PARTICULAR PURPOSE. Full license text is available on the following
23  link: http://www.freertos.org/a00114.html
24 
25  ***************************************************************************
26  * *
27  * FreeRTOS provides completely free yet professionally developed, *
28  * robust, strictly quality controlled, supported, and cross *
29  * platform software that is more than just the market leader, it *
30  * is the industry's de facto standard. *
31  * *
32  * Help yourself get started quickly while simultaneously helping *
33  * to support the FreeRTOS project by purchasing a FreeRTOS *
34  * tutorial book, reference manual, or both: *
35  * http://www.FreeRTOS.org/Documentation *
36  * *
37  ***************************************************************************
38 
39  http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
40  the FAQ page "My application does not run, what could be wrong?". Have you
41  defined configASSERT()?
42 
43  http://www.FreeRTOS.org/support - In return for receiving this top quality
44  embedded software for free we request you assist our global community by
45  participating in the support forum.
46 
47  http://www.FreeRTOS.org/training - Investing in training allows your team to
48  be as productive as possible as early as possible. Now you can receive
49  FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50  Ltd, and the world's leading authority on the world's leading RTOS.
51 
52  http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53  including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54  compatible FAT file system, and our tiny thread aware UDP/IP stack.
55 
56  http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57  Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
58 
59  http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60  Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
61  licenses offer ticketed support, indemnification and commercial middleware.
62 
63  http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64  engineered and independently SIL3 certified version for use in safety and
65  mission critical applications that require provable dependability.
66 
67  1 tab == 4 spaces!
68 */
69 
70 
71 #ifndef INC_TASK_H
72 #define INC_TASK_H
73 
74 #ifndef INC_FREERTOS_H
75  #error "include FreeRTOS.h must appear in source files before include task.h"
76 #endif
77 
78 #include "list.h"
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
84 /*-----------------------------------------------------------
85  * MACROS AND DEFINITIONS
86  *----------------------------------------------------------*/
87 
88 #define tskKERNEL_VERSION_NUMBER "V9.0.0"
89 #define tskKERNEL_VERSION_MAJOR 9
90 #define tskKERNEL_VERSION_MINOR 0
91 #define tskKERNEL_VERSION_BUILD 0
92 
103 typedef void * TaskHandle_t;
104 
105 /*
106  * Defines the prototype to which the application task hook function must
107  * conform.
108  */
109 typedef BaseType_t (*TaskHookFunction_t)( void * );
110 
111 /* Task states returned by eTaskGetState. */
112 typedef enum
113 {
114  eRunning = 0, /* A task is querying the state of itself, so must be running. */
115  eReady, /* The task being queried is in a read or pending ready list. */
116  eBlocked, /* The task being queried is in the Blocked state. */
117  eSuspended, /* The task being queried is in the Suspended state, or is in the Blocked state with an infinite time out. */
118  eDeleted, /* The task being queried has been deleted, but its TCB has not yet been freed. */
119  eInvalid /* Used as an 'invalid state' value. */
120 } eTaskState;
121 
122 /* Actions that can be performed when vTaskNotify() is called. */
123 typedef enum
124 {
125  eNoAction = 0, /* Notify the task without updating its notify value. */
126  eSetBits, /* Set bits in the task's notification value. */
127  eIncrement, /* Increment the task's notification value. */
128  eSetValueWithOverwrite, /* Set the task's notification value to a specific value even if the previous value has not yet been read by the task. */
129  eSetValueWithoutOverwrite /* Set the task's notification value if the previous value has been read by the task. */
130 } eNotifyAction;
131 
132 /*
133  * Used internally only.
134  */
135 typedef struct xTIME_OUT
136 {
139 } TimeOut_t;
140 
141 /*
142  * Defines the memory ranges allocated to the task when an MPU is used.
143  */
144 typedef struct xMEMORY_REGION
145 {
147  uint32_t ulLengthInBytes;
148  uint32_t ulParameters;
150 
151 /*
152  * Parameters required to create an MPU protected task.
153  */
154 typedef struct xTASK_PARAMETERS
155 {
157  const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
158  uint16_t usStackDepth;
164 
165 /* Used with the uxTaskGetSystemState() function to return the state of each task
166 in the system. */
167 typedef struct xTASK_STATUS
168 {
169  TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
170  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. */
171  UBaseType_t xTaskNumber; /* A number unique to the task. */
172  eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */
173  UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */
174  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. */
175  uint32_t ulRunTimeCounter; /* The total run time allocated to the task so far, as defined by the run time stats clock. See http://www.freertos.org/rtos-run-time-stats.html. Only valid when configGENERATE_RUN_TIME_STATS is defined as 1 in FreeRTOSConfig.h. */
176  StackType_t *pxStackBase; /* Points to the lowest address of the task's stack area. */
177  uint16_t 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. */
178 } TaskStatus_t;
179 
180 /* Possible return values for eTaskConfirmSleepModeStatus(). */
181 typedef enum
182 {
183  eAbortSleep = 0, /* A task has been made ready or a context switch pended since portSUPPORESS_TICKS_AND_SLEEP() was called - abort entering a sleep mode. */
184  eStandardSleep, /* Enter a sleep mode that will not last any longer than the expected idle time. */
185  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. */
187 
193 #define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U )
194 
203 #define taskYIELD() portYIELD()
204 
217 #define taskENTER_CRITICAL() portENTER_CRITICAL()
218 #define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
219 
232 #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
233 #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
234 
242 #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
243 
252 #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
253 
254 /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is
255 0 to generate more optimal code when configASSERT() is defined as the constant
256 is used in assert() statements. */
257 #define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 )
258 #define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 )
259 #define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 )
260 
261 
262 /*-----------------------------------------------------------
263  * TASK CREATION API
264  *----------------------------------------------------------*/
265 
359 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
360  BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
361  const char * const pcName,
362  const uint16_t usStackDepth,
363  void * const pvParameters,
364  UBaseType_t uxPriority,
365  TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
366 #endif
367 
475 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
476  TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
477  const char * const pcName,
478  const uint32_t ulStackDepth,
479  void * const pvParameters,
480  UBaseType_t uxPriority,
481  StackType_t * const puxStackBuffer,
482  StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
483 #endif /* configSUPPORT_STATIC_ALLOCATION */
484 
552 #if( portUSING_MPU_WRAPPERS == 1 )
553  BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ) PRIVILEGED_FUNCTION;
554 #endif
555 
602 void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
603 
643 void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
644 
645 /*-----------------------------------------------------------
646  * TASK CONTROL API
647  *----------------------------------------------------------*/
648 
695 void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
696 
754 void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
755 
779 BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
780 
827 
835 
852 eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
853 
908 void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) PRIVILEGED_FUNCTION;
909 
950 void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
951 
1001 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
1002 
1050 void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1051 
1079 BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1080 
1081 /*-----------------------------------------------------------
1082  * SCHEDULER CONTROL
1083  *----------------------------------------------------------*/
1084 
1112 void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
1113 
1168 void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
1169 
1219 void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
1220 
1273 BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
1274 
1275 /*-----------------------------------------------------------
1276  * TASK UTILITIES
1277  *----------------------------------------------------------*/
1278 
1288 TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
1289 
1304 TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
1305 
1318 UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
1319 
1331 char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1332 
1347 TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1348 
1368 UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1369 
1370 /* When using trace macros it is sometimes necessary to include task.h before
1371 FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
1372 so the following two prototypes will cause a compilation error. This can be
1373 fixed by simply guarding against the inclusion of these two prototypes unless
1374 they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
1375 constant. */
1376 #ifdef configUSE_APPLICATION_TASK_TAG
1377  #if configUSE_APPLICATION_TASK_TAG == 1
1378 
1386  void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
1387 
1394  TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1395  #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
1396 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
1397 
1398 #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
1399 
1400  /* Each task contains an array of pointers that is dimensioned by the
1401  configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
1402  kernel does not use the pointers itself, so the application writer can use
1403  the pointers for any purpose they wish. The following two functions are
1404  used to set and query a pointer respectively. */
1405  void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) PRIVILEGED_FUNCTION;
1406  void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) PRIVILEGED_FUNCTION;
1407 
1408 #endif
1409 
1421 BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) PRIVILEGED_FUNCTION;
1422 
1430 TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
1431 
1529 UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
1530 
1576 void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1577 
1630 void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1631 
1711 BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
1712 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL )
1713 #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
1714 
1802 BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
1803 #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
1804 #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
1805 
1879 BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
1880 
1925 #define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL )
1926 
1980 void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
1981 
2049 uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2050 
2065 BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
2066 
2067 /*-----------------------------------------------------------
2068  * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
2069  *----------------------------------------------------------*/
2070 
2071 /*
2072  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
2073  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
2074  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2075  *
2076  * Called from the real time kernel tick (either preemptive or cooperative),
2077  * this increments the tick count and checks if any tasks that are blocked
2078  * for a finite period required removing from a blocked list and placing on
2079  * a ready list. If a non-zero value is returned then a context switch is
2080  * required because either:
2081  * + A task was removed from a blocked list because its timeout had expired,
2082  * or
2083  * + Time slicing is in use and there is a task of equal priority to the
2084  * currently running task.
2085  */
2086 BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
2087 
2088 /*
2089  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
2090  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2091  *
2092  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2093  *
2094  * Removes the calling task from the ready list and places it both
2095  * on the list of tasks waiting for a particular event, and the
2096  * list of delayed tasks. The task will be removed from both lists
2097  * and replaced on the ready list should either the event occur (and
2098  * there be no higher priority tasks waiting on the same event) or
2099  * the delay period expires.
2100  *
2101  * The 'unordered' version replaces the event list item value with the
2102  * xItemValue value, and inserts the list item at the end of the list.
2103  *
2104  * The 'ordered' version uses the existing event list item value (which is the
2105  * owning tasks priority) to insert the list item into the event list is task
2106  * priority order.
2107  *
2108  * @param pxEventList The list containing tasks that are blocked waiting
2109  * for the event to occur.
2110  *
2111  * @param xItemValue The item value to use for the event list item when the
2112  * event list is not ordered by task priority.
2113  *
2114  * @param xTicksToWait The maximum amount of time that the task should wait
2115  * for the event to occur. This is specified in kernel ticks,the constant
2116  * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
2117  * period.
2118  */
2119 void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2120 void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2121 
2122 /*
2123  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
2124  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2125  *
2126  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2127  *
2128  * This function performs nearly the same function as vTaskPlaceOnEventList().
2129  * The difference being that this function does not permit tasks to block
2130  * indefinitely, whereas vTaskPlaceOnEventList() does.
2131  *
2132  */
2133 void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
2134 
2135 /*
2136  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
2137  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2138  *
2139  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2140  *
2141  * Removes a task from both the specified event list and the list of blocked
2142  * tasks, and places it on a ready queue.
2143  *
2144  * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called
2145  * if either an event occurs to unblock a task, or the block timeout period
2146  * expires.
2147  *
2148  * xTaskRemoveFromEventList() is used when the event list is in task priority
2149  * order. It removes the list item from the head of the event list as that will
2150  * have the highest priority owning task of all the tasks on the event list.
2151  * xTaskRemoveFromUnorderedEventList() is used when the event list is not
2152  * ordered and the event list items hold something other than the owning tasks
2153  * priority. In this case the event list item value is updated to the value
2154  * passed in the xItemValue parameter.
2155  *
2156  * @return pdTRUE if the task being removed has a higher priority than the task
2157  * making the call, otherwise pdFALSE.
2158  */
2159 BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
2160 BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
2161 
2162 /*
2163  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
2164  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
2165  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2166  *
2167  * Sets the pointer to the current TCB to the TCB of the highest priority task
2168  * that is ready to run.
2169  */
2170 void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
2171 
2172 /*
2173  * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
2174  * THE EVENT BITS MODULE.
2175  */
2176 TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
2177 
2178 /*
2179  * Return the handle of the calling task.
2180  */
2181 TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
2182 
2183 /*
2184  * Capture the current time status for future reference.
2185  */
2186 void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
2187 
2188 /*
2189  * Compare the time status now with that previously captured to see if the
2190  * timeout has expired.
2191  */
2192 BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
2193 
2194 /*
2195  * Shortcut used by the queue implementation to prevent unnecessary call to
2196  * taskYIELD();
2197  */
2198 void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
2199 
2200 /*
2201  * Returns the scheduler state as taskSCHEDULER_RUNNING,
2202  * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
2203  */
2204 BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
2205 
2206 /*
2207  * Raises the priority of the mutex holder to that of the calling task should
2208  * the mutex holder have a priority less than the calling task.
2209  */
2210 void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
2211 
2212 /*
2213  * Set the priority of a task back to its proper priority in the case that it
2214  * inherited a higher priority while it was holding a semaphore.
2215  */
2216 BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
2217 
2218 /*
2219  * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
2220  */
2221 UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
2222 
2223 /*
2224  * Set the uxTaskNumber of the task referenced by the xTask parameter to
2225  * uxHandle.
2226  */
2227 void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
2228 
2229 /*
2230  * Only available when configUSE_TICKLESS_IDLE is set to 1.
2231  * If tickless mode is being used, or a low power mode is implemented, then
2232  * the tick interrupt will not execute during idle periods. When this is the
2233  * case, the tick count value maintained by the scheduler needs to be kept up
2234  * to date with the actual execution time by being skipped forward by a time
2235  * equal to the idle period.
2236  */
2237 void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
2238 
2239 /*
2240  * Only avilable when configUSE_TICKLESS_IDLE is set to 1.
2241  * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
2242  * specific sleep function to determine if it is ok to proceed with the sleep,
2243  * and if it is ok to proceed, if it is ok to sleep indefinitely.
2244  *
2245  * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
2246  * called with the scheduler suspended, not from within a critical section. It
2247  * is therefore possible for an interrupt to request a context switch between
2248  * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
2249  * entered. eTaskConfirmSleepModeStatus() should be called from a short
2250  * critical section between the timer being stopped and the sleep mode being
2251  * entered to ensure it is ok to proceed into the sleep mode.
2252  */
2253 eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
2254 
2255 /*
2256  * For internal use only. Increment the mutex held count when a mutex is
2257  * taken and return the handle of the task that has taken the mutex.
2258  */
2259 void *pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
2260 
2261 
2262 BaseType_t uxTaskGetCpuUsage(TaskHandle_t xTask);
2263 void vTaskResetRunTimeStats(void);
2264 void vRunTimeStatIsrEntry();
2265 void vRunTimeStatIsrExit();
2266 
2267 #ifdef __cplusplus
2268 }
2269 #endif
2270 #endif /* INC_TASK_H */
2271 
2272 
2273 
UBaseType_t uxCurrentPriority
Definition: task.h:173
#define pxMutexHolder
Definition: queue.c:108
UBaseType_t uxPriority
Definition: task.h:160
void vTaskSwitchContext(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2761
TaskHandle_t xTaskGetHandle(const char *pcNameToQuery) PRIVILEGED_FUNCTION
eTaskState eCurrentState
Definition: task.h:172
Definition: list.h:181
uint32_t ulRunTimeCounter
Definition: task.h:175
UBaseType_t uxTaskPriorityGetFromISR(TaskHandle_t xTask) PRIVILEGED_FUNCTION
void * pvBaseAddress
Definition: task.h:146
Definition: list.h:205
uint16_t usStackHighWaterMark
Definition: task.h:177
void vTaskSetTaskNumber(TaskHandle_t xTask, const UBaseType_t uxHandle) PRIVILEGED_FUNCTION
Definition: task.h:125
Definition: task.h:167
void vTaskGetRunTimeStats(char *pcWriteBuffer) PRIVILEGED_FUNCTION
TickType_t xTimeOnEntering
Definition: task.h:138
TaskHandle_t xTaskGetCurrentTaskHandle(void) PRIVILEGED_FUNCTION
Definition: task.h:129
Definition: task.h:119
void vTaskPrioritySet(TaskHandle_t xTask, UBaseType_t uxNewPriority) PRIVILEGED_FUNCTION
Definition: tasks.c:1402
void vTaskSuspendAll(void) PRIVILEGED_FUNCTION
Definition: tasks.c:1944
Definition: task.h:128
Definition: task.h:184
Definition: task.h:114
Definition: task.h:118
struct xTIME_OUT TimeOut_t
StackType_t * pxStackBase
Definition: task.h:176
void * pvTaskIncrementMutexHeldCount(void) PRIVILEGED_FUNCTION
eNotifyAction
Definition: task.h:123
BaseType_t xTaskResumeFromISR(TaskHandle_t xTaskToResume) PRIVILEGED_FUNCTION
void vTaskPlaceOnEventListRestricted(List_t *const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely) PRIVILEGED_FUNCTION
BaseType_t xTaskCallApplicationTaskHook(TaskHandle_t xTask, void *pvParameter) PRIVILEGED_FUNCTION
void vTaskList(char *pcWriteBuffer) PRIVILEGED_FUNCTION
Definition: task.h:115
void vTaskPlaceOnUnorderedEventList(List_t *pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait) PRIVILEGED_FUNCTION
Definition: tasks.c:2837
BaseType_t xTaskAbortDelay(TaskHandle_t xTask) PRIVILEGED_FUNCTION
uint32_t ulLengthInBytes
Definition: task.h:147
BaseType_t xTaskGenericNotifyFromISR(TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION
unsigned long UBaseType_t
Definition: portmacro.h:99
uint32_t TickType_t
Definition: portmacro.h:105
const char * pcTaskName
Definition: task.h:170
void vTaskStepTick(const TickType_t xTicksToJump) PRIVILEGED_FUNCTION
eTaskState
Definition: task.h:112
Definition: task.h:185
void vTaskStartScheduler(void) PRIVILEGED_FUNCTION
Definition: tasks.c:1826
struct xMEMORY_REGION MemoryRegion_t
BaseType_t xTaskRemoveFromUnorderedEventList(ListItem_t *pxEventListItem, const TickType_t xItemValue) PRIVILEGED_FUNCTION
Definition: tasks.c:2962
BaseType_t xTaskNotifyWait(uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
Definition: task.h:135
UBaseType_t uxTaskPriorityGet(TaskHandle_t xTask) PRIVILEGED_FUNCTION
TickType_t xTaskGetTickCountFromISR(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2142
BaseType_t(* TaskHookFunction_t)(void *)
Definition: task.h:109
void vTaskEndScheduler(void) PRIVILEGED_FUNCTION
Definition: tasks.c:1933
Definition: task.h:126
TickType_t xTaskGetTickCount(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2127
Definition: FreeRTOS.h:910
void vTaskDelete(TaskHandle_t xTaskToDelete) PRIVILEGED_FUNCTION
UBaseType_t uxTaskGetTaskNumber(TaskHandle_t xTask) PRIVILEGED_FUNCTION
BaseType_t xTaskPriorityDisinherit(TaskHandle_t const pxMutexHolder) PRIVILEGED_FUNCTION
void vTaskMissedYield(void) PRIVILEGED_FUNCTION
Definition: tasks.c:3076
UBaseType_t uxTaskGetStackHighWaterMark(TaskHandle_t xTask) PRIVILEGED_FUNCTION
void vTaskDelayUntil(TickType_t *const pxPreviousWakeTime, const TickType_t xTimeIncrement) PRIVILEGED_FUNCTION
long BaseType_t
Definition: portmacro.h:98
void vTaskSuspend(TaskHandle_t xTaskToSuspend) PRIVILEGED_FUNCTION
TaskHandle_t xTaskGetIdleTaskHandle(void) PRIVILEGED_FUNCTION
#define portNUM_CONFIGURABLE_REGIONS
Definition: portable.h:126
void * pvParameters
Definition: task.h:159
Definition: task.h:144
Definition: task.h:154
void * TaskHandle_t
Definition: task.h:103
void vRunTimeStatIsrEntry()
void vTaskPriorityInherit(TaskHandle_t const pxMutexHolder) PRIVILEGED_FUNCTION
UBaseType_t uxTaskGetNumberOfTasks(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2173
TaskHandle_t xHandle
Definition: task.h:169
void vTaskResetRunTimeStats(void)
TickType_t uxTaskResetEventItemValue(void) PRIVILEGED_FUNCTION
Definition: tasks.c:4162
struct xTASK_STATUS TaskStatus_t
void vTaskNotifyGiveFromISR(TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken) PRIVILEGED_FUNCTION
const char *const pcName
Definition: task.h:157
BaseType_t xTaskNotifyStateClear(TaskHandle_t xTask)
eSleepModeStatus
Definition: task.h:181
void vTaskResume(TaskHandle_t xTaskToResume) PRIVILEGED_FUNCTION
void vTaskAllocateMPURegions(TaskHandle_t xTask, const MemoryRegion_t *const pxRegions) PRIVILEGED_FUNCTION
BaseType_t xTaskIncrementTick(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2499
BaseType_t xTaskResumeAll(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2017
BaseType_t xTaskGetSchedulerState(void) PRIVILEGED_FUNCTION
struct xTASK_PARAMETERS TaskParameters_t
uint16_t usStackDepth
Definition: task.h:158
void vRunTimeStatIsrExit()
uint32_t ulParameters
Definition: task.h:148
Definition: task.h:127
void vTaskSetTimeOutState(TimeOut_t *const pxTimeOut) PRIVILEGED_FUNCTION
Definition: tasks.c:3007
eSleepModeStatus eTaskConfirmSleepModeStatus(void) PRIVILEGED_FUNCTION
Definition: task.h:183
uint32_t ulTaskNotifyTake(BaseType_t xClearCountOnExit, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
BaseType_t uxTaskGetCpuUsage(TaskHandle_t xTask)
#define PRIVILEGED_FUNCTION
Definition: mpu_wrappers.h:193
void vTaskDelay(const TickType_t xTicksToDelay) PRIVILEGED_FUNCTION
Definition: task.h:116
UBaseType_t uxBasePriority
Definition: task.h:174
BaseType_t xOverflowCount
Definition: task.h:137
UBaseType_t xTaskNumber
Definition: task.h:171
BaseType_t xTaskCheckForTimeOut(TimeOut_t *const pxTimeOut, TickType_t *const pxTicksToWait) PRIVILEGED_FUNCTION
Definition: tasks.c:3015
TaskFunction_t pvTaskCode
Definition: task.h:156
UBaseType_t uxTaskGetSystemState(TaskStatus_t *const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t *const pulTotalRunTime) PRIVILEGED_FUNCTION
Definition: tasks.c:2321
void vTaskGetInfo(TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState) PRIVILEGED_FUNCTION
Definition: tasks.c:3411
Definition: task.h:117
BaseType_t xTaskGenericNotify(TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue) PRIVILEGED_FUNCTION
void(* TaskFunction_t)(void *)
Definition: projdefs.h:77
BaseType_t xTaskRemoveFromEventList(const List_t *const pxEventList) PRIVILEGED_FUNCTION
Definition: tasks.c:2894
void vTaskPlaceOnEventList(List_t *const pxEventList, const TickType_t xTicksToWait) PRIVILEGED_FUNCTION
Definition: tasks.c:2820
StackType_t * puxStackBuffer
Definition: task.h:161
char * pcTaskGetName(TaskHandle_t xTaskToQuery) PRIVILEGED_FUNCTION
Definition: tasks.c:2181
eTaskState eTaskGetState(TaskHandle_t xTask) PRIVILEGED_FUNCTION
portSTACK_TYPE StackType_t
Definition: portmacro.h:97