]> git.sur5r.net Git - freertos/blobdiff - Source/include/task.h
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Source / include / task.h
index 56ca2535021272f4426ad0bf5d136a342ebedfc6..3f462ff3ee8e947041650d7b34eb210e523d9cf2 100644 (file)
@@ -1,46 +1,90 @@
 /*\r
-       FreeRTOS.org V4.0.5 - Copyright (C) 2003-2006 Richard Barry.\r
-\r
-       This file is part of the FreeRTOS.org distribution.\r
-\r
-       FreeRTOS.org is free software; you can redistribute it and/or modify\r
-       it under the terms of the GNU General Public License as published by\r
-       the Free Software Foundation; either version 2 of the License, or\r
-       (at your option) any later version.\r
-\r
-       FreeRTOS.org is distributed in the hope that it will be useful,\r
-       but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-       GNU General Public License for more details.\r
-\r
-       You should have received a copy of the GNU General Public License\r
-       along with FreeRTOS.org; if not, write to the Free Software\r
-       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
-\r
-       A special exception to the GPL can be applied should you wish to distribute\r
-       a combined work that includes FreeRTOS.org, without being obliged to provide\r
-       the source code for any proprietary components.  See the licensing section\r
-       of http://www.FreeRTOS.org for full details of how and when the exception\r
-       can be applied.\r
-\r
-       ***************************************************************************\r
-       See http://www.FreeRTOS.org for documentation, latest information, license\r
-       and contact details.  Please ensure to read the configuration and relevant\r
-       port sections of the online documentation.\r
-       ***************************************************************************\r
+    FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.\r
+\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
+     *    Complete, revised, and edited pdf reference manuals are also       *\r
+     *    available.                                                         *\r
+     *                                                                       *\r
+     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
+     *    ensuring you get running as quickly as possible and with an        *\r
+     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
+     *    the FreeRTOS project to continue with its mission of providing     *\r
+     *    professional grade, cross platform, de facto standard solutions    *\r
+     *    for microcontrollers - completely free of charge!                  *\r
+     *                                                                       *\r
+     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
+     *                                                                       *\r
+     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+    >>>NOTE<<< The modification to the GPL is included to allow you to\r
+    distribute a combined work that includes FreeRTOS without being obliged to\r
+    provide the source code for proprietary components outside of the FreeRTOS\r
+    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
+    more details. You should have received a copy of the GNU General Public\r
+    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+    by writing to Richard Barry, contact details for whom are available on the\r
+    FreeRTOS WEB site.\r
+\r
+    1 tab == 4 spaces!\r
+\r
+       \r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+        *    not run, what could be wrong?                                      *\r
+        *                                                                       *\r
+        *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+        *                                                                       *\r
+    ***************************************************************************\r
+\r
+       \r
+    http://www.FreeRTOS.org - Documentation, training, latest information, \r
+    license and contact details.\r
+       \r
+       http://www.FreeRTOS.org/plus - Selection of FreeRTOS ecosystem products,\r
+       including FreeRTOS+Trace - an indispensable productivity tool.\r
+\r
+       Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
+       the code with commercial support, indemnification, and middleware, under \r
+       the OpenRTOS brand:  http://www.OpenRTOS.com.  High Integrity Systems also\r
+       provide a safety engineered and independently SIL3 certified version under \r
+       the     SafeRTOS brand: http://www.SafeRTOS.com.\r
 */\r
 \r
+\r
 #ifndef TASK_H\r
 #define TASK_H\r
 \r
+#ifndef INC_FREERTOS_H\r
+       #error "include FreeRTOS.h must appear in source files before include task.h"\r
+#endif\r
+\r
 #include "portable.h"\r
 #include "list.h"\r
 \r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
 /*-----------------------------------------------------------\r
  * MACROS AND DEFINITIONS\r
  *----------------------------------------------------------*/\r
 \r
-#define tskKERNEL_VERSION_NUMBER "V4.0.5"\r
+#define tskKERNEL_VERSION_NUMBER "V7.1.1"\r
 \r
 /**\r
  * task. h\r
@@ -59,16 +103,40 @@ typedef void * xTaskHandle;
  */\r
 typedef struct xTIME_OUT\r
 {\r
-    portBASE_TYPE xOverflowCount;\r
-    portTickType  xTimeOnEntering;\r
+       portBASE_TYPE xOverflowCount;\r
+       portTickType  xTimeOnEntering;\r
 } xTimeOutType;\r
 \r
+/*\r
+ * Defines the memory ranges allocated to the task when an MPU is used.\r
+ */\r
+typedef struct xMEMORY_REGION\r
+{\r
+       void *pvBaseAddress;\r
+       unsigned long ulLengthInBytes;\r
+       unsigned long ulParameters;\r
+} xMemoryRegion;\r
+\r
+/*\r
+ * Parameters required to create an MPU protected task.\r
+ */\r
+typedef struct xTASK_PARAMTERS\r
+{\r
+       pdTASK_CODE pvTaskCode;\r
+       const signed char * const pcName;\r
+       unsigned short usStackDepth;\r
+       void *pvParameters;\r
+       unsigned portBASE_TYPE uxPriority;\r
+       portSTACK_TYPE *puxStackBuffer;\r
+       xMemoryRegion xRegions[ portNUM_CONFIGURABLE_REGIONS ];\r
+} xTaskParameters;\r
+\r
 /*\r
  * Defines the priority used by the idle task.  This must not be modified.\r
  *\r
  * \ingroup TaskUtils\r
  */\r
-#define tskIDLE_PRIORITY                       ( ( unsigned portBASE_TYPE ) 0 )\r
+#define tskIDLE_PRIORITY                       ( ( unsigned portBASE_TYPE ) 0U )\r
 \r
 /**\r
  * task. h\r
@@ -128,6 +196,10 @@ typedef struct xTIME_OUT
  */\r
 #define taskENABLE_INTERRUPTS()                portENABLE_INTERRUPTS()\r
 \r
