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