task.h
Go to the documentation of this file.
1 /*
2  FreeRTOS V9.0.0rc2 - 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.0rc2"
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 {
137  BaseType_t xOverflowCount;
138  TickType_t xTimeOnEntering;
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;
160  UBaseType_t uxPriority;
161  StackType_t *puxStackBuffer;
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, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
361 #endif
362 
470 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
471  TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
472 #endif /* configSUPPORT_STATIC_ALLOCATION */
473 
541 #define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ( NULL ), ((x)->xRegions) )
542 
589 void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
590 
630 void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
631 
632 /*-----------------------------------------------------------
633  * TASK CONTROL API
634  *----------------------------------------------------------*/
635 
682 void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
683 
741 void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
742 
766 BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
767 
813 UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
814 
821 UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
822 
839 eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
840 
895 void vTaskGetTaskInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) PRIVILEGED_FUNCTION;
896 
937 void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
938 
988 void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
989 
1037 void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1038 
1066 BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
1067 
1068 /*-----------------------------------------------------------
1069  * SCHEDULER CONTROL
1070  *----------------------------------------------------------*/
1071 
1099 void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
1100 
1155 void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
1156 
1206 void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
1207 
1260 BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
1261 
1262 /*-----------------------------------------------------------
1263  * TASK UTILITIES
1264  *----------------------------------------------------------*/
1265 
1275 TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
1276 
1291 TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
1292 
1305 UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
1306 
1318 char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1319 
1334 TaskHandle_t xTaskGetTaskHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1335 
1355 UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1356 
1357 /* When using trace macros it is sometimes necessary to include task.h before
1358 FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
1359 so the following two prototypes will cause a compilation error. This can be
1360 fixed by simply guarding against the inclusion of these two prototypes unless
1361 they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
1362 constant. */
1363 #ifdef configUSE_APPLICATION_TASK_TAG
1364  #if configUSE_APPLICATION_TASK_TAG == 1
1365 
1373  void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
1374 
1381  TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1382  #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
1383 #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
1384 
1385 #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
1386 
1387  /* Each task contains an array of pointers that is dimensioned by the
1388  configNUM_THREAD_LOCAL_STORAGE_POINTERS setting in FreeRTOSConfig.h. The
1389  kernel does not use the pointers itself, so the application writer can use
1390  the pointers for any purpose they wish. The following two functions are
1391  used to set and query a pointer respectively. */
1392  void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue ) PRIVILEGED_FUNCTION;
1393  void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex ) PRIVILEGED_FUNCTION;
1394 
1395 #endif
1396 
1408 BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) PRIVILEGED_FUNCTION;
1409 
1417 TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
1418 
1516 UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
1517 
1563 void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1564 
1617 void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
1618 
1698 BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue ) PRIVILEGED_FUNCTION;
1699 #define xTaskNotify( xTaskToNotify, ulValue, eAction ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL )
1700 #define xTaskNotifyAndQuery( xTaskToNotify, ulValue, eAction, pulPreviousNotifyValue ) xTaskGenericNotify( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotifyValue ) )
1701 
1789 BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
1790 #define xTaskNotifyFromISR( xTaskToNotify, ulValue, eAction, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), NULL, ( pxHigherPriorityTaskWoken ) )
1791 #define xTaskNotifyAndQueryFromISR( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ) xTaskGenericNotifyFromISR( ( xTaskToNotify ), ( ulValue ), ( eAction ), ( pulPreviousNotificationValue ), ( pxHigherPriorityTaskWoken ) )
1792 
1866 BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
1867 
1912 #define xTaskNotifyGive( xTaskToNotify ) xTaskGenericNotify( ( xTaskToNotify ), ( 0 ), eIncrement, NULL )
1913 
1967 void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
1968 
2036 uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2037 
2052 BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
2053 
2054 /*-----------------------------------------------------------
2055  * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
2056  *----------------------------------------------------------*/
2057 
2058 /*
2059  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
2060  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
2061  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2062  *
2063  * Called from the real time kernel tick (either preemptive or cooperative),
2064  * this increments the tick count and checks if any tasks that are blocked
2065  * for a finite period required removing from a blocked list and placing on
2066  * a ready list. If a non-zero value is returned then a context switch is
2067  * required because either:
2068  * + A task was removed from a blocked list because its timeout had expired,
2069  * or
2070  * + Time slicing is in use and there is a task of equal priority to the
2071  * currently running task.
2072  */
2073 BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
2074 
2075 /*
2076  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
2077  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2078  *
2079  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2080  *
2081  * Removes the calling task from the ready list and places it both
2082  * on the list of tasks waiting for a particular event, and the
2083  * list of delayed tasks. The task will be removed from both lists
2084  * and replaced on the ready list should either the event occur (and
2085  * there be no higher priority tasks waiting on the same event) or
2086  * the delay period expires.
2087  *
2088  * The 'unordered' version replaces the event list item value with the
2089  * xItemValue value, and inserts the list item at the end of the list.
2090  *
2091  * The 'ordered' version uses the existing event list item value (which is the
2092  * owning tasks priority) to insert the list item into the event list is task
2093  * priority order.
2094  *
2095  * @param pxEventList The list containing tasks that are blocked waiting
2096  * for the event to occur.
2097  *
2098  * @param xItemValue The item value to use for the event list item when the
2099  * event list is not ordered by task priority.
2100  *
2101  * @param xTicksToWait The maximum amount of time that the task should wait
2102  * for the event to occur. This is specified in kernel ticks,the constant
2103  * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
2104  * period.
2105  */
2106 void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2107 void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2108 
2109 /*
2110  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
2111  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2112  *
2113  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
2114  *
2115  * This function performs nearly the same function as vTaskPlaceOnEventList().
2116  * The difference being that this function does not permit tasks to block
2117  * indefinitely, whereas vTaskPlaceOnEventList() does.
2118  *
2119  */
2120 void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) 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  * Removes a task from both the specified event list and the list of blocked
2129  * tasks, and places it on a ready queue.
2130  *
2131  * xTaskRemoveFromEventList()/xTaskRemoveFromUnorderedEventList() will be called
2132  * if either an event occurs to unblock a task, or the block timeout period
2133  * expires.
2134  *
2135  * xTaskRemoveFromEventList() is used when the event list is in task priority
2136  * order. It removes the list item from the head of the event list as that will
2137  * have the highest priority owning task of all the tasks on the event list.
2138  * xTaskRemoveFromUnorderedEventList() is used when the event list is not
2139  * ordered and the event list items hold something other than the owning tasks
2140  * priority. In this case the event list item value is updated to the value
2141  * passed in the xItemValue parameter.
2142  *
2143  * @return pdTRUE if the task being removed has a higher priority than the task
2144  * making the call, otherwise pdFALSE.
2145  */
2146 BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
2147 BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
2148 
2149 /*
2150  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
2151  * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
2152  * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
2153  *
2154  * Sets the pointer to the current TCB to the TCB of the highest priority task
2155  * that is ready to run.
2156  */
2157 void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;
2158 
2159 /*
2160  * THESE FUNCTIONS MUST NOT BE USED FROM APPLICATION CODE. THEY ARE USED BY
2161  * THE EVENT BITS MODULE.
2162  */
2163 TickType_t uxTaskResetEventItemValue( void ) PRIVILEGED_FUNCTION;
2164 
2165 /*
2166  * Return the handle of the calling task.
2167  */
2168 TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
2169 
2170 /*
2171  * Capture the current time status for future reference.
2172  */
2173 void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
2174 
2175 /*
2176  * Compare the time status now with that previously captured to see if the
2177  * timeout has expired.
2178  */
2179 BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
2180 
2181 /*
2182  * Shortcut used by the queue implementation to prevent unnecessary call to
2183  * taskYIELD();
2184  */
2185 void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;
2186 
2187 /*
2188  * Returns the scheduler state as taskSCHEDULER_RUNNING,
2189  * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
2190  */
2191 BaseType_t xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;
2192 
2193 /*
2194  * Raises the priority of the mutex holder to that of the calling task should
2195  * the mutex holder have a priority less than the calling task.
2196  */
2197 void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
2198 
2199 /*
2200  * Set the priority of a task back to its proper priority in the case that it
2201  * inherited a higher priority while it was holding a semaphore.
2202  */
2203 BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGED_FUNCTION;
2204 
2205 /*
2206  * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
2207  */
2208 UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
2209 
2210 /*
2211  * Set the uxTaskNumber of the task referenced by the xTask parameter to
2212  * uxHandle.
2213  */
2214 void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
2215 
2216 /*
2217  * Only available when configUSE_TICKLESS_IDLE is set to 1.
2218  * If tickless mode is being used, or a low power mode is implemented, then
2219  * the tick interrupt will not execute during idle periods. When this is the
2220  * case, the tick count value maintained by the scheduler needs to be kept up
2221  * to date with the actual execution time by being skipped forward by a time
2222  * equal to the idle period.
2223  */
2224 void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;
2225 
2226 /*
2227  * Only avilable when configUSE_TICKLESS_IDLE is set to 1.
2228  * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port
2229  * specific sleep function to determine if it is ok to proceed with the sleep,
2230  * and if it is ok to proceed, if it is ok to sleep indefinitely.
2231  *
2232  * This function is necessary because portSUPPRESS_TICKS_AND_SLEEP() is only
2233  * called with the scheduler suspended, not from within a critical section. It
2234  * is therefore possible for an interrupt to request a context switch between
2235  * portSUPPRESS_TICKS_AND_SLEEP() and the low power mode actually being
2236  * entered. eTaskConfirmSleepModeStatus() should be called from a short
2237  * critical section between the timer being stopped and the sleep mode being
2238  * entered to ensure it is ok to proceed into the sleep mode.
2239  */
2240 eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
2241 
2242 /*
2243  * For internal use only. Increment the mutex held count when a mutex is
2244  * taken and return the handle of the task that has taken the mutex.
2245  */
2246 void *pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
2247 
2248 #ifdef __cplusplus
2249 }
2250 #endif
2251 #endif /* INC_TASK_H */
2252 
2253 
2254 
UBaseType_t uxCurrentPriority
Definition: task.h:173
TaskHandle_t xTaskGetTaskHandle(const char *pcNameToQuery) PRIVILEGED_FUNCTION
UBaseType_t uxPriority
Definition: task.h:160
void vTaskGetTaskInfo(TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState) PRIVILEGED_FUNCTION
void vTaskSwitchContext(void) 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
task.
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
void vTaskSuspendAll(void) PRIVILEGED_FUNCTION
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
task.h
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
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
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
struct xMEMORY_REGION MemoryRegion_t
BaseType_t xTaskRemoveFromUnorderedEventList(ListItem_t *pxEventListItem, const TickType_t xItemValue) PRIVILEGED_FUNCTION
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
BaseType_t(* TaskHookFunction_t)(void *)
Definition: task.h:109
void vTaskEndScheduler(void) PRIVILEGED_FUNCTION
Definition: task.h:126
TickType_t xTaskGetTickCount(void) PRIVILEGED_FUNCTION
Definition: FreeRTOS.h:907
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
UBaseType_t uxTaskGetStackHighWaterMark(TaskHandle_t xTask) PRIVILEGED_FUNCTION
task.h
void vTaskDelayUntil(TickType_t *const pxPreviousWakeTime, const TickType_t xTimeIncrement) PRIVILEGED_FUNCTION
void vTaskSuspend(TaskHandle_t xTaskToSuspend) PRIVILEGED_FUNCTION
TaskHandle_t xTaskGetIdleTaskHandle(void) PRIVILEGED_FUNCTION
xTaskGetIdleTaskHandle() is only available if INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSC...
#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 vTaskPriorityInherit(TaskHandle_t const pxMutexHolder) PRIVILEGED_FUNCTION
UBaseType_t uxTaskGetNumberOfTasks(void) PRIVILEGED_FUNCTION
TaskHandle_t xHandle
Definition: task.h:169
TickType_t uxTaskResetEventItemValue(void) PRIVILEGED_FUNCTION
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
BaseType_t xTaskResumeAll(void) PRIVILEGED_FUNCTION
BaseType_t xTaskGetSchedulerState(void) PRIVILEGED_FUNCTION
struct xTASK_PARAMETERS TaskParameters_t
uint16_t usStackDepth
Definition: task.h:158
uint32_t ulParameters
Definition: task.h:148
Definition: task.h:127
void vTaskSetTimeOutState(TimeOut_t *const pxTimeOut) PRIVILEGED_FUNCTION
eSleepModeStatus eTaskConfirmSleepModeStatus(void) PRIVILEGED_FUNCTION
Definition: task.h:183
uint32_t ulTaskNotifyTake(BaseType_t xClearCountOnExit, TickType_t xTicksToWait) PRIVILEGED_FUNCTION
#define PRIVILEGED_FUNCTION
Definition: mpu_wrappers.h:169
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
TaskFunction_t pvTaskCode
Definition: task.h:156
UBaseType_t uxTaskGetSystemState(TaskStatus_t *const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t *const pulTotalRunTime) PRIVILEGED_FUNCTION
configUSE_TRACE_FACILITY must be defined as 1 in FreeRTOSConfig.h for uxTaskGetSystemState() to be av...
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
void vTaskPlaceOnEventList(List_t *const pxEventList, const TickType_t xTicksToWait) PRIVILEGED_FUNCTION
StackType_t * puxStackBuffer
Definition: task.h:161
char * pcTaskGetName(TaskHandle_t xTaskToQuery) PRIVILEGED_FUNCTION
eTaskState eTaskGetState(TaskHandle_t xTask) PRIVILEGED_FUNCTION
task.