+/* Definitions returned by xTaskGetSchedulerState(). */\r
+#define taskSCHEDULER_NOT_STARTED      0\r
+#define taskSCHEDULER_RUNNING          1\r
+#define taskSCHEDULER_SUSPENDED                2\r
 \r
 /*-----------------------------------------------------------\r
  * TASK CREATION API\r
@@ -137,16 +209,21 @@ typedef struct xTIME_OUT
  * task. h\r
  *<pre>\r
  portBASE_TYPE xTaskCreate(\r
-                              pdTASK_CODE pvTaskCode,\r
-                              const portCHAR * const pcName,\r
-                              unsigned portSHORT usStackDepth,\r
-                              void *pvParameters,\r
-                              unsigned portBASE_TYPE uxPriority,\r
-                              xTaskHandle *pvCreatedTask\r
-                          );</pre>\r
+                                                         pdTASK_CODE pvTaskCode,\r
+                                                         const char * const pcName,\r
+                                                         unsigned short usStackDepth,\r
+                                                         void *pvParameters,\r
+                                                         unsigned portBASE_TYPE uxPriority,\r
+                                                         xTaskHandle *pvCreatedTask\r
+                                                 );</pre>\r
  *\r
  * Create a new task and add it to the list of tasks that are ready to run.\r
  *\r
+ * xTaskCreate() can only be used to create a task that has unrestricted\r
+ * access to the entire microcontroller memory map.  Systems that include MPU\r
+ * support can alternatively create an MPU constrained task using\r
+ * xTaskCreateRestricted().\r
+ *\r
  * @param pvTaskCode Pointer to the task entry function.  Tasks\r
  * must be implemented to never return (i.e. continuous loop).\r
  *\r
@@ -162,7 +239,11 @@ typedef struct xTIME_OUT
  * @param pvParameters Pointer that will be used as the parameter for the task\r
  * being created.\r
  *\r
- * @param uxPriority The priority at which the task should run.\r
+ * @param uxPriority The priority at which the task should run.  Systems that\r
+ * include MPU support can optionally create tasks in a privileged (system)\r
+ * mode by setting bit portPRIVILEGE_BIT of the priority parameter.  For\r
+ * example, to create a privileged task at priority 2 the uxPriority parameter\r
+ * should be set to ( 2 | portPRIVILEGE_BIT ).\r
  *\r
  * @param pvCreatedTask Used to pass back a handle by which the created task\r
  * can be referenced.\r
@@ -175,29 +256,149 @@ typedef struct xTIME_OUT
  // Task to be created.\r
  void vTaskCode( void * pvParameters )\r
  {\r
-     for( ;; )\r
-     {\r
-         // Task code goes here.\r
-     }\r
+        for( ;; )\r
+        {\r
+                // Task code goes here.\r
+        }\r
  }\r
 \r
  // Function that creates a task.\r
  void vOtherFunction( void )\r
  {\r
- unsigned char ucParameterToPass;\r
static unsigned char ucParameterToPass;\r
  xTaskHandle xHandle;\r
-               \r
-     // Create the task, storing the handle.\r
-     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );\r
-               \r
-     // Use the handle to delete the task.\r
-     vTaskDelete( xHandle );\r
+\r
+        // Create the task, storing the handle.  Note that the passed parameter ucParameterToPass\r
+        // must exist for the lifetime of the task, so in this case is declared static.  If it was just an\r
+        // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time\r
+        // the new task attempts to access it.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );\r
+\r
+        // Use the handle to delete the task.\r
+        vTaskDelete( xHandle );\r
  }\r
    </pre>\r
  * \defgroup xTaskCreate xTaskCreate\r
  * \ingroup Tasks\r
  */\r
