task.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*
  2. * FreeRTOS Kernel V10.4.6
  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. #ifndef INC_TASK_H
  29. #define INC_TASK_H
  30. #ifndef INC_FREERTOS_H
  31. #error "include FreeRTOS.h must appear in source files before include task.h"
  32. #endif
  33. /* *INDENT-OFF* */
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. /* *INDENT-ON* */
  38. /*-----------------------------------------------------------
  39. * MACROS AND DEFINITIONS
  40. *----------------------------------------------------------*/
  41. /*
  42. * If tskKERNEL_VERSION_NUMBER ends with + it represents the version in development
  43. * after the numbered release.
  44. *
  45. * The tskKERNEL_VERSION_MAJOR, tskKERNEL_VERSION_MINOR, tskKERNEL_VERSION_BUILD
  46. * values will reflect the last released version number.
  47. */
  48. #define tskKERNEL_VERSION_NUMBER "V10.4.6"
  49. #define tskKERNEL_VERSION_MAJOR 10
  50. #define tskKERNEL_VERSION_MINOR 4
  51. #define tskKERNEL_VERSION_BUILD 6
  52. /**
  53. * task. h
  54. *
  55. * Type by which tasks are referenced. For example, a call to xTaskCreate
  56. * returns (via a pointer parameter) an TaskHandle_t variable that can then
  57. * be used as a parameter to vTaskDelete to delete the task.
  58. *
  59. * \defgroup TaskHandle_t TaskHandle_t
  60. * \ingroup Tasks
  61. */
  62. struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
  63. typedef struct tskTaskControlBlock * TaskHandle_t;
  64. /**
  65. * task. h
  66. *
  67. * Macro for forcing a context switch.
  68. *
  69. * \defgroup taskYIELD taskYIELD
  70. * \ingroup SchedulerControl
  71. */
  72. #define taskYIELD() portYIELD()
  73. /**
  74. * task. h
  75. *
  76. * Macro to mark the start of a critical code region. Preemptive context
  77. * switches cannot occur when in a critical region.
  78. *
  79. * NOTE: This may alter the stack (depending on the portable implementation)
  80. * so must be used with care!
  81. *
  82. * \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
  83. * \ingroup SchedulerControl
  84. */
  85. #define taskENTER_CRITICAL() portENTER_CRITICAL()
  86. #define taskENTER_CRITICAL_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
  87. /**
  88. * task. h
  89. *
  90. * Macro to mark the end of a critical code region. Preemptive context
  91. * switches cannot occur when in a critical region.
  92. *
  93. * NOTE: This may alter the stack (depending on the portable implementation)
  94. * so must be used with care!
  95. *
  96. * \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
  97. * \ingroup SchedulerControl
  98. */
  99. #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
  100. #define taskEXIT_CRITICAL_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( x )
  101. /**
  102. * task. h
  103. *
  104. * Macro to disable all maskable interrupts.
  105. *
  106. * \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
  107. * \ingroup SchedulerControl
  108. */
  109. #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
  110. /**
  111. * task. h
  112. *
  113. * Macro to enable microcontroller interrupts.
  114. *
  115. * \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
  116. * \ingroup SchedulerControl
  117. */
  118. #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
  119. /*-----------------------------------------------------------
  120. * TASK CREATION API
  121. *----------------------------------------------------------*/
  122. /**
  123. * task. h
  124. * @code{c}
  125. * BaseType_t xTaskCreate(
  126. * TaskFunction_t pxTaskCode,
  127. * const char *pcName,
  128. * configSTACK_DEPTH_TYPE usStackDepth,
  129. * void *pvParameters,
  130. * UBaseType_t uxPriority,
  131. * TaskHandle_t *pxCreatedTask
  132. * );
  133. * @endcode
  134. *
  135. * Create a new task and add it to the list of tasks that are ready to run.
  136. *
  137. * Internally, within the FreeRTOS implementation, tasks use two blocks of
  138. * memory. The first block is used to hold the task's data structures. The
  139. * second block is used by the task as its stack. If a task is created using
  140. * xTaskCreate() then both blocks of memory are automatically dynamically
  141. * allocated inside the xTaskCreate() function. (see
  142. * https://www.FreeRTOS.org/a00111.html). If a task is created using
  143. * xTaskCreateStatic() then the application writer must provide the required
  144. * memory. xTaskCreateStatic() therefore allows a task to be created without
  145. * using any dynamic memory allocation.
  146. *
  147. * See xTaskCreateStatic() for a version that does not use any dynamic memory
  148. * allocation.
  149. *
  150. * xTaskCreate() can only be used to create a task that has unrestricted
  151. * access to the entire microcontroller memory map. Systems that include MPU
  152. * support can alternatively create an MPU constrained task using
  153. * xTaskCreateRestricted().
  154. *
  155. * @param pxTaskCode Pointer to the task entry function. Tasks
  156. * must be implemented to never return (i.e. continuous loop).
  157. *
  158. * @param pcName A descriptive name for the task. This is mainly used to
  159. * facilitate debugging. Max length defined by configMAX_TASK_NAME_LEN - default
  160. * is 16.
  161. *
  162. * @param usStackDepth The size of the task stack specified as the number of
  163. * variables the stack can hold - not the number of bytes. For example, if
  164. * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
  165. * will be allocated for stack storage.
  166. *
  167. * @param pvParameters Pointer that will be used as the parameter for the task
  168. * being created.
  169. *
  170. * @param uxPriority The priority at which the task should run. Systems that
  171. * include MPU support can optionally create tasks in a privileged (system)
  172. * mode by setting bit portPRIVILEGE_BIT of the priority parameter. For
  173. * example, to create a privileged task at priority 2 the uxPriority parameter
  174. * should be set to ( 2 | portPRIVILEGE_BIT ).
  175. *
  176. * @param pxCreatedTask Used to pass back a handle by which the created task
  177. * can be referenced.
  178. *
  179. * @return pdPASS if the task was successfully created and added to a ready
  180. * list, otherwise an error code defined in the file projdefs.h
  181. *
  182. * Example usage:
  183. * @code{c}
  184. * // Task to be created.
  185. * void vTaskCode( void * pvParameters )
  186. * {
  187. * for( ;; )
  188. * {
  189. * // Task code goes here.
  190. * }
  191. * }
  192. *
  193. * // Function that creates a task.
  194. * void vOtherFunction( void )
  195. * {
  196. * static uint8_t ucParameterToPass;
  197. * TaskHandle_t xHandle = NULL;
  198. *
  199. * // Create the task, storing the handle. Note that the passed parameter ucParameterToPass
  200. * // must exist for the lifetime of the task, so in this case is declared static. If it was just an
  201. * // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time
  202. * // the new task attempts to access it.
  203. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
  204. * configASSERT( xHandle );
  205. *
  206. * // Use the handle to delete the task.
  207. * if( xHandle != NULL )
  208. * {
  209. * vTaskDelete( xHandle );
  210. * }
  211. * }
  212. * @endcode
  213. * \defgroup xTaskCreate xTaskCreate
  214. * \ingroup Tasks
  215. */
  216. #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  217. BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
  218. const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  219. const configSTACK_DEPTH_TYPE usStackDepth,
  220. void * const pvParameters,
  221. UBaseType_t uxPriority,
  222. TaskHandle_t * const pxCreatedTask );
  223. #endif
  224. /**
  225. * task. h
  226. * @code{c}
  227. * TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
  228. * const char *pcName,
  229. * uint32_t ulStackDepth,
  230. * void *pvParameters,
  231. * UBaseType_t uxPriority,
  232. * StackType_t *puxStackBuffer,
  233. * StaticTask_t *pxTaskBuffer );
  234. * @endcode
  235. *
  236. * Create a new task and add it to the list of tasks that are ready to run.
  237. *
  238. * Internally, within the FreeRTOS implementation, tasks use two blocks of
  239. * memory. The first block is used to hold the task's data structures. The
  240. * second block is used by the task as its stack. If a task is created using
  241. * xTaskCreate() then both blocks of memory are automatically dynamically
  242. * allocated inside the xTaskCreate() function. (see
  243. * https://www.FreeRTOS.org/a00111.html). If a task is created using
  244. * xTaskCreateStatic() then the application writer must provide the required
  245. * memory. xTaskCreateStatic() therefore allows a task to be created without
  246. * using any dynamic memory allocation.
  247. *
  248. * @param pxTaskCode Pointer to the task entry function. Tasks
  249. * must be implemented to never return (i.e. continuous loop).
  250. *
  251. * @param pcName A descriptive name for the task. This is mainly used to
  252. * facilitate debugging. The maximum length of the string is defined by
  253. * configMAX_TASK_NAME_LEN in FreeRTOSConfig.h.
  254. *
  255. * @param ulStackDepth The size of the task stack specified as the number of
  256. * variables the stack can hold - not the number of bytes. For example, if
  257. * the stack is 32-bits wide and ulStackDepth is defined as 100 then 400 bytes
  258. * will be allocated for stack storage.
  259. *
  260. * @param pvParameters Pointer that will be used as the parameter for the task
  261. * being created.
  262. *
  263. * @param uxPriority The priority at which the task will run.
  264. *
  265. * @param puxStackBuffer Must point to a StackType_t array that has at least
  266. * ulStackDepth indexes - the array will then be used as the task's stack,
  267. * removing the need for the stack to be allocated dynamically.
  268. *
  269. * @param pxTaskBuffer Must point to a variable of type StaticTask_t, which will
  270. * then be used to hold the task's data structures, removing the need for the
  271. * memory to be allocated dynamically.
  272. *
  273. * @return If neither puxStackBuffer nor pxTaskBuffer are NULL, then the task
  274. * will be created and a handle to the created task is returned. If either
  275. * puxStackBuffer or pxTaskBuffer are NULL then the task will not be created and
  276. * NULL is returned.
  277. *
  278. * Example usage:
  279. * @code{c}
  280. *
  281. * // Dimensions of the buffer that the task being created will use as its stack.
  282. * // NOTE: This is the number of words the stack will hold, not the number of
  283. * // bytes. For example, if each stack item is 32-bits, and this is set to 100,
  284. * // then 400 bytes (100 * 32-bits) will be allocated.
  285. #define STACK_SIZE 200
  286. *
  287. * // Structure that will hold the TCB of the task being created.
  288. * StaticTask_t xTaskBuffer;
  289. *
  290. * // Buffer that the task being created will use as its stack. Note this is
  291. * // an array of StackType_t variables. The size of StackType_t is dependent on
  292. * // the RTOS port.
  293. * StackType_t xStack[ STACK_SIZE ];
  294. *
  295. * // Function that implements the task being created.
  296. * void vTaskCode( void * pvParameters )
  297. * {
  298. * // The parameter value is expected to be 1 as 1 is passed in the
  299. * // pvParameters value in the call to xTaskCreateStatic().
  300. * configASSERT( ( uint32_t ) pvParameters == 1UL );
  301. *
  302. * for( ;; )
  303. * {
  304. * // Task code goes here.
  305. * }
  306. * }
  307. *
  308. * // Function that creates a task.
  309. * void vOtherFunction( void )
  310. * {
  311. * TaskHandle_t xHandle = NULL;
  312. *
  313. * // Create the task without using any dynamic memory allocation.
  314. * xHandle = xTaskCreateStatic(
  315. * vTaskCode, // Function that implements the task.
  316. * "NAME", // Text name for the task.
  317. * STACK_SIZE, // Stack size in words, not bytes.
  318. * ( void * ) 1, // Parameter passed into the task.
  319. * tskIDLE_PRIORITY,// Priority at which the task is created.
  320. * xStack, // Array to use as the task's stack.
  321. * &xTaskBuffer ); // Variable to hold the task's data structure.
  322. *
  323. * // puxStackBuffer and pxTaskBuffer were not NULL, so the task will have
  324. * // been created, and xHandle will be the task's handle. Use the handle
  325. * // to suspend the task.
  326. * vTaskSuspend( xHandle );
  327. * }
  328. * @endcode
  329. * \defgroup xTaskCreateStatic xTaskCreateStatic
  330. * \ingroup Tasks
  331. */
  332. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  333. TaskHandle_t xTaskCreateStatic( TaskFunction_t pxTaskCode,
  334. const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
  335. const uint32_t ulStackDepth,
  336. void * const pvParameters,
  337. UBaseType_t uxPriority,
  338. StackType_t * const puxStackBuffer,
  339. StaticTask_t * const pxTaskBuffer );
  340. #endif /* configSUPPORT_STATIC_ALLOCATION */
  341. /**
  342. * task. h
  343. * @code{c}
  344. * void vTaskDelete( TaskHandle_t xTaskToDelete );
  345. * @endcode
  346. *
  347. * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
  348. * See the configuration section for more information.
  349. *
  350. * Remove a task from the RTOS real time kernel's management. The task being
  351. * deleted will be removed from all ready, blocked, suspended and event lists.
  352. *
  353. * NOTE: The idle task is responsible for freeing the kernel allocated
  354. * memory from tasks that have been deleted. It is therefore important that
  355. * the idle task is not starved of microcontroller processing time if your
  356. * application makes any calls to vTaskDelete (). Memory allocated by the
  357. * task code is not automatically freed, and should be freed before the task
  358. * is deleted.
  359. *
  360. * See the demo application file death.c for sample code that utilises
  361. * vTaskDelete ().
  362. *
  363. * @param xTaskToDelete The handle of the task to be deleted. Passing NULL will
  364. * cause the calling task to be deleted.
  365. *
  366. * Example usage:
  367. * @code{c}
  368. * void vOtherFunction( void )
  369. * {
  370. * TaskHandle_t xHandle;
  371. *
  372. * // Create the task, storing the handle.
  373. * xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
  374. *
  375. * // Use the handle to delete the task.
  376. * vTaskDelete( xHandle );
  377. * }
  378. * @endcode
  379. * \defgroup vTaskDelete vTaskDelete
  380. * \ingroup Tasks
  381. */
  382. void vTaskDelete( TaskHandle_t xTaskToDelete );
  383. /*-----------------------------------------------------------
  384. * TASK CONTROL API
  385. *----------------------------------------------------------*/
  386. /**
  387. * task. h
  388. * @code{c}
  389. * void vTaskDelay( const TickType_t xTicksToDelay );
  390. * @endcode
  391. *
  392. * Delay a task for a given number of ticks. The actual time that the
  393. * task remains blocked depends on the tick rate. The constant
  394. * portTICK_PERIOD_MS can be used to calculate real time from the tick
  395. * rate - with the resolution of one tick period.
  396. *
  397. * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
  398. * See the configuration section for more information.
  399. *
  400. *
  401. * vTaskDelay() specifies a time at which the task wishes to unblock relative to
  402. * the time at which vTaskDelay() is called. For example, specifying a block
  403. * period of 100 ticks will cause the task to unblock 100 ticks after
  404. * vTaskDelay() is called. vTaskDelay() does not therefore provide a good method
  405. * of controlling the frequency of a periodic task as the path taken through the
  406. * code, as well as other task and interrupt activity, will affect the frequency
  407. * at which vTaskDelay() gets called and therefore the time at which the task
  408. * next executes. See xTaskDelayUntil() for an alternative API function designed
  409. * to facilitate fixed frequency execution. It does this by specifying an
  410. * absolute time (rather than a relative time) at which the calling task should
  411. * unblock.
  412. *
  413. * @param xTicksToDelay The amount of time, in tick periods, that
  414. * the calling task should block.
  415. *
  416. * Example usage:
  417. *
  418. * void vTaskFunction( void * pvParameters )
  419. * {
  420. * // Block for 500ms.
  421. * const TickType_t xDelay = 500 / portTICK_PERIOD_MS;
  422. *
  423. * for( ;; )
  424. * {
  425. * // Simply toggle the LED every 500ms, blocking between each toggle.
  426. * vToggleLED();
  427. * vTaskDelay( xDelay );
  428. * }
  429. * }
  430. *
  431. * \defgroup vTaskDelay vTaskDelay
  432. * \ingroup TaskCtrl
  433. */
  434. void vTaskDelay( const TickType_t xTicksToDelay );
  435. /**
  436. * task. h
  437. * @code{c}
  438. * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
  439. * @endcode
  440. *
  441. * INCLUDE_xTaskDelayUntil must be defined as 1 for this function to be available.
  442. * See the configuration section for more information.
  443. *
  444. * Delay a task until a specified time. This function can be used by periodic
  445. * tasks to ensure a constant execution frequency.
  446. *
  447. * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
  448. * cause a task to block for the specified number of ticks from the time vTaskDelay () is
  449. * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
  450. * execution frequency as the time between a task starting to execute and that task
  451. * calling vTaskDelay () may not be fixed [the task may take a different path though the
  452. * code between calls, or may get interrupted or preempted a different number of times
  453. * each time it executes].
  454. *
  455. * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
  456. * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
  457. * unblock.
  458. *
  459. * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
  460. * time specified in milliseconds with a resolution of one tick period.
  461. *
  462. * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
  463. * task was last unblocked. The variable must be initialised with the current time
  464. * prior to its first use (see the example below). Following this the variable is
  465. * automatically updated within xTaskDelayUntil ().
  466. *
  467. * @param xTimeIncrement The cycle time period. The task will be unblocked at
  468. * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the
  469. * same xTimeIncrement parameter value will cause the task to execute with
  470. * a fixed interface period.
  471. *
  472. * @return Value which can be used to check whether the task was actually delayed.
  473. * Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not
  474. * be delayed if the next expected wake time is in the past.
  475. *
  476. * Example usage:
  477. * @code{c}
  478. * // Perform an action every 10 ticks.
  479. * void vTaskFunction( void * pvParameters )
  480. * {
  481. * TickType_t xLastWakeTime;
  482. * const TickType_t xFrequency = 10;
  483. * BaseType_t xWasDelayed;
  484. *
  485. * // Initialise the xLastWakeTime variable with the current time.
  486. * xLastWakeTime = xTaskGetTickCount ();
  487. * for( ;; )
  488. * {
  489. * // Wait for the next cycle.
  490. * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
  491. *
  492. * // Perform action here. xWasDelayed value can be used to determine
  493. * // whether a deadline was missed if the code here took too long.
  494. * }
  495. * }
  496. * @endcode
  497. * \defgroup xTaskDelayUntil xTaskDelayUntil
  498. * \ingroup TaskCtrl
  499. */
  500. BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
  501. const TickType_t xTimeIncrement );
  502. /*
  503. * vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
  504. * return a value.
  505. */
  506. #define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \
  507. { \
  508. ( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \
  509. }
  510. /*-----------------------------------------------------------
  511. * SCHEDULER CONTROL
  512. *----------------------------------------------------------*/
  513. /**
  514. * task. h
  515. * @code{c}
  516. * void vTaskSuspendAll( void );
  517. * @endcode
  518. *
  519. * Suspends the scheduler without disabling interrupts. Context switches will
  520. * not occur while the scheduler is suspended.
  521. *
  522. * After calling vTaskSuspendAll () the calling task will continue to execute
  523. * without risk of being swapped out until a call to xTaskResumeAll () has been
  524. * made.
  525. *
  526. * API functions that have the potential to cause a context switch (for example,
  527. * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
  528. * is suspended.
  529. *
  530. * Example usage:
  531. * @code{c}
  532. * void vTask1( void * pvParameters )
  533. * {
  534. * for( ;; )
  535. * {
  536. * // Task code goes here.
  537. *
  538. * // ...
  539. *
  540. * // At some point the task wants to perform a long operation during
  541. * // which it does not want to get swapped out. It cannot use
  542. * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
  543. * // operation may cause interrupts to be missed - including the
  544. * // ticks.
  545. *
  546. * // Prevent the real time kernel swapping out the task.
  547. * vTaskSuspendAll ();
  548. *
  549. * // Perform the operation here. There is no need to use critical
  550. * // sections as we have all the microcontroller processing time.
  551. * // During this time interrupts will still operate and the kernel
  552. * // tick count will be maintained.
  553. *
  554. * // ...
  555. *
  556. * // The operation is complete. Restart the kernel.
  557. * xTaskResumeAll ();
  558. * }
  559. * }
  560. * @endcode
  561. * \defgroup vTaskSuspendAll vTaskSuspendAll
  562. * \ingroup SchedulerControl
  563. */
  564. void vTaskSuspendAll( void );
  565. /**
  566. * task. h
  567. * @code{c}
  568. * BaseType_t xTaskResumeAll( void );
  569. * @endcode
  570. *
  571. * Resumes scheduler activity after it was suspended by a call to
  572. * vTaskSuspendAll().
  573. *
  574. * xTaskResumeAll() only resumes the scheduler. It does not unsuspend tasks
  575. * that were previously suspended by a call to vTaskSuspend().
  576. *
  577. * @return If resuming the scheduler caused a context switch then pdTRUE is
  578. * returned, otherwise pdFALSE is returned.
  579. *
  580. * Example usage:
  581. * @code{c}
  582. * void vTask1( void * pvParameters )
  583. * {
  584. * for( ;; )
  585. * {
  586. * // Task code goes here.
  587. *
  588. * // ...
  589. *
  590. * // At some point the task wants to perform a long operation during
  591. * // which it does not want to get swapped out. It cannot use
  592. * // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
  593. * // operation may cause interrupts to be missed - including the
  594. * // ticks.
  595. *
  596. * // Prevent the real time kernel swapping out the task.
  597. * vTaskSuspendAll ();
  598. *
  599. * // Perform the operation here. There is no need to use critical
  600. * // sections as we have all the microcontroller processing time.
  601. * // During this time interrupts will still operate and the real
  602. * // time kernel tick count will be maintained.
  603. *
  604. * // ...
  605. *
  606. * // The operation is complete. Restart the kernel. We want to force
  607. * // a context switch - but there is no point if resuming the scheduler
  608. * // caused a context switch already.
  609. * if( !xTaskResumeAll () )
  610. * {
  611. * taskYIELD ();
  612. * }
  613. * }
  614. * }
  615. * @endcode
  616. * \defgroup xTaskResumeAll xTaskResumeAll
  617. * \ingroup SchedulerControl
  618. */
  619. BaseType_t xTaskResumeAll( void );
  620. /* *INDENT-OFF* */
  621. #ifdef __cplusplus
  622. }
  623. #endif
  624. /* *INDENT-ON* */
  625. #endif /* INC_TASK_H */