2 FreeRTOS.org V4.4.0 - Copyright (C) 2003-2007 Richard Barry.
4 This file is part of the FreeRTOS.org distribution.
6 FreeRTOS.org is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 FreeRTOS.org is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with FreeRTOS.org; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 A special exception to the GPL can be applied should you wish to distribute
21 a combined work that includes FreeRTOS.org, without being obliged to provide
22 the source code for any proprietary components. See the licensing section
23 of http://www.FreeRTOS.org for full details of how and when the exception
26 ***************************************************************************
27 See http://www.FreeRTOS.org for documentation, latest information, license
28 and contact details. Please ensure to read the configuration and relevant
29 port sections of the online documentation.
31 Also see http://www.SafeRTOS.com for an IEC 61508 compliant version along
32 with commercial development and support options.
33 ***************************************************************************
39 + Added xTaskGetSchedulerState() function.
48 /*-----------------------------------------------------------
49 * MACROS AND DEFINITIONS
50 *----------------------------------------------------------*/
52 #define tskKERNEL_VERSION_NUMBER "V4.4.0"
57 * Type by which tasks are referenced. For example, a call to xTaskCreate
58 * returns (via a pointer parameter) an xTaskHandle variable that can then
59 * be used as a parameter to vTaskDelete to delete the task.
61 * \page xTaskHandle xTaskHandle
64 typedef void * xTaskHandle;
67 * Used internally only.
69 typedef struct xTIME_OUT
71 portBASE_TYPE xOverflowCount;
72 portTickType xTimeOnEntering;
76 * Defines the priority used by the idle task. This must not be modified.
80 #define tskIDLE_PRIORITY ( ( unsigned portBASE_TYPE ) 0 )
85 * Macro for forcing a context switch.
87 * \page taskYIELD taskYIELD
88 * \ingroup SchedulerControl
90 #define taskYIELD() portYIELD()
95 * Macro to mark the start of a critical code region. Preemptive context
96 * switches cannot occur when in a critical region.
98 * NOTE: This may alter the stack (depending on the portable implementation)
99 * so must be used with care!
101 * \page taskENTER_CRITICAL taskENTER_CRITICAL
102 * \ingroup SchedulerControl
104 #define taskENTER_CRITICAL() portENTER_CRITICAL()
109 * Macro to mark the end of a critical code region. Preemptive context
110 * switches cannot occur when in a critical region.
112 * NOTE: This may alter the stack (depending on the portable implementation)
113 * so must be used with care!
115 * \page taskEXIT_CRITICAL taskEXIT_CRITICAL
116 * \ingroup SchedulerControl
118 #define taskEXIT_CRITICAL() portEXIT_CRITICAL()
123 * Macro to disable all maskable interrupts.
125 * \page taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
126 * \ingroup SchedulerControl
128 #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
133 * Macro to enable microcontroller interrupts.
135 * \page taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
136 * \ingroup SchedulerControl
138 #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
140 /* Definitions returned by xTaskGetSchedulerState(). */
141 #define taskSCHEDULER_NOT_STARTED 0
142 #define taskSCHEDULER_RUNNING 1
143 #define taskSCHEDULER_SUSPENDED 2
145 /*-----------------------------------------------------------
147 *----------------------------------------------------------*/
152 portBASE_TYPE xTaskCreate(
153 pdTASK_CODE pvTaskCode,
154 const portCHAR * const pcName,
155 unsigned portSHORT usStackDepth,
157 unsigned portBASE_TYPE uxPriority,
158 xTaskHandle *pvCreatedTask
161 * Create a new task and add it to the list of tasks that are ready to run.
163 * @param pvTaskCode Pointer to the task entry function. Tasks
164 * must be implemented to never return (i.e. continuous loop).
166 * @param pcName A descriptive name for the task. This is mainly used to
167 * facilitate debugging. Max length defined by tskMAX_TASK_NAME_LEN - default
170 * @param usStackDepth The size of the task stack specified as the number of
171 * variables the stack can hold - not the number of bytes. For example, if
172 * the stack is 16 bits wide and usStackDepth is defined as 100, 200 bytes
173 * will be allocated for stack storage.
175 * @param pvParameters Pointer that will be used as the parameter for the task
178 * @param uxPriority The priority at which the task should run.
180 * @param pvCreatedTask Used to pass back a handle by which the created task
183 * @return pdPASS if the task was successfully created and added to a ready
184 * list, otherwise an error code defined in the file errors. h
188 // Task to be created.
189 void vTaskCode( void * pvParameters )
193 // Task code goes here.
197 // Function that creates a task.
198 void vOtherFunction( void )
200 unsigned char ucParameterToPass;
203 // Create the task, storing the handle.
204 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );
206 // Use the handle to delete the task.
207 vTaskDelete( xHandle );
210 * \defgroup xTaskCreate xTaskCreate
213 signed portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, const signed portCHAR * const pcName, unsigned portSHORT usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pvCreatedTask );
217 * <pre>void vTaskDelete( xTaskHandle pxTask );</pre>
219 * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
220 * See the configuration section for more information.
222 * Remove a task from the RTOS real time kernels management. The task being
223 * deleted will be removed from all ready, blocked, suspended and event lists.
225 * NOTE: The idle task is responsible for freeing the kernel allocated
226 * memory from tasks that have been deleted. It is therefore important that
227 * the idle task is not starved of microcontroller processing time if your
228 * application makes any calls to vTaskDelete (). Memory allocated by the
229 * task code is not automatically freed, and should be freed before the task
232 * See the demo application file death.c for sample code that utilises
235 * @param pxTask The handle of the task to be deleted. Passing NULL will
236 * cause the calling task to be deleted.
240 void vOtherFunction( void )
244 // Create the task, storing the handle.
245 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
247 // Use the handle to delete the task.
248 vTaskDelete( xHandle );
251 * \defgroup vTaskDelete vTaskDelete
254 void vTaskDelete( xTaskHandle pxTask );
257 /*-----------------------------------------------------------
259 *----------------------------------------------------------*/
263 * <pre>void vTaskDelay( portTickType xTicksToDelay );</pre>
265 * Delay a task for a given number of ticks. The actual time that the
266 * task remains blocked depends on the tick rate. The constant
267 * portTICK_RATE_MS can be used to calculate real time from the tick
268 * rate - with the resolution of one tick period.
270 * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
271 * See the configuration section for more information.
273 * @param xTicksToDelay The amount of time, in tick periods, that
274 * the calling task should block.
278 // Wait 10 ticks before performing an action.
280 // This is for demonstration only and would be better achieved
281 // using vTaskDelayUntil ().
282 void vTaskFunction( void * pvParameters )
284 portTickType xDelay, xNextTime;
286 // Calc the time at which we want to perform the action
288 xNextTime = xTaskGetTickCount () + ( portTickType ) 10;
292 xDelay = xNextTime - xTaskGetTickCount ();
293 xNextTime += ( portTickType ) 10;
295 // Guard against overflow
296 if( xDelay <= ( portTickType ) 10 )
298 vTaskDelay( xDelay );
301 // Perform action here.
305 * \defgroup vTaskDelay vTaskDelay
308 void vTaskDelay( portTickType xTicksToDelay );
312 * <pre>void vTaskDelayUntil( portTickType *pxPreviousWakeTime, portTickType xTimeIncrement );</pre>
314 * INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available.
315 * See the configuration section for more information.
317 * Delay a task until a specified time. This function can be used by cyclical
318 * tasks to ensure a constant execution frequency.
320 * This function differs from vTaskDelay () in one important aspect: vTaskDelay () will
321 * cause a task to block for the specified number of ticks from the time vTaskDelay () is
322 * called. It is therefore difficult to use vTaskDelay () by itself to generate a fixed
323 * execution frequency as the time between a task starting to execute and that task
324 * calling vTaskDelay () may not be fixed [the task may take a different path though the
325 * code between calls, or may get interrupted or preempted a different number of times
326 * each time it executes].
328 * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
329 * is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
332 * The constant portTICK_RATE_MS can be used to calculate real time from the tick
333 * rate - with the resolution of one tick period.
335 * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
336 * task was last unblocked. The variable must be initialised with the current time
337 * prior to its first use (see the example below). Following this the variable is
338 * automatically updated within vTaskDelayUntil ().
340 * @param xTimeIncrement The cycle time period. The task will be unblocked at
341 * time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the
342 * same xTimeIncrement parameter value will cause the task to execute with
343 * a fixed interface period.
347 // Perform an action every 10 ticks.
348 void vTaskFunction( void * pvParameters )
350 portTickType xLastWakeTime;
351 const portTickType xFrequency = 10;
353 // Initialise the xLastWakeTime variable with the current time.
354 xLastWakeTime = xTaskGetTickCount ();
357 // Wait for the next cycle.
358 vTaskDelayUntil( &xLastWakeTime, xFrequency );
360 // Perform action here.
364 * \defgroup vTaskDelayUntil vTaskDelayUntil
367 void vTaskDelayUntil( portTickType *pxPreviousWakeTime, portTickType xTimeIncrement );
371 * <pre>unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );</pre>
373 * INCLUDE_xTaskPriorityGet must be defined as 1 for this function to be available.
374 * See the configuration section for more information.
376 * Obtain the priority of any task.
378 * @param pxTask Handle of the task to be queried. Passing a NULL
379 * handle results in the priority of the calling task being returned.
381 * @return The priority of pxTask.
385 void vAFunction( void )
389 // Create a task, storing the handle.
390 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
394 // Use the handle to obtain the priority of the created task.
395 // It was created with tskIDLE_PRIORITY, but may have changed
397 if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )
399 // The task has changed it's priority.
404 // Is our priority higher than the created task?
405 if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )
407 // Our priority (obtained using NULL handle) is higher.
411 * \defgroup uxTaskPriorityGet uxTaskPriorityGet
414 unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );
418 * <pre>void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );</pre>
420 * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
421 * See the configuration section for more information.
423 * Set the priority of any task.
425 * A context switch will occur before the function returns if the priority
426 * being set is higher than the currently executing task.
428 * @param pxTask Handle to the task for which the priority is being set.
429 * Passing a NULL handle results in the priority of the calling task being set.
431 * @param uxNewPriority The priority to which the task will be set.
435 void vAFunction( void )
439 // Create a task, storing the handle.
440 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
444 // Use the handle to raise the priority of the created task.
445 vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );
449 // Use a NULL handle to raise our priority to the same value.
450 vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
453 * \defgroup vTaskPrioritySet vTaskPrioritySet
456 void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );
460 * <pre>void vTaskSuspend( xTaskHandle pxTaskToSuspend );</pre>
462 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
463 * See the configuration section for more information.
465 * Suspend any task. When suspended a task will never get any microcontroller
466 * processing time, no matter what its priority.
468 * Calls to vTaskSuspend are not accumulative -
469 * i.e. calling vTaskSuspend () twice on the same task still only requires one
470 * call to vTaskResume () to ready the suspended task.
472 * @param pxTaskToSuspend Handle to the task being suspended. Passing a NULL
473 * handle will cause the calling task to be suspended.
477 void vAFunction( void )
481 // Create a task, storing the handle.
482 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
486 // Use the handle to suspend the created task.
487 vTaskSuspend( xHandle );
491 // The created task will not run during this period, unless
492 // another task calls vTaskResume( xHandle ).
497 // Suspend ourselves.
498 vTaskSuspend( NULL );
500 // We cannot get here unless another task calls vTaskResume
501 // with our handle as the parameter.
504 * \defgroup vTaskSuspend vTaskSuspend
507 void vTaskSuspend( xTaskHandle pxTaskToSuspend );
511 * <pre>void vTaskResume( xTaskHandle pxTaskToResume );</pre>
513 * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
514 * See the configuration section for more information.
516 * Resumes a suspended task.
518 * A task that has been suspended by one of more calls to vTaskSuspend ()
519 * will be made available for running again by a single call to
522 * @param pxTaskToResume Handle to the task being readied.
526 void vAFunction( void )
530 // Create a task, storing the handle.
531 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
535 // Use the handle to suspend the created task.
536 vTaskSuspend( xHandle );
540 // The created task will not run during this period, unless
541 // another task calls vTaskResume( xHandle ).
546 // Resume the suspended task ourselves.
547 vTaskResume( xHandle );
549 // The created task will once again get microcontroller processing
550 // time in accordance with it priority within the system.
553 * \defgroup vTaskResume vTaskResume
556 void vTaskResume( xTaskHandle pxTaskToResume );
560 * <pre>void xTaskResumeFromISR( xTaskHandle pxTaskToResume );</pre>
562 * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
563 * available. See the configuration section for more information.
565 * An implementation of vTaskResume() that can be called from within an ISR.
567 * A task that has been suspended by one of more calls to vTaskSuspend ()
568 * will be made available for running again by a single call to
569 * xTaskResumeFromISR ().
571 * @param pxTaskToResume Handle to the task being readied.
573 * \defgroup vTaskResumeFromISR vTaskResumeFromISR
576 portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume );
578 /*-----------------------------------------------------------
580 *----------------------------------------------------------*/
584 * <pre>void vTaskStartScheduler( void );</pre>
586 * Starts the real time kernel tick processing. After calling the kernel
587 * has control over which tasks are executed and when. This function
588 * does not return until an executing task calls vTaskEndScheduler ().
590 * At least one task should be created via a call to xTaskCreate ()
591 * before calling vTaskStartScheduler (). The idle task is created
592 * automatically when the first application task is created.
594 * See the demo application file main.c for an example of creating
595 * tasks and starting the kernel.
599 void vAFunction( void )
601 // Create at least one task before starting the kernel.
602 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
604 // Start the real time kernel with preemption.
605 vTaskStartScheduler ();
607 // Will not get here unless a task calls vTaskEndScheduler ()
611 * \defgroup vTaskStartScheduler vTaskStartScheduler
612 * \ingroup SchedulerControl
614 void vTaskStartScheduler( void );
618 * <pre>void vTaskEndScheduler( void );</pre>
620 * Stops the real time kernel tick. All created tasks will be automatically
621 * deleted and multitasking (either preemptive or cooperative) will
622 * stop. Execution then resumes from the point where vTaskStartScheduler ()
623 * was called, as if vTaskStartScheduler () had just returned.
625 * See the demo application file main. c in the demo/PC directory for an
626 * example that uses vTaskEndScheduler ().
628 * vTaskEndScheduler () requires an exit function to be defined within the
629 * portable layer (see vPortEndScheduler () in port. c for the PC port). This
630 * performs hardware specific operations such as stopping the kernel tick.
632 * vTaskEndScheduler () will cause all of the resources allocated by the
633 * kernel to be freed - but will not free resources allocated by application
638 void vTaskCode( void * pvParameters )
642 // Task code goes here.
644 // At some point we want to end the real time kernel processing
646 vTaskEndScheduler ();
650 void vAFunction( void )
652 // Create at least one task before starting the kernel.
653 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
655 // Start the real time kernel with preemption.
656 vTaskStartScheduler ();
658 // Will only get here when the vTaskCode () task has called
659 // vTaskEndScheduler (). When we get here we are back to single task
664 * \defgroup vTaskEndScheduler vTaskEndScheduler
665 * \ingroup SchedulerControl
667 void vTaskEndScheduler( void );
671 * <pre>void vTaskSuspendAll( void );</pre>
673 * Suspends all real time kernel activity while keeping interrupts (including the
674 * kernel tick) enabled.
676 * After calling vTaskSuspendAll () the calling task will continue to execute
677 * without risk of being swapped out until a call to xTaskResumeAll () has been
682 void vTask1( void * pvParameters )
686 // Task code goes here.
690 // At some point the task wants to perform a long operation during
691 // which it does not want to get swapped out. It cannot use
692 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
693 // operation may cause interrupts to be missed - including the
696 // Prevent the real time kernel swapping out the task.
699 // Perform the operation here. There is no need to use critical
700 // sections as we have all the microcontroller processing time.
701 // During this time interrupts will still operate and the kernel
702 // tick count will be maintained.
706 // The operation is complete. Restart the kernel.
711 * \defgroup vTaskSuspendAll vTaskSuspendAll
712 * \ingroup SchedulerControl
714 void vTaskSuspendAll( void );
718 * <pre>portCHAR xTaskResumeAll( void );</pre>
720 * Resumes real time kernel activity following a call to vTaskSuspendAll ().
721 * After a call to vTaskSuspendAll () the kernel will take control of which
722 * task is executing at any time.
724 * @return If resuming the scheduler caused a context switch then pdTRUE is
725 * returned, otherwise pdFALSE is returned.
729 void vTask1( void * pvParameters )
733 // Task code goes here.
737 // At some point the task wants to perform a long operation during
738 // which it does not want to get swapped out. It cannot use
739 // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the
740 // operation may cause interrupts to be missed - including the
743 // Prevent the real time kernel swapping out the task.
746 // Perform the operation here. There is no need to use critical
747 // sections as we have all the microcontroller processing time.
748 // During this time interrupts will still operate and the real
749 // time kernel tick count will be maintained.
753 // The operation is complete. Restart the kernel. We want to force
754 // a context switch - but there is no point if resuming the scheduler
755 // caused a context switch already.
756 if( !xTaskResumeAll () )
763 * \defgroup xTaskResumeAll xTaskResumeAll
764 * \ingroup SchedulerControl
766 signed portBASE_TYPE xTaskResumeAll( void );
769 /*-----------------------------------------------------------
771 *----------------------------------------------------------*/
775 * <PRE>volatile portTickType xTaskGetTickCount( void );</PRE>
777 * @return The count of ticks since vTaskStartScheduler was called.
779 * \page xTaskGetTickCount xTaskGetTickCount
782 portTickType xTaskGetTickCount( void );
786 * <PRE>unsigned portSHORT uxTaskGetNumberOfTasks( void );</PRE>
788 * @return The number of tasks that the real time kernel is currently managing.
789 * This includes all ready, blocked and suspended tasks. A task that
790 * has been deleted but not yet freed by the idle task will also be
791 * included in the count.
793 * \page uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
796 unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void );
800 * <PRE>void vTaskList( portCHAR *pcWriteBuffer );</PRE>
802 * configUSE_TRACE_FACILITY, INCLUDE_vTaskDelete and INCLUDE_vTaskSuspend
803 * must all be defined as 1 for this function to be available.
804 * See the configuration section for more information.
806 * NOTE: This function will disable interrupts for its duration. It is
807 * not intended for normal application runtime use but as a debug aid.
809 * Lists all the current tasks, along with their current state and stack
810 * usage high water mark.
812 * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
815 * @param pcWriteBuffer A buffer into which the above mentioned details
816 * will be written, in ascii form. This buffer is assumed to be large
817 * enough to contain the generated report. Approximately 40 bytes per
818 * task should be sufficient.
820 * \page vTaskList vTaskList
823 void vTaskList( signed portCHAR *pcWriteBuffer );
827 * <PRE>void vTaskStartTrace( portCHAR * pcBuffer, unsigned portBASE_TYPE uxBufferSize );</PRE>
829 * Starts a real time kernel activity trace. The trace logs the identity of
830 * which task is running when.
832 * The trace file is stored in binary format. A separate DOS utility called
833 * convtrce.exe is used to convert this into a tab delimited text file which
834 * can be viewed and plotted in a spread sheet.
836 * @param pcBuffer The buffer into which the trace will be written.
838 * @param ulBufferSize The size of pcBuffer in bytes. The trace will continue
839 * until either the buffer in full, or ulTaskEndTrace () is called.
841 * \page vTaskStartTrace vTaskStartTrace
844 void vTaskStartTrace( signed portCHAR * pcBuffer, unsigned portLONG ulBufferSize );
848 * <PRE>unsigned portLONG ulTaskEndTrace( void );</PRE>
850 * Stops a kernel activity trace. See vTaskStartTrace ().
852 * @return The number of bytes that have been written into the trace buffer.
854 * \page usTaskEndTrace usTaskEndTrace
857 unsigned portLONG ulTaskEndTrace( void );
860 /*-----------------------------------------------------------
861 * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES
862 *----------------------------------------------------------*/
865 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
866 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
867 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
869 * Called from the real time kernel tick (either preemptive or cooperative),
870 * this increments the tick count and checks if any tasks that are blocked
871 * for a finite period required removing from a blocked list and placing on
874 inline void vTaskIncrementTick( void );
877 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
878 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
880 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
882 * Removes the calling task from the ready list and places it both
883 * on the list of tasks waiting for a particular event, and the
884 * list of delayed tasks. The task will be removed from both lists
885 * and replaced on the ready list should either the event occur (and
886 * there be no higher priority tasks waiting on the same event) or
887 * the delay period expires.
889 * @param pxEventList The list containing tasks that are blocked waiting
890 * for the event to occur.
892 * @param xTicksToWait The maximum amount of time that the task should wait
893 * for the event to occur. This is specified in kernel ticks,the constant
894 * portTICK_RATE_MS can be used to convert kernel ticks into a real time
897 void vTaskPlaceOnEventList( xList *pxEventList, portTickType xTicksToWait );
900 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
901 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
903 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.
905 * Removes a task from both the specified event list and the list of blocked
906 * tasks, and places it on a ready queue.
908 * xTaskRemoveFromEventList () will be called if either an event occurs to
909 * unblock a task, or the block timeout period expires.
911 * @return pdTRUE if the task being removed has a higher priority than the task
912 * making the call, otherwise pdFALSE.
914 signed portBASE_TYPE xTaskRemoveFromEventList( const xList *pxEventList );
917 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
918 * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
920 * INCLUDE_vTaskCleanUpResources and INCLUDE_vTaskSuspend must be defined as 1
921 * for this function to be available.
922 * See the configuration section for more information.
924 * Empties the ready and delayed queues of task control blocks, freeing the
925 * memory allocated for the task control block and task stacks as it goes.
927 void vTaskCleanUpResources( void );
930 * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
931 * INTENDED FOR USE WHEN IMPLEMENTING A PORT OF THE SCHEDULER AND IS
932 * AN INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.
934 * Sets the pointer to the current TCB to the TCB of the highest priority task
935 * that is ready to run.
937 inline void vTaskSwitchContext( void );
940 * Return the handle of the calling task.
942 xTaskHandle xTaskGetCurrentTaskHandle( void );
945 * Capture the current time status for future reference.
947 void vTaskSetTimeOutState( xTimeOutType *pxTimeOut );
950 * Compare the time status now with that previously captured to see if the
951 * timeout has expired.
953 portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType *pxTimeOut, portTickType * const pxTicksToWait );
956 * Shortcut used by the queue implementation to prevent unnecessary call to
959 void vTaskMissedYield( void );
962 * Returns the scheduler state as taskSCHEDULER_RUNNING,
963 * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.
965 portBASE_TYPE xTaskGetSchedulerState( void );