-signed portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, const signed portCHAR * const pcName, unsigned portSHORT usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pvCreatedTask );\r
+#define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL ) )\r
+\r
+/**\r
+ * task. h\r
+ *<pre>\r
+ portBASE_TYPE xTaskCreateRestricted( xTaskParameters *pxTaskDefinition, xTaskHandle *pxCreatedTask );</pre>\r
+ *\r
+ * xTaskCreateRestricted() should only be used in systems that include an MPU\r
+ * implementation.\r
+ *\r
+ * Create a new task and add it to the list of tasks that are ready to run.\r
+ * The function parameters define the memory regions and associated access\r
+ * permissions allocated to the task.\r
+ *\r
+ * @param pxTaskDefinition Pointer to a structure that contains a member\r
+ * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API\r
+ * documentation) plus an optional stack buffer and the memory region\r
+ * definitions.\r
+ *\r
+ * @param pxCreatedTask Used to pass back a handle by which the created task\r
+ * can be referenced.\r
+ *\r
+ * @return pdPASS if the task was successfully created and added to a ready\r
+ * list, otherwise an error code defined in the file errors. h\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+// Create an xTaskParameters structure that defines the task to be created.\r
+static const xTaskParameters xCheckTaskParameters =\r
+{\r
+       vATask,         // pvTaskCode - the function that implements the task.\r
+       "ATask",        // pcName - just a text name for the task to assist debugging.\r
+       100,            // usStackDepth - the stack size DEFINED IN WORDS.\r
+       NULL,           // pvParameters - passed into the task function as the function parameters.\r
+       ( 1UL | portPRIVILEGE_BIT ),// uxPriority - task priority, set the portPRIVILEGE_BIT if the task should run in a privileged state.\r
+       cStackBuffer,// puxStackBuffer - the buffer to be used as the task stack.\r
+\r
+       // xRegions - Allocate up to three separate memory regions for access by\r
+       // the task, with appropriate access permissions.  Different processors have\r
+       // different memory alignment requirements - refer to the FreeRTOS documentation\r
+       // for full information.\r
+       {                                                                                       \r
+               // Base address                                 Length  Parameters\r
+        { cReadWriteArray,                             32,             portMPU_REGION_READ_WRITE },\r
+        { cReadOnlyArray,                              32,             portMPU_REGION_READ_ONLY },\r
+        { cPrivilegedOnlyAccessArray,  128,    portMPU_REGION_PRIVILEGED_READ_WRITE }\r
+       }\r
+};\r
+\r
+int main( void )\r
+{\r
+xTaskHandle xHandle;\r
+\r
+       // Create a task from the const structure defined above.  The task handle\r
+       // is requested (the second parameter is not NULL) but in this case just for\r
+       // demonstration purposes as its not actually used.\r
+       xTaskCreateRestricted( &xRegTest1Parameters, &xHandle );\r
+\r
+       // Start the scheduler.\r
+       vTaskStartScheduler();\r
+\r
+       // Will only get here if there was insufficient memory to create the idle\r
+       // task.\r
+       for( ;; );\r
+}\r
+   </pre>\r
+ * \defgroup xTaskCreateRestricted xTaskCreateRestricted\r
+ * \ingroup Tasks\r
+ */\r
+#define xTaskCreateRestricted( x, pxCreatedTask ) xTaskGenericCreate( ((x)->pvTaskCode), ((x)->pcName), ((x)->usStackDepth), ((x)->pvParameters), ((x)->uxPriority), (pxCreatedTask), ((x)->puxStackBuffer), ((x)->xRegions) )\r
+\r
+/**\r
+ * task. h\r
+ *<pre>\r
+ void vTaskAllocateMPURegions( xTaskHandle xTask, const xMemoryRegion * const pxRegions );</pre>\r
+ *\r
+ * Memory regions are assigned to a restricted task when the task is created by\r
+ * a call to xTaskCreateRestricted().  These regions can be redefined using\r
+ * vTaskAllocateMPURegions().\r
+ *\r
+ * @param xTask The handle of the task being updated.\r
+ *\r
+ * @param xRegions A pointer to an xMemoryRegion structure that contains the\r
+ * new memory region definitions.\r
+ *\r
+ * Example usage:\r
+   <pre>\r
+// Define an array of xMemoryRegion structures that configures an MPU region\r
+// allowing read/write access for 1024 bytes starting at the beginning of the\r
+// ucOneKByte array.  The other two of the maximum 3 definable regions are\r
+// unused so set to zero.\r
+static const xMemoryRegion xAltRegions[ portNUM_CONFIGURABLE_REGIONS ] =\r
+{                                                                                      \r
+       // Base address         Length          Parameters\r
+       { ucOneKByte,           1024,           portMPU_REGION_READ_WRITE },\r
+       { 0,                            0,                      0 },\r
+       { 0,                            0,                      0 }\r
+};\r
+\r
+void vATask( void *pvParameters )\r
+{\r
+       // This task was created such that it has access to certain regions of\r
+       // memory as defined by the MPU configuration.  At some point it is\r
+       // desired that these MPU regions are replaced with that defined in the\r
+       // xAltRegions const struct above.  Use a call to vTaskAllocateMPURegions()\r
+       // for this purpose.  NULL is used as the task handle to indicate that this\r
+       // function should modify the MPU regions of the calling task.\r
+       vTaskAllocateMPURegions( NULL, xAltRegions );\r
+       \r
+       // Now the task can continue its function, but from this point on can only\r
+       // access its stack and the ucOneKByte array (unless any other statically\r
+       // defined or shared regions have been declared elsewhere).\r
+}\r
+   </pre>\r
+ * \defgroup xTaskCreateRestricted xTaskCreateRestricted\r
+ * \ingroup Tasks\r
+ */\r
+void vTaskAllocateMPURegions( xTaskHandle xTask, const xMemoryRegion * const pxRegions ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -227,19 +428,18 @@ signed portBASE_TYPE xTaskCreate( pdTASK_CODE pvTaskCode, const signed portCHAR
  void vOtherFunction( void )\r
  {\r
  xTaskHandle xHandle;\r
-               \r
-     // Create the task, storing the handle.\r
-     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
-               \r
-     // Use the handle to delete the task.\r
-     vTaskDelete( xHandle );\r
+\r
+        // Create the task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
+\r
+        // Use the handle to delete the task.\r
+        vTaskDelete( xHandle );\r
  }\r
    </pre>\r
  * \defgroup vTaskDelete vTaskDelete\r
  * \ingroup Tasks\r
  */\r
-void vTaskDelete( xTaskHandle pxTask );\r
-\r
+void vTaskDelete( xTaskHandle pxTaskToDelete ) PRIVILEGED_FUNCTION;\r
 \r
 /*-----------------------------------------------------------\r
  * TASK CONTROL API\r
@@ -257,42 +457,43 @@ void vTaskDelete( xTaskHandle pxTask );
  * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.\r
  * See the configuration section for more information.\r
  *\r
+ *\r
+ * vTaskDelay() specifies a time at which the task wishes to unblock relative to\r
+ * the time at which vTaskDelay() is called.  For example, specifying a block\r
+ * period of 100 ticks will cause the task to unblock 100 ticks after\r
+ * vTaskDelay() is called.  vTaskDelay() does not therefore provide a good method\r
+ * of controlling the frequency of a cyclical task as the path taken through the\r
+ * code, as well as other task and interrupt activity, will effect the frequency\r
+ * at which vTaskDelay() gets called and therefore the time at which the task\r
+ * next executes.  See vTaskDelayUntil() for an alternative API function designed\r
+ * to facilitate fixed frequency execution.  It does this by specifying an\r
+ * absolute time (rather than a relative time) at which the calling task should\r
+ * unblock.\r
+ *\r
  * @param xTicksToDelay The amount of time, in tick periods, that\r
  * the calling task should block.\r
  *\r
  * Example usage:\r
-   <pre>\r
- // Wait 10 ticks before performing an action.\r
- // NOTE:\r
- // This is for demonstration only and would be better achieved\r
- // using vTaskDelayUntil ().\r
+\r
  void vTaskFunction( void * pvParameters )\r
  {\r
- portTickType xDelay, xNextTime;\r
-\r
-     // Calc the time at which we want to perform the action\r
-     // next.\r
-     xNextTime = xTaskGetTickCount () + ( portTickType ) 10;\r
-\r
-     for( ;; )\r
-     {\r
-         xDelay = xNextTime - xTaskGetTickCount ();\r
-         xNextTime += ( portTickType ) 10;\r
-\r
-         // Guard against overflow\r
-         if( xDelay <= ( portTickType ) 10 )\r
-         {\r
-             vTaskDelay( xDelay );\r
-         }\r
-\r
-         // Perform action here.\r
-     }\r
+ void vTaskFunction( void * pvParameters )\r
+ {\r
+ // Block for 500ms.\r
+ const portTickType xDelay = 500 / portTICK_RATE_MS;\r
+\r
+        for( ;; )\r
+        {\r
+                // Simply toggle the LED every 500ms, blocking between each toggle.\r
+                vToggleLED();\r
+                vTaskDelay( xDelay );\r
+        }\r
  }\r
-   </pre>\r
+\r
  * \defgroup vTaskDelay vTaskDelay\r
  * \ingroup TaskCtrl\r
  */\r
-void vTaskDelay( portTickType xTicksToDelay );\r
+void vTaskDelay( portTickType xTicksToDelay ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -337,21 +538,21 @@ void vTaskDelay( portTickType xTicksToDelay );
  portTickType xLastWakeTime;\r
  const portTickType xFrequency = 10;\r
 \r
-     // Initialise the xLastWakeTime variable with the current time.\r
-     xLastWakeTime = xTaskGetTickCount ();\r
-     for( ;; )\r
-     {\r
-         // Wait for the next cycle.\r
-         vTaskDelayUntil( &xLastWakeTime, xFrequency );\r
+        // Initialise the xLastWakeTime variable with the current time.\r
+        xLastWakeTime = xTaskGetTickCount ();\r
+        for( ;; )\r
+        {\r
+                // Wait for the next cycle.\r
+                vTaskDelayUntil( &xLastWakeTime, xFrequency );\r
 \r
-         // Perform action here.\r
-     }\r
+                // Perform action here.\r
+        }\r
  }\r
    </pre>\r
  * \defgroup vTaskDelayUntil vTaskDelayUntil\r
  * \ingroup TaskCtrl\r
  */\r
-void vTaskDelayUntil( portTickType *pxPreviousWakeTime, portTickType xTimeIncrement );\r
+void vTaskDelayUntil( portTickType * const pxPreviousWakeTime, portTickType xTimeIncrement ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -372,33 +573,33 @@ void vTaskDelayUntil( portTickType *pxPreviousWakeTime, portTickType xTimeIncrem
  void vAFunction( void )\r
  {\r
  xTaskHandle xHandle;\r
-               \r
-     // Create a task, storing the handle.\r
-     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
-               \r
-     // ...\r
-\r
-     // Use the handle to obtain the priority of the created task.\r
-     // It was created with tskIDLE_PRIORITY, but may have changed\r
-     // it itself.\r
-     if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )\r
-     {\r
-         // The task has changed it's priority.\r
-     }\r
-\r
-     // ...\r
-\r
-     // Is our priority higher than the created task?\r
-     if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )\r
-     {\r
-         // Our priority (obtained using NULL handle) is higher.\r
-     }\r
+\r
+        // Create a task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
+\r
+        // ...\r
+\r
+        // Use the handle to obtain the priority of the created task.\r
+        // It was created with tskIDLE_PRIORITY, but may have changed\r
+        // it itself.\r
+        if( uxTaskPriorityGet( xHandle ) != tskIDLE_PRIORITY )\r
+        {\r
+                // The task has changed it's priority.\r
+        }\r
+\r
+        // ...\r
+\r
+        // Is our priority higher than the created task?\r
+        if( uxTaskPriorityGet( xHandle ) < uxTaskPriorityGet( NULL ) )\r
+        {\r
+                // Our priority (obtained using NULL handle) is higher.\r
+        }\r
  }\r
    </pre>\r
  * \defgroup uxTaskPriorityGet uxTaskPriorityGet\r
  * \ingroup TaskCtrl\r
  */\r
-unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );\r
+unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -422,25 +623,25 @@ unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle pxTask );
  void vAFunction( void )\r
  {\r
  xTaskHandle xHandle;\r
-               \r
-     // Create a task, storing the handle.\r
-     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
 \r
-     // ...\r
+        // Create a task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
 \r
-     // Use the handle to raise the priority of the created task.\r
-     vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );\r
+        // ...\r
 \r
-     // ...\r
+        // Use the handle to raise the priority of the created task.\r
+        vTaskPrioritySet( xHandle, tskIDLE_PRIORITY + 1 );\r
 \r
-     // Use a NULL handle to raise our priority to the same value.\r
-     vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );\r
+        // ...\r
+\r
+        // Use a NULL handle to raise our priority to the same value.\r
+        vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );\r
  }\r
    </pre>\r
  * \defgroup vTaskPrioritySet vTaskPrioritySet\r
  * \ingroup TaskCtrl\r
  */\r
-void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );\r
+void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -464,34 +665,34 @@ void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority
  void vAFunction( void )\r
  {\r
  xTaskHandle xHandle;\r
-               \r
-     // Create a task, storing the handle.\r
-     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
-               \r
-     // ...\r
-\r
-     // Use the handle to suspend the created task.\r
-     vTaskSuspend( xHandle );\r
-\r
-     // ...\r
-               \r
-     // The created task will not run during this period, unless\r
-     // another task calls vTaskResume( xHandle ).\r
-               \r
-     //...\r
-               \r
-\r
-     // Suspend ourselves.\r
-     vTaskSuspend( NULL );\r
-\r
-     // We cannot get here unless another task calls vTaskResume\r
-     // with our handle as the parameter.\r
+\r
+        // Create a task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
+\r
+        // ...\r
+\r
+        // Use the handle to suspend the created task.\r
+        vTaskSuspend( xHandle );\r
+\r
+        // ...\r
+\r
+        // The created task will not run during this period, unless\r
+        // another task calls vTaskResume( xHandle ).\r
+\r
+        //...\r
+\r
+\r
+        // Suspend ourselves.\r
+        vTaskSuspend( NULL );\r
+\r
+        // We cannot get here unless another task calls vTaskResume\r
+        // with our handle as the parameter.\r
  }\r
    </pre>\r
  * \defgroup vTaskSuspend vTaskSuspend\r
  * \ingroup TaskCtrl\r
  */\r
-void vTaskSuspend( xTaskHandle pxTaskToSuspend );\r
+void vTaskSuspend( xTaskHandle pxTaskToSuspend ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -513,40 +714,40 @@ void vTaskSuspend( xTaskHandle pxTaskToSuspend );
  void vAFunction( void )\r
  {\r
  xTaskHandle xHandle;\r
-               \r
-     // Create a task, storing the handle.\r
-     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
-               \r
-     // ...\r
 \r
-     // Use the handle to suspend the created task.\r
-     vTaskSuspend( xHandle );\r
+        // Create a task, storing the handle.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );\r
 \r
-     // ...\r
-       \r
-     // The created task will not run during this period, unless\r
-     // another task calls vTaskResume( xHandle ).\r
-               \r
-     //...\r
-               \r
+        // ...\r
 \r
-     // Resume the suspended task ourselves.\r
-     vTaskResume( xHandle );\r
+        // Use the handle to suspend the created task.\r
+        vTaskSuspend( xHandle );\r
 \r
-     // The created task will once again get microcontroller processing\r
-     // time in accordance with it priority within the system.\r
+        // ...\r
+\r
+        // The created task will not run during this period, unless\r
+        // another task calls vTaskResume( xHandle ).\r
+\r
+        //...\r
+\r
+\r
+        // Resume the suspended task ourselves.\r
+        vTaskResume( xHandle );\r
+\r
+        // The created task will once again get microcontroller processing\r
+        // time in accordance with it priority within the system.\r
  }\r
    </pre>\r
  * \defgroup vTaskResume vTaskResume\r
  * \ingroup TaskCtrl\r
  */\r
-void vTaskResume( xTaskHandle pxTaskToResume );\r
+void vTaskResume( xTaskHandle pxTaskToResume ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
  * <pre>void xTaskResumeFromISR( xTaskHandle pxTaskToResume );</pre>\r
  *\r
- * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be \r
+ * INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be\r
  * available.  See the configuration section for more information.\r
  *\r
  * An implementation of vTaskResume() that can be called from within an ISR.\r
@@ -560,7 +761,7 @@ void vTaskResume( xTaskHandle pxTaskToResume );
  * \defgroup vTaskResumeFromISR vTaskResumeFromISR\r
  * \ingroup TaskCtrl\r
  */\r
-portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume );\r
+portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume ) PRIVILEGED_FUNCTION;\r
 \r
 /*-----------------------------------------------------------\r
  * SCHEDULER CONTROL\r
@@ -585,20 +786,20 @@ portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume );
    <pre>\r
  void vAFunction( void )\r
  {\r
-     // Create at least one task before starting the kernel.\r
-     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+        // Create at least one task before starting the kernel.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
 \r
-     // Start the real time kernel with preemption.\r
-     vTaskStartScheduler ();\r
+        // Start the real time kernel with preemption.\r
+        vTaskStartScheduler ();\r
 \r
-     // Will not get here unless a task calls vTaskEndScheduler ()\r
+        // Will not get here unless a task calls vTaskEndScheduler ()\r
  }\r
    </pre>\r
  *\r
  * \defgroup vTaskStartScheduler vTaskStartScheduler\r
  * \ingroup SchedulerControl\r
  */\r
-void vTaskStartScheduler( void );\r
+void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -624,34 +825,34 @@ void vTaskStartScheduler( void );
    <pre>\r
  void vTaskCode( void * pvParameters )\r
  {\r
-     for( ;; )\r
-     {\r
-         // Task code goes here.\r
-\r
-         // At some point we want to end the real time kernel processing\r
-         // so call ...\r
-         vTaskEndScheduler ();\r
-     }\r
+        for( ;; )\r
+        {\r
+                // Task code goes here.\r
+\r
+                // At some point we want to end the real time kernel processing\r
+                // so call ...\r
+                vTaskEndScheduler ();\r
+        }\r
  }\r
 \r
  void vAFunction( void )\r
  {\r
-     // Create at least one task before starting the kernel.\r
-     xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+        // Create at least one task before starting the kernel.\r
+        xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
 \r
-     // Start the real time kernel with preemption.\r
-     vTaskStartScheduler ();\r
+        // Start the real time kernel with preemption.\r
+        vTaskStartScheduler ();\r
 \r
-     // Will only get here when the vTaskCode () task has called\r
-     // vTaskEndScheduler ().  When we get here we are back to single task\r
-     // execution.\r
+        // Will only get here when the vTaskCode () task has called\r
+        // vTaskEndScheduler ().  When we get here we are back to single task\r
+        // execution.\r
  }\r
    </pre>\r
  *\r
  * \defgroup vTaskEndScheduler vTaskEndScheduler\r
  * \ingroup SchedulerControl\r
  */\r
-void vTaskEndScheduler( void );\r
+void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
@@ -664,94 +865,108 @@ void vTaskEndScheduler( void );
  * without risk of being swapped out until a call to xTaskResumeAll () has been\r
  * made.\r
  *\r
+ * API functions that have the potential to cause a context switch (for example,\r
+ * vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler\r
+ * is suspended.\r
+ *\r
  * Example usage:\r
    <pre>\r
  void vTask1( void * pvParameters )\r
  {\r
-     for( ;; )\r
-     {\r
-         // Task code goes here.\r
+        for( ;; )\r
+        {\r
+                // Task code goes here.\r
 \r
-         // ...\r
+                // ...\r
 \r
-         // At some point the task wants to perform a long operation during\r
-         // which it does not want to get swapped out.  It cannot use\r
-         // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the\r
-         // operation may cause interrupts to be missed - including the\r
-         // ticks.\r
+                // At some point the task wants to perform a long operation during\r
+                // which it does not want to get swapped out.  It cannot use\r
+                // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the\r
+                // operation may cause interrupts to be missed - including the\r
+                // ticks.\r
 \r
-         // Prevent the real time kernel swapping out the task.\r
-         vTaskSuspendAll ();\r
+                // Prevent the real time kernel swapping out the task.\r
+                vTaskSuspendAll ();\r
 \r
-         // Perform the operation here.  There is no need to use critical\r
-         // sections as we have all the microcontroller processing time.\r
-         // During this time interrupts will still operate and the kernel\r
-         // tick count will be maintained.\r
+                // Perform the operation here.  There is no need to use critical\r
+                // sections as we have all the microcontroller processing time.\r
+                // During this time interrupts will still operate and the kernel\r
+                // tick count will be maintained.\r
 \r
-         // ...\r
+                // ...\r
 \r
-         // The operation is complete.  Restart the kernel.\r
-         xTaskResumeAll ();\r
-     }\r
+                // The operation is complete.  Restart the kernel.\r
+                xTaskResumeAll ();\r
+        }\r
  }\r
    </pre>\r
  * \defgroup vTaskSuspendAll vTaskSuspendAll\r
  * \ingroup SchedulerControl\r
  */\r
-void vTaskSuspendAll( void );\r
+void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
- * <pre>portCHAR xTaskResumeAll( void );</pre>\r
+ * <pre>char xTaskResumeAll( void );</pre>\r
  *\r
  * Resumes real time kernel activity following a call to vTaskSuspendAll ().\r
  * After a call to vTaskSuspendAll () the kernel will take control of which\r
  * task is executing at any time.\r
  *\r
  * @return If resuming the scheduler caused a context switch then pdTRUE is\r
- *         returned, otherwise pdFALSE is returned.\r
+ *               returned, otherwise pdFALSE is returned.\r
  *\r
  * Example usage:\r
    <pre>\r
  void vTask1( void * pvParameters )\r
  {\r
-     for( ;; )\r
-     {\r
-         // Task code goes here.\r
-\r
-         // ...\r
-\r
-         // At some point the task wants to perform a long operation during\r
-         // which it does not want to get swapped out.  It cannot use\r
-         // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the\r
-         // operation may cause interrupts to be missed - including the\r
-         // ticks.\r
-\r
-         // Prevent the real time kernel swapping out the task.\r
-         vTaskSuspendAll ();\r
-\r
-         // Perform the operation here.  There is no need to use critical\r
-         // sections as we have all the microcontroller processing time.\r
-         // During this time interrupts will still operate and the real\r
-         // time kernel tick count will be maintained.\r
-\r
-         // ...\r
-\r
-         // The operation is complete.  Restart the kernel.  We want to force\r
-         // a context switch - but there is no point if resuming the scheduler\r
-         // caused a context switch already.\r
-         if( !xTaskResumeAll () )\r
-         {\r
-              taskYIELD ();\r
-         }\r
-     }\r
+        for( ;; )\r
+        {\r
+                // Task code goes here.\r
+\r
+                // ...\r
+\r
+                // At some point the task wants to perform a long operation during\r
+                // which it does not want to get swapped out.  It cannot use\r
+                // taskENTER_CRITICAL ()/taskEXIT_CRITICAL () as the length of the\r
+                // operation may cause interrupts to be missed - including the\r
+                // ticks.\r
+\r
+                // Prevent the real time kernel swapping out the task.\r
+                vTaskSuspendAll ();\r
+\r
+                // Perform the operation here.  There is no need to use critical\r
+                // sections as we have all the microcontroller processing time.\r
+                // During this time interrupts will still operate and the real\r
+                // time kernel tick count will be maintained.\r
+\r
+                // ...\r
+\r
+                // The operation is complete.  Restart the kernel.  We want to force\r
+                // a context switch - but there is no point if resuming the scheduler\r
+                // caused a context switch already.\r
+                if( !xTaskResumeAll () )\r
+                {\r
+                         taskYIELD ();\r
+                }\r
+        }\r
  }\r
    </pre>\r
  * \defgroup xTaskResumeAll xTaskResumeAll\r
  * \ingroup SchedulerControl\r
  */\r
-signed portBASE_TYPE xTaskResumeAll( void );\r
+signed portBASE_TYPE xTaskResumeAll( void ) PRIVILEGED_FUNCTION;\r
 \r
+/**\r
+ * task. h\r
+ * <pre>signed portBASE_TYPE xTaskIsTaskSuspended( xTaskHandle xTask );</pre>\r
+ *\r
+ * Utility task that simply returns pdTRUE if the task referenced by xTask is\r
+ * currently in the Suspended state, or pdFALSE if the task referenced by xTask\r
+ * is in any other state.\r
+ *\r
+ */\r
+signed portBASE_TYPE xTaskIsTaskSuspended( xTaskHandle xTask ) PRIVILEGED_FUNCTION;\r
 \r
 /*-----------------------------------------------------------\r
  * TASK UTILITIES\r
@@ -759,18 +974,34 @@ signed portBASE_TYPE xTaskResumeAll( void );
 \r
 /**\r
  * task. h\r
- * <PRE>volatile portTickType xTaskGetTickCount( void );</PRE>\r
+ * <PRE>portTickType xTaskGetTickCount( void );</PRE>\r
  *\r
  * @return The count of ticks since vTaskStartScheduler was called.\r
  *\r
  * \page xTaskGetTickCount xTaskGetTickCount\r
  * \ingroup TaskUtils\r
  */\r
-portTickType xTaskGetTickCount( void );\r
+portTickType xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
- * <PRE>unsigned portSHORT uxTaskGetNumberOfTasks( void );</PRE>\r
+ * <PRE>portTickType xTaskGetTickCountFromISR( void );</PRE>\r
+ *\r
+ * @return The count of ticks since vTaskStartScheduler was called.\r
+ *\r
+ * This is a version of xTaskGetTickCount() that is safe to be called from an\r
+ * ISR - provided that portTickType is the natural word size of the\r
+ * microcontroller being used or interrupt nesting is either not supported or\r
+ * not being used.\r
+ *\r
+ * \page xTaskGetTickCount xTaskGetTickCount\r
+ * \ingroup TaskUtils\r
+ */\r
+portTickType xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>unsigned short uxTaskGetNumberOfTasks( void );</PRE>\r
  *\r
  * @return The number of tasks that the real time kernel is currently managing.\r
  * This includes all ready, blocked and suspended tasks.  A task that\r
@@ -780,15 +1011,28 @@ portTickType xTaskGetTickCount( void );
  * \page uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks\r
  * \ingroup TaskUtils\r
  */\r
-unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void );\r
+unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
- * <PRE>void vTaskList( portCHAR *pcWriteBuffer );</PRE>\r
+ * <PRE>signed char *pcTaskGetTaskName( xTaskHandle xTaskToQuery );</PRE>\r
  *\r
- * configUSE_TRACE_FACILITY, INCLUDE_vTaskDelete and INCLUDE_vTaskSuspend\r
- * must all be defined as 1 for this function to be available.\r
- * See the configuration section for more information.\r
+ * @return The text (human readable) name of the task referenced by the handle\r
+ * xTaskToQueury.  A task can query its own name by either passing in its own\r
+ * handle, or by setting xTaskToQuery to NULL.  INCLUDE_pcTaskGetTaskName must be\r
+ * set to 1 in FreeRTOSConfig.h for pcTaskGetTaskName() to be available.\r
+ *\r
+ * \page pcTaskGetTaskName pcTaskGetTaskName\r
+ * \ingroup TaskUtils\r
+ */\r
+signed char *pcTaskGetTaskName( xTaskHandle xTaskToQuery );\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>void vTaskList( char *pcWriteBuffer );</PRE>\r
+ *\r
+ * configUSE_TRACE_FACILITY must be defined as 1 for this function to be\r
+ * available.  See the configuration section for more information.\r
  *\r
  * NOTE: This function will disable interrupts for its duration.  It is\r
  * not intended for normal application runtime use but as a debug aid.\r
@@ -807,11 +1051,43 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void );
  * \page vTaskList vTaskList\r
  * \ingroup TaskUtils\r
  */\r
-void vTaskList( signed portCHAR *pcWriteBuffer );\r
+void vTaskList( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task. h\r
+ * <PRE>void vTaskGetRunTimeStats( char *pcWriteBuffer );</PRE>\r
+ *\r
+ * configGENERATE_RUN_TIME_STATS must be defined as 1 for this function\r
+ * to be available.  The application must also then provide definitions\r
+ * for portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and\r
+ * portGET_RUN_TIME_COUNTER_VALUE to configure a peripheral timer/counter\r
+ * and return the timers current count value respectively.  The counter\r
+ * should be at least 10 times the frequency of the tick count.\r
+ *\r
+ * NOTE: This function will disable interrupts for its duration.  It is\r
+ * not intended for normal application runtime use but as a debug aid.\r
+ *\r
+ * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total\r
+ * accumulated execution time being stored for each task.  The resolution\r
+ * of the accumulated time value depends on the frequency of the timer\r
+ * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.\r
+ * Calling vTaskGetRunTimeStats() writes the total execution time of each\r
+ * task into a buffer, both as an absolute count value and as a percentage\r
+ * of the total system execution time.\r
+ *\r
+ * @param pcWriteBuffer A buffer into which the execution times will be\r
+ * written, in ascii form.  This buffer is assumed to be large enough to\r
+ * contain the generated report.  Approximately 40 bytes per task should\r
+ * be sufficient.\r
+ *\r
+ * \page vTaskGetRunTimeStats vTaskGetRunTimeStats\r
+ * \ingroup TaskUtils\r
+ */\r
+void vTaskGetRunTimeStats( signed char *pcWriteBuffer ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
- * <PRE>void vTaskStartTrace( portCHAR * pcBuffer, unsigned portBASE_TYPE uxBufferSize );</PRE>\r
+ * <PRE>void vTaskStartTrace( char * pcBuffer, unsigned portBASE_TYPE uxBufferSize );</PRE>\r
  *\r
  * Starts a real time kernel activity trace.  The trace logs the identity of\r
  * which task is running when.\r
@@ -828,11 +1104,11 @@ void vTaskList( signed portCHAR *pcWriteBuffer );
  * \page vTaskStartTrace vTaskStartTrace\r
  * \ingroup TaskUtils\r
  */\r
-void vTaskStartTrace( signed portCHAR * pcBuffer, unsigned portLONG ulBufferSize );\r
+void vTaskStartTrace( signed char * pcBuffer, unsigned long ulBufferSize ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
  * task. h\r
- * <PRE>unsigned portLONG ulTaskEndTrace( void );</PRE>\r
+ * <PRE>unsigned long ulTaskEndTrace( void );</PRE>\r
  *\r
  * Stops a kernel activity trace.  See vTaskStartTrace ().\r
  *\r
@@ -841,8 +1117,76 @@ void vTaskStartTrace( signed portCHAR * pcBuffer, unsigned portLONG ulBufferSize
  * \page usTaskEndTrace usTaskEndTrace\r
  * \ingroup TaskUtils\r
  */\r
-unsigned portLONG ulTaskEndTrace( void );\r
+unsigned long ulTaskEndTrace( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task.h\r
+ * <PRE>unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask );</PRE>\r
+ *\r
+ * INCLUDE_uxTaskGetStackHighWaterMark must be set to 1 in FreeRTOSConfig.h for\r
+ * this function to be available.\r
+ *\r
+ * Returns the high water mark of the stack associated with xTask.  That is,\r
+ * the minimum free stack space there has been (in words, so on a 32 bit machine\r
+ * a value of 1 means 4 bytes) since the task started.  The smaller the returned\r
+ * number the closer the task has come to overflowing its stack.\r
+ *\r
+ * @param xTask Handle of the task associated with the stack to be checked.\r
+ * Set xTask to NULL to check the stack of the calling task.\r
+ *\r
+ * @return The smallest amount of free stack space there has been (in bytes)\r
+ * since the task referenced by xTask was created.\r
+ */\r
+unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask ) PRIVILEGED_FUNCTION;\r
+\r
+/* When using trace macros it is sometimes necessary to include tasks.h before\r
+FreeRTOS.h.  When this is done pdTASK_HOOK_CODE will not yet have been defined,\r
+so the following two prototypes will cause a compilation error.  This can be\r
+fixed by simply guarding against the inclusion of these two prototypes unless\r
+they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration\r
+constant. */\r
+#ifdef configUSE_APPLICATION_TASK_TAG\r
+       #if configUSE_APPLICATION_TASK_TAG == 1\r
+               /**\r
+                * task.h\r
+                * <pre>void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction );</pre>\r
+                *\r
+                * Sets pxHookFunction to be the task hook function used by the task xTask.\r
+                * Passing xTask as NULL has the effect of setting the calling tasks hook\r
+                * function.\r
+                */\r
+               void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction ) PRIVILEGED_FUNCTION;\r
+\r
+               /**\r
+                * task.h\r
+                * <pre>void xTaskGetApplicationTaskTag( xTaskHandle xTask );</pre>\r
+                *\r
+                * Returns the pxHookFunction value assigned to the task xTask.\r
+                */\r
+               pdTASK_HOOK_CODE xTaskGetApplicationTaskTag( xTaskHandle xTask ) PRIVILEGED_FUNCTION;\r
+       #endif /* configUSE_APPLICATION_TASK_TAG ==1 */\r
+#endif /* ifdef configUSE_APPLICATION_TASK_TAG */\r
+\r
+/**\r
+ * task.h\r
+ * <pre>portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction );</pre>\r
+ *\r
+ * Calls the hook function associated with xTask.  Passing xTask as NULL has\r
+ * the effect of calling the Running tasks (the calling task) hook function.\r
+ *\r
+ * pvParameter is passed to the hook function for the task to interpret as it\r
+ * wants.\r
+ */\r
+portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter ) PRIVILEGED_FUNCTION;\r
 \r
+/**\r
+ * xTaskGetIdleTaskHandle() is only available if \r
+ * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.\r
+ *\r
+ * Simply returns the handle of the idle task.  It is not valid to call\r
+ * xTaskGetIdleTaskHandle() before the scheduler has been started.\r
+ */\r
+xTaskHandle xTaskGetIdleTaskHandle( void );\r
 \r
 /*-----------------------------------------------------------\r
  * SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES\r
@@ -858,7 +1202,7 @@ unsigned portLONG ulTaskEndTrace( void );
  * for a finite period required removing from a blocked list and placing on\r
  * a ready list.\r
  */\r
-inline void vTaskIncrementTick( void );\r
+void vTaskIncrementTick( void ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
@@ -881,7 +1225,7 @@ inline void vTaskIncrementTick( void );
  * portTICK_RATE_MS can be used to convert kernel ticks into a real time\r
  * period.\r
  */\r
-void vTaskPlaceOnEventList( xList *pxEventList, portTickType xTicksToWait );\r
+void vTaskPlaceOnEventList( const xList * const pxEventList, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
@@ -889,29 +1233,31 @@ void vTaskPlaceOnEventList( xList *pxEventList, portTickType xTicksToWait );
  *\r
  * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.\r
  *\r
- * Removes a task from both the specified event list and the list of blocked\r
- * tasks, and places it on a ready queue.\r
- *\r
- * xTaskRemoveFromEventList () will be called if either an event occurs to\r
- * unblock a task, or the block timeout period expires.\r
+ * This function performs nearly the same function as vTaskPlaceOnEventList().\r
+ * The difference being that this function does not permit tasks to block\r
+ * indefinitely, whereas vTaskPlaceOnEventList() does.\r
  *\r
  * @return pdTRUE if the task being removed has a higher priority than the task\r
  * making the call, otherwise pdFALSE.\r
  */\r
-signed portBASE_TYPE xTaskRemoveFromEventList( const xList *pxEventList );\r
+void vTaskPlaceOnEventListRestricted( const xList * const pxEventList, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
  * INTERFACE WHICH IS FOR THE EXCLUSIVE USE OF THE SCHEDULER.\r
  *\r
- * INCLUDE_vTaskCleanUpResources and INCLUDE_vTaskSuspend must be defined as 1\r
- * for this function to be available.\r
- * See the configuration section for more information.\r
+ * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED.\r
  *\r
- * Empties the ready and delayed queues of task control blocks, freeing the\r
- * memory allocated for the task control block and task stacks as it goes.\r
+ * Removes a task from both the specified event list and the list of blocked\r
+ * tasks, and places it on a ready queue.\r
+ *\r
+ * xTaskRemoveFromEventList () will be called if either an event occurs to\r
+ * unblock a task, or the block timeout period expires.\r
+ *\r
+ * @return pdTRUE if the task being removed has a higher priority than the task\r
+ * making the call, otherwise pdFALSE.\r
  */\r
-void vTaskCleanUpResources( void );\r
+signed portBASE_TYPE xTaskRemoveFromEventList( const xList * const pxEventList ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS ONLY\r
@@ -921,30 +1267,69 @@ void vTaskCleanUpResources( void );
  * Sets the pointer to the current TCB to the TCB of the highest priority task\r
  * that is ready to run.\r
  */\r
-inline void vTaskSwitchContext( void );\r
+void vTaskSwitchContext( void ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Return the handle of the calling task.\r
  */\r
-xTaskHandle xTaskGetCurrentTaskHandle( void );\r
+xTaskHandle xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Capture the current time status for future reference.\r
  */\r
-void vTaskSetTimeOutState( xTimeOutType *pxTimeOut );\r
+void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Compare the time status now with that previously captured to see if the\r
  * timeout has expired.\r
  */\r
-portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType *pxTimeOut, portTickType *pxTicksToWait );\r
+portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType * const pxTicksToWait ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Shortcut used by the queue implementation to prevent unnecessary call to\r
  * taskYIELD();\r
  */\r
-void vTaskMissedYield( void );\r
+void vTaskMissedYield( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Returns the scheduler state as taskSCHEDULER_RUNNING,\r
+ * taskSCHEDULER_NOT_STARTED or taskSCHEDULER_SUSPENDED.\r
+ */\r
+portBASE_TYPE xTaskGetSchedulerState( void ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Raises the priority of the mutex holder to that of the calling task should\r
+ * the mutex holder have a priority less than the calling task.\r
+ */\r
+void vTaskPriorityInherit( xTaskHandle * const pxMutexHolder ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Set the priority of a task back to its proper priority in the case that it\r
+ * inherited a higher priority while it was holding a semaphore.\r
+ */\r
+void vTaskPriorityDisinherit( xTaskHandle * const pxMutexHolder ) PRIVILEGED_FUNCTION;\r
+\r
+/*\r
+ * Generic version of the task creation function which is in turn called by the\r
+ * xTaskCreate() and xTaskCreateRestricted() macros.\r
+ */\r
+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;\r
+\r
+/*\r
+ * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.\r
+ */\r
+unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask );\r
+\r
+/* \r
+ * Set the uxTCBNumber of the task referenced by the xTask parameter to\r
+ * ucHandle.\r
+ */\r
+void vTaskSetTaskNumber( xTaskHandle xTask, unsigned portBASE_TYPE uxHandle );\r
+\r
 \r
+#ifdef __cplusplus\r
+}\r
+#endif\r
 #endif /* TASK_H */\r
 \r
 \r