]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/tasks.c
Final V8.2.1 release ready for tagging:
[freertos] / FreeRTOS / Source / tasks.c
index 1acd887454294032b4d3d6fc9c11b509dff273a2..426ee2d591f9460d0b848d04ad1493128306ebb4 100644 (file)
@@ -1,60 +1,64 @@
 /*\r
-    FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+    FreeRTOS V8.2.1 - Copyright (C) 2015 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS provides completely free yet professionally developed,    *\r
-     *    robust, strictly quality controlled, supported, and cross          *\r
-     *    platform software that has become a de facto standard.             *\r
-     *                                                                       *\r
-     *    Help yourself get started quickly and support the FreeRTOS         *\r
-     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
-     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
-     *                                                                       *\r
-     *    Thank you!                                                         *\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
 \r
-    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
-    >>! a combined work that includes FreeRTOS without being obliged to provide\r
-    >>! the source code for proprietary components outside of the FreeRTOS\r
-    >>! kernel.\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
 \r
     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
-    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
     link: http://www.freertos.org/a00114.html\r
 \r
-    1 tab == 4 spaces!\r
-\r
     ***************************************************************************\r
      *                                                                       *\r
-     *    Having a problem?  Start by reading the FAQ "My application does   *\r
-     *    not run, what could be wrong?"                                     *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
      *                                                                       *\r
-     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
-    license and Real Time Engineers Ltd. contact details.\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
 \r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
 \r
-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
-    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
-    licenses offer ticketed support, indemnification and middleware.\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
 \r
     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
     engineered and independently SIL3 certified version for use in safety and\r
@@ -84,6 +88,8 @@ header files above, but not in this file, in order to generate the correct
 privileged Vs unprivileged linkage and placement. */\r
 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */\r
 \r
+/* Set configUSE_STATS_FORMATTING_FUNCTIONS to 2 to include the stats formatting\r
+functions but without including stdio.h here. */\r
 #if ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 )\r
        /* At the bottom of this file are two optional functions that can be used\r
        to generate human readable text from the raw data generated by the\r
@@ -112,6 +118,14 @@ privileged Vs unprivileged linkage and placement. */
        #define taskYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()\r
 #endif\r
 \r
+/* Value that can be assigned to the eNotifyState member of the TCB. */\r
+typedef enum\r
+{\r
+       eNotWaitingNotification = 0,\r
+       eWaitingNotification,\r
+       eNotified\r
+} eNotifyValue;\r
+\r
 /*\r
  * Task control block.  A task control block (TCB) is allocated for each task,\r
  * and stores task state information, including a pointer to the task's context\r
@@ -119,41 +133,47 @@ privileged Vs unprivileged linkage and placement. */
  */\r
 typedef struct tskTaskControlBlock\r
 {\r
-       volatile portSTACK_TYPE *pxTopOfStack;          /*< Points to the location of the last item placed on the tasks stack.  THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */\r
+       volatile StackType_t    *pxTopOfStack;  /*< Points to the location of the last item placed on the tasks stack.  THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */\r
 \r
        #if ( portUSING_MPU_WRAPPERS == 1 )\r
-               xMPU_SETTINGS xMPUSettings;                             /*< The MPU settings are defined as part of the port layer.  THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */\r
+               xMPU_SETTINGS   xMPUSettings;           /*< The MPU settings are defined as part of the port layer.  THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */\r
+               BaseType_t              xUsingStaticallyAllocatedStack; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */\r
        #endif\r
 \r
-       xListItem                               xGenericListItem;       /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */\r
-       xListItem                               xEventListItem;         /*< Used to reference a task from an event list. */\r
-       unsigned portBASE_TYPE  uxPriority;                     /*< The priority of the task.  0 is the lowest priority. */\r
-       portSTACK_TYPE                  *pxStack;                       /*< Points to the start of the stack. */\r
-       signed char                             pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created.  Facilitates debugging only. */\r
+       ListItem_t                      xGenericListItem;       /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */\r
+       ListItem_t                      xEventListItem;         /*< Used to reference a task from an event list. */\r
+       UBaseType_t                     uxPriority;                     /*< The priority of the task.  0 is the lowest priority. */\r
+       StackType_t                     *pxStack;                       /*< Points to the start of the stack. */\r
+       char                            pcTaskName[ configMAX_TASK_NAME_LEN ];/*< Descriptive name given to the task when created.  Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 \r
        #if ( portSTACK_GROWTH > 0 )\r
-               portSTACK_TYPE *pxEndOfStack;                   /*< Points to the end of the stack on architectures where the stack grows up from low memory. */\r
+               StackType_t             *pxEndOfStack;          /*< Points to the end of the stack on architectures where the stack grows up from low memory. */\r
        #endif\r
 \r
        #if ( portCRITICAL_NESTING_IN_TCB == 1 )\r
-               unsigned portBASE_TYPE uxCriticalNesting; /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */\r
+               UBaseType_t     uxCriticalNesting;      /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */\r
        #endif\r
 \r
        #if ( configUSE_TRACE_FACILITY == 1 )\r
-               unsigned portBASE_TYPE  uxTCBNumber;    /*< Stores a number that increments each time a TCB is created.  It allows debuggers to determine when a task has been deleted and then recreated. */\r
-               unsigned portBASE_TYPE  uxTaskNumber;   /*< Stores a number specifically for use by third party trace code. */\r
+               UBaseType_t             uxTCBNumber;            /*< Stores a number that increments each time a TCB is created.  It allows debuggers to determine when a task has been deleted and then recreated. */\r
+               UBaseType_t     uxTaskNumber;           /*< Stores a number specifically for use by third party trace code. */\r
        #endif\r
 \r
        #if ( configUSE_MUTEXES == 1 )\r
-               unsigned portBASE_TYPE uxBasePriority;  /*< The priority last assigned to the task - used by the priority inheritance mechanism. */\r
+               UBaseType_t     uxBasePriority;         /*< The priority last assigned to the task - used by the priority inheritance mechanism. */\r
+               UBaseType_t     uxMutexesHeld;\r
        #endif\r
 \r
        #if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
-               pdTASK_HOOK_CODE pxTaskTag;\r
+               TaskHookFunction_t pxTaskTag;\r
+       #endif\r
+\r
+       #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )\r
+               void *pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];\r
        #endif\r
 \r
        #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
-               unsigned long ulRunTimeCounter;                 /*< Stores the amount of time the task has spent in the Running state. */\r
+               uint32_t                ulRunTimeCounter;       /*< Stores the amount of time the task has spent in the Running state. */\r
        #endif\r
 \r
        #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
@@ -164,11 +184,20 @@ typedef struct tskTaskControlBlock
                newlib and must provide system-wide implementations of the necessary\r
                stubs. Be warned that (at the time of writing) the current newlib design\r
                implements a system-wide malloc() that must be provided with locks. */\r
-               struct _reent xNewLib_reent;\r
+               struct  _reent xNewLib_reent;\r
+       #endif\r
+\r
+       #if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
+               volatile uint32_t ulNotifiedValue;\r
+               volatile eNotifyValue eNotifyState;\r
        #endif\r
 \r
 } tskTCB;\r
 \r
+/* The old tskTCB name is maintained above then typedefed to the new TCB_t name\r
+below to enable the use of older kernel aware debuggers. */\r
+typedef tskTCB TCB_t;\r
+\r
 /*\r
  * Some kernel aware debuggers require the data the debugger needs access to to\r
  * be global, rather than file scope.\r
@@ -180,51 +209,60 @@ typedef struct tskTaskControlBlock
 /*lint -e956 A manual analysis and inspection has been used to determine which\r
 static variables must be declared volatile. */\r
 \r
-PRIVILEGED_DATA tskTCB * volatile pxCurrentTCB = NULL;\r
+PRIVILEGED_DATA TCB_t * volatile pxCurrentTCB = NULL;\r
 \r
 /* Lists for ready and blocked tasks. --------------------*/\r
-PRIVILEGED_DATA static xList pxReadyTasksLists[ configMAX_PRIORITIES ];        /*< Prioritised ready tasks. */\r
-PRIVILEGED_DATA static xList xDelayedTaskList1;                                                        /*< Delayed tasks. */\r
-PRIVILEGED_DATA static xList xDelayedTaskList2;                                                        /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */\r
-PRIVILEGED_DATA static xList * volatile pxDelayedTaskList;                             /*< Points to the delayed task list currently being used. */\r
-PRIVILEGED_DATA static xList * volatile pxOverflowDelayedTaskList;             /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */\r
-PRIVILEGED_DATA static xList xPendingReadyList;                                                        /*< Tasks that have been readied while the scheduler was suspended.  They will be moved to the ready list when the scheduler is resumed. */\r
+PRIVILEGED_DATA static List_t pxReadyTasksLists[ configMAX_PRIORITIES ];/*< Prioritised ready tasks. */\r
+PRIVILEGED_DATA static List_t xDelayedTaskList1;                                               /*< Delayed tasks. */\r
+PRIVILEGED_DATA static List_t xDelayedTaskList2;                                               /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */\r
+PRIVILEGED_DATA static List_t * volatile pxDelayedTaskList;                            /*< Points to the delayed task list currently being used. */\r
+PRIVILEGED_DATA static List_t * volatile pxOverflowDelayedTaskList;            /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */\r
+PRIVILEGED_DATA static List_t xPendingReadyList;                                               /*< Tasks that have been readied while the scheduler was suspended.  They will be moved to the ready list when the scheduler is resumed. */\r
 \r
 #if ( INCLUDE_vTaskDelete == 1 )\r
 \r
-       PRIVILEGED_DATA static xList xTasksWaitingTermination;                          /*< Tasks that have been deleted - but their memory not yet freed. */\r
-       PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxTasksDeleted = ( unsigned portBASE_TYPE ) 0U;\r
+       PRIVILEGED_DATA static List_t xTasksWaitingTermination;                         /*< Tasks that have been deleted - but their memory not yet freed. */\r
+       PRIVILEGED_DATA static volatile UBaseType_t uxTasksDeleted = ( UBaseType_t ) 0U;\r
 \r
 #endif\r
 \r
 #if ( INCLUDE_vTaskSuspend == 1 )\r
 \r
-       PRIVILEGED_DATA static xList xSuspendedTaskList;                                        /*< Tasks that are currently suspended. */\r
+       PRIVILEGED_DATA static List_t xSuspendedTaskList;                                       /*< Tasks that are currently suspended. */\r
 \r
 #endif\r
 \r
 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
 \r
-       PRIVILEGED_DATA static xTaskHandle xIdleTaskHandle = NULL;                      /*< Holds the handle of the idle task.  The idle task is created automatically when the scheduler is started. */\r
+       PRIVILEGED_DATA static TaskHandle_t xIdleTaskHandle = NULL;                     /*< Holds the handle of the idle task.  The idle task is created automatically when the scheduler is started. */\r
 \r
 #endif\r
 \r
 /* Other file private variables. --------------------------------*/\r
-PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxCurrentNumberOfTasks  = ( unsigned portBASE_TYPE ) 0U;\r
-PRIVILEGED_DATA static volatile portTickType xTickCount                                                = ( portTickType ) 0U;\r
-PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxTopReadyPriority              = tskIDLE_PRIORITY;\r
-PRIVILEGED_DATA static volatile signed portBASE_TYPE xSchedulerRunning                         = pdFALSE;\r
-PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxSchedulerSuspended            = ( unsigned portBASE_TYPE ) pdFALSE;\r
-PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxPendedTicks                   = ( unsigned portBASE_TYPE ) 0U;\r
-PRIVILEGED_DATA static volatile portBASE_TYPE xYieldPending                                    = pdFALSE;\r
-PRIVILEGED_DATA static volatile portBASE_TYPE xNumOfOverflows                                  = ( portBASE_TYPE ) 0;\r
-PRIVILEGED_DATA static unsigned portBASE_TYPE uxTaskNumber                                             = ( unsigned portBASE_TYPE ) 0U;\r
-PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime                              = portMAX_DELAY;\r
+PRIVILEGED_DATA static volatile UBaseType_t uxCurrentNumberOfTasks     = ( UBaseType_t ) 0U;\r
+PRIVILEGED_DATA static volatile TickType_t xTickCount                          = ( TickType_t ) 0U;\r
+PRIVILEGED_DATA static volatile UBaseType_t uxTopReadyPriority                 = tskIDLE_PRIORITY;\r
+PRIVILEGED_DATA static volatile BaseType_t xSchedulerRunning           = pdFALSE;\r
+PRIVILEGED_DATA static volatile UBaseType_t uxPendedTicks                      = ( UBaseType_t ) 0U;\r
+PRIVILEGED_DATA static volatile BaseType_t xYieldPending                       = pdFALSE;\r
+PRIVILEGED_DATA static volatile BaseType_t xNumOfOverflows                     = ( BaseType_t ) 0;\r
+PRIVILEGED_DATA static UBaseType_t uxTaskNumber                                        = ( UBaseType_t ) 0U;\r
+PRIVILEGED_DATA static volatile TickType_t xNextTaskUnblockTime                = portMAX_DELAY;\r
+\r
+/* Context switches are held pending while the scheduler is suspended.  Also,\r
+interrupts must not manipulate the xGenericListItem of a TCB, or any of the\r
+lists the xGenericListItem can be referenced from, if the scheduler is suspended.\r
+If an interrupt needs to unblock a task while the scheduler is suspended then it\r
+moves the task's event list item into the xPendingReadyList, ready for the\r
+kernel to move the task from the pending ready list into the real ready list\r
+when the scheduler is unsuspended.  The pending ready list itself can only be\r
+accessed from a critical section. */\r
+PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended       = ( UBaseType_t ) pdFALSE;\r
 \r
 #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
 \r
-       PRIVILEGED_DATA static unsigned long ulTaskSwitchedInTime = 0UL;        /*< Holds the value of a timer/counter the last time a task was switched in. */\r
-       PRIVILEGED_DATA static unsigned long ulTotalRunTime = 0UL;                      /*< Holds the total amount of execution time as defined by the run time counter clock. */\r
+       PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL;     /*< Holds the value of a timer/counter the last time a task was switched in. */\r
+       PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL;           /*< Holds the total amount of execution time as defined by the run time counter clock. */\r
 \r
 #endif\r
 \r
@@ -241,10 +279,10 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime                         = portMAX_D
 /*\r
  * Macros used by vListTask to indicate which state a task is in.\r
  */\r
-#define tskBLOCKED_CHAR                ( ( signed char ) 'B' )\r
-#define tskREADY_CHAR          ( ( signed char ) 'R' )\r
-#define tskDELETED_CHAR                ( ( signed char ) 'D' )\r
-#define tskSUSPENDED_CHAR      ( ( signed char ) 'S' )\r
+#define tskBLOCKED_CHAR                ( 'B' )\r
+#define tskREADY_CHAR          ( 'R' )\r
+#define tskDELETED_CHAR                ( 'D' )\r
+#define tskSUSPENDED_CHAR      ( 'S' )\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -256,28 +294,28 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime                         = portMAX_D
 \r
        /* uxTopReadyPriority holds the priority of the highest priority ready\r
        state task. */\r
-       #define taskRECORD_READY_PRIORITY( uxPriority )                                                                                                                                         \\r
-       {                                                                                                                                                                                                                                       \\r
-               if( ( uxPriority ) > uxTopReadyPriority )                                                                                                                                               \\r
-               {                                                                                                                                                                                                                               \\r
-                       uxTopReadyPriority = ( uxPriority );                                                                                                                                            \\r
-               }                                                                                                                                                                                                                               \\r
+       #define taskRECORD_READY_PRIORITY( uxPriority )                                                                                                         \\r
+       {                                                                                                                                                                                                       \\r
+               if( ( uxPriority ) > uxTopReadyPriority )                                                                                                               \\r
+               {                                                                                                                                                                                               \\r
+                       uxTopReadyPriority = ( uxPriority );                                                                                                            \\r
+               }                                                                                                                                                                                               \\r
        } /* taskRECORD_READY_PRIORITY */\r
 \r
        /*-----------------------------------------------------------*/\r
 \r
-       #define taskSELECT_HIGHEST_PRIORITY_TASK()                                                                                                                                                      \\r
-       {                                                                                                                                                                                                                                       \\r
-               /* Find the highest priority queue that contains ready tasks. */                                                                                                \\r
-               while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )                                                                              \\r
-               {                                                                                                                                                                                                                               \\r
-                       configASSERT( uxTopReadyPriority );                                                                                                                                                     \\r
-                       --uxTopReadyPriority;                                                                                                                                                                           \\r
-               }                                                                                                                                                                                                                               \\r
-                                                                                                                                                                                                                                               \\r
-               /* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of                                                                                \\r
-               the     same priority get an equal share of the processor time. */                                                                                                      \\r
-               listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );                                              \\r
+       #define taskSELECT_HIGHEST_PRIORITY_TASK()                                                                                                                      \\r
+       {                                                                                                                                                                                                       \\r
+               /* Find the highest priority queue that contains ready tasks. */                                                                \\r
+               while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )                                              \\r
+               {                                                                                                                                                                                               \\r
+                       configASSERT( uxTopReadyPriority );                                                                                                                     \\r
+                       --uxTopReadyPriority;                                                                                                                                           \\r
+               }                                                                                                                                                                                               \\r
+                                                                                                                                                                                                               \\r
+               /* listGET_OWNER_OF_NEXT_ENTRY indexes through the list, so the tasks of                                                \\r
+               the     same priority get an equal share of the processor time. */                                                                      \\r
+               listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );              \\r
        } /* taskSELECT_HIGHEST_PRIORITY_TASK */\r
 \r
        /*-----------------------------------------------------------*/\r
@@ -301,7 +339,7 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime                           = portMAX_D
 \r
        #define taskSELECT_HIGHEST_PRIORITY_TASK()                                                                                                              \\r
        {                                                                                                                                                                                               \\r
-       unsigned portBASE_TYPE uxTopPriority;                                                                                                                   \\r
+       UBaseType_t uxTopPriority;                                                                                                                                              \\r
                                                                                                                                                                                                        \\r
                /* Find the highest priority queue that contains ready tasks. */                                                        \\r
                portGET_HIGHEST_PRIORITY( uxTopPriority, uxTopReadyPriority );                                                          \\r
@@ -314,12 +352,12 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime                         = portMAX_D
        /* A port optimised version is provided, call it only if the TCB being reset\r
        is being referenced from a ready list.  If it is referenced from a delayed\r
        or suspended list then it won't be in a ready list. */\r
-       #define taskRESET_READY_PRIORITY( uxPriority )                                                                                                  \\r
-       {                                                                                                                                                                                               \\r
-               if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ ( uxPriority ) ] ) ) == 0 )                          \\r
-               {                                                                                                                                                                                       \\r
-                       portRESET_READY_PRIORITY( ( uxPriority ), ( uxTopReadyPriority ) );                                             \\r
-               }                                                                                                                                                                                       \\r
+       #define taskRESET_READY_PRIORITY( uxPriority )                                                                                                          \\r
+       {                                                                                                                                                                                                       \\r
+               if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ ( uxPriority ) ] ) ) == ( UBaseType_t ) 0 )  \\r
+               {                                                                                                                                                                                               \\r
+                       portRESET_READY_PRIORITY( ( uxPriority ), ( uxTopReadyPriority ) );                                                     \\r
+               }                                                                                                                                                                                               \\r
        }\r
 \r
 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
@@ -330,7 +368,7 @@ PRIVILEGED_DATA static volatile portTickType xNextTaskUnblockTime                           = portMAX_D
 count overflows. */\r
 #define taskSWITCH_DELAYED_LISTS()                                                                                                                                     \\r
 {                                                                                                                                                                                                      \\r
-       xList *pxTemp;                                                                                                                                                                  \\r
+       List_t *pxTemp;                                                                                                                                                                 \\r
                                                                                                                                                                                                        \\r
        /* The delayed tasks list should be empty when the lists are switched. */                                               \\r
        configASSERT( ( listLIST_IS_EMPTY( pxDelayedTaskList ) ) );                                                                             \\r
@@ -348,19 +386,19 @@ count overflows. */
  * Place the task represented by pxTCB into the appropriate ready list for\r
  * the task.  It is inserted at the end of the list.\r
  */\r
-#define prvAddTaskToReadyList( pxTCB )                                                                                                                                                         \\r
-       traceMOVED_TASK_TO_READY_STATE( pxTCB )                                                                                                                                                 \\r
-       taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority );                                                                                                                             \\r
+#define prvAddTaskToReadyList( pxTCB )                                                                                                                         \\r
+       traceMOVED_TASK_TO_READY_STATE( pxTCB );                                                                                                                \\r
+       taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority );                                                                                             \\r
        vListInsertEnd( &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) )\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
- * Several functions take an xTaskHandle parameter that can optionally be NULL,\r
+ * Several functions take an TaskHandle_t parameter that can optionally be NULL,\r
  * where NULL is used to indicate that the handle of the currently executing\r
  * task should be used in place of the parameter.  This macro simply checks to\r
  * see if the parameter is NULL and returns a pointer to the appropriate TCB.\r
  */\r
-#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) ( pxHandle ) )\r
+#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( TCB_t * ) pxCurrentTCB : ( TCB_t * ) ( pxHandle ) )\r
 \r
 /* The item value of the event list item is normally used to hold the priority\r
 of the task to which it belongs (coded to allow it to be held in reverse\r
@@ -378,7 +416,7 @@ to its original value when it is released. */
 \r
 /* Callback function prototypes. --------------------------*/\r
 #if configCHECK_FOR_STACK_OVERFLOW > 0\r
-       extern void vApplicationStackOverflowHook( xTaskHandle xTask, signed char *pcTaskName );\r
+       extern void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName );\r
 #endif\r
 \r
 #if configUSE_TICK_HOOK > 0\r
@@ -391,7 +429,16 @@ to its original value when it is released. */
  * Utility to ready a TCB for a given task.  Mainly just copies the parameters\r
  * into the TCB structure.\r
  */\r
-static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const pcName, unsigned portBASE_TYPE uxPriority, const xMemoryRegion * const xRegions, unsigned short usStackDepth ) PRIVILEGED_FUNCTION;\r
+static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const pcName, UBaseType_t uxPriority, const MemoryRegion_t * const xRegions, const uint16_t usStackDepth ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+\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
+#if ( INCLUDE_vTaskSuspend == 1 )\r
+       static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;\r
+#endif /* INCLUDE_vTaskSuspend */\r
 \r
 /*\r
  * Utility to ready all the lists used by the scheduler.  This is called\r
@@ -421,7 +468,7 @@ static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters );
  */\r
 #if ( INCLUDE_vTaskDelete == 1 )\r
 \r
-       static void prvDeleteTCB( tskTCB *pxTCB ) PRIVILEGED_FUNCTION;\r
+       static void prvDeleteTCB( TCB_t *pxTCB ) PRIVILEGED_FUNCTION;\r
 \r
 #endif\r
 \r
@@ -436,16 +483,16 @@ static void prvCheckTasksWaitingTermination( void ) PRIVILEGED_FUNCTION;
  * The currently executing task is entering the Blocked state.  Add the task to\r
  * either the current or the overflow delayed task list.\r
  */\r
-static void prvAddCurrentTaskToDelayedList( portTickType xTimeToWake ) PRIVILEGED_FUNCTION;\r
+static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Allocates memory from the heap for a TCB and associated stack.  Checks the\r
  * allocation was successful.\r
  */\r
-static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TYPE *puxStackBuffer ) PRIVILEGED_FUNCTION;\r
+static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
- * Fills an xTaskStatusType structure with information on each task that is\r
+ * Fills an TaskStatus_t structure with information on each task that is\r
  * referenced from the pxList list (which may be a ready list, a delayed list,\r
  * a suspended list, etc.).\r
  *\r
@@ -454,7 +501,7 @@ static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TY
  */\r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       static unsigned portBASE_TYPE prvListTaskWithinSingleList( xTaskStatusType *pxTaskStatusArray, xList *pxList, eTaskState eState ) PRIVILEGED_FUNCTION;\r
+       static UBaseType_t prvListTaskWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState ) PRIVILEGED_FUNCTION;\r
 \r
 #endif\r
 \r
@@ -465,7 +512,7 @@ static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TY
  */\r
 #if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
 \r
-       static unsigned short prvTaskCheckFreeStackSpace( const unsigned char * pucStackByte ) PRIVILEGED_FUNCTION;\r
+       static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte ) PRIVILEGED_FUNCTION;\r
 \r
 #endif\r
 \r
@@ -480,7 +527,7 @@ static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TY
  */\r
 #if ( configUSE_TICKLESS_IDLE != 0 )\r
 \r
-       static portTickType prvGetExpectedIdleTime( void ) PRIVILEGED_FUNCTION;\r
+       static TickType_t prvGetExpectedIdleTime( void ) PRIVILEGED_FUNCTION;\r
 \r
 #endif\r
 \r
@@ -490,15 +537,25 @@ static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TY
  */\r
 static void prvResetNextTaskUnblockTime( void );\r
 \r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )\r
+\r
+       /*\r
+        * Helper function used to pad task names with spaces when printing out\r
+        * human readable tables of task information.\r
+        */\r
+       static char *prvWriteNameToBuffer( char *pcBuffer, const char *pcTaskName );\r
+\r
+#endif\r
 /*-----------------------------------------------------------*/\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 )\r
+BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, const MemoryRegion_t * const xRegions ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 {\r
-signed portBASE_TYPE xReturn;\r
-tskTCB * pxNewTCB;\r
+BaseType_t xReturn;\r
+TCB_t * pxNewTCB;\r
+StackType_t *pxTopOfStack;\r
 \r
        configASSERT( pxTaskCode );\r
-       configASSERT( ( ( uxPriority & ( ~portPRIVILEGE_BIT ) ) < configMAX_PRIORITIES ) );\r
+       configASSERT( ( ( uxPriority & ( UBaseType_t ) ( ~portPRIVILEGE_BIT ) ) < ( UBaseType_t ) configMAX_PRIORITIES ) );\r
 \r
        /* Allocate the memory required by the TCB and stack for the new task,\r
        checking that the allocation was successful. */\r
@@ -506,11 +563,9 @@ tskTCB * pxNewTCB;
 \r
        if( pxNewTCB != NULL )\r
        {\r
-               portSTACK_TYPE *pxTopOfStack;\r
-\r
                #if( portUSING_MPU_WRAPPERS == 1 )\r
                        /* Should the task be created in privileged mode? */\r
-                       portBASE_TYPE xRunPrivileged;\r
+                       BaseType_t xRunPrivileged;\r
                        if( ( uxPriority & portPRIVILEGE_BIT ) != 0U )\r
                        {\r
                                xRunPrivileged = pdTRUE;\r
@@ -520,6 +575,20 @@ tskTCB * pxNewTCB;
                                xRunPrivileged = pdFALSE;\r
                        }\r
                        uxPriority &= ~portPRIVILEGE_BIT;\r
+\r
+                       if( puxStackBuffer != NULL )\r
+                       {\r
+                               /* The application provided its own stack.  Note this so no\r
+                               attempt is made to delete the stack should that task be\r
+                               deleted. */\r
+                               pxNewTCB->xUsingStaticallyAllocatedStack = pdTRUE;\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The stack was allocated dynamically.  Note this so it can be\r
+                               deleted again if the task is deleted. */\r
+                               pxNewTCB->xUsingStaticallyAllocatedStack = pdFALSE;\r
+                       }\r
                #endif /* portUSING_MPU_WRAPPERS == 1 */\r
 \r
                /* Calculate the top of stack address.  This depends on whether the\r
@@ -528,18 +597,18 @@ tskTCB * pxNewTCB;
                required by the port. */\r
                #if( portSTACK_GROWTH < 0 )\r
                {\r
-                       pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( unsigned short ) 1 );\r
-                       pxTopOfStack = ( portSTACK_TYPE * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ( portPOINTER_SIZE_TYPE ) ~portBYTE_ALIGNMENT_MASK  ) ); /*lint !e923 MISRA exception.  Avoiding casts between pointers and integers is not practical.  Size differences accounted for using portPOINTER_SIZE_TYPE type. */\r
+                       pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( uint16_t ) 1 );\r
+                       pxTopOfStack = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); /*lint !e923 MISRA exception.  Avoiding casts between pointers and integers is not practical.  Size differences accounted for using portPOINTER_SIZE_TYPE type. */\r
 \r
                        /* Check the alignment of the calculated top of stack is correct. */\r
-                       configASSERT( ( ( ( unsigned long ) pxTopOfStack & ( unsigned long ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
+                       configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxTopOfStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
                }\r
                #else /* portSTACK_GROWTH */\r
                {\r
                        pxTopOfStack = pxNewTCB->pxStack;\r
 \r
                        /* Check the alignment of the stack buffer is correct. */\r
-                       configASSERT( ( ( ( unsigned long ) pxNewTCB->pxStack & ( unsigned long ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
+                       configASSERT( ( ( ( portPOINTER_SIZE_TYPE ) pxNewTCB->pxStack & ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) == 0UL ) );\r
 \r
                        /* If we want to use stack checking on architectures that use\r
                        a positive stack growth direction then we also need to store the\r
@@ -570,7 +639,11 @@ tskTCB * pxNewTCB;
                        /* Pass the TCB out - in an anonymous way.  The calling function/\r
                        task can use this as a handle to delete the task later if\r
                        required.*/\r
-                       *pxCreatedTask = ( xTaskHandle ) pxNewTCB;\r
+                       *pxCreatedTask = ( TaskHandle_t ) pxNewTCB;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
 \r
                /* Ensure interrupts don't access the task lists while they are being\r
@@ -584,13 +657,17 @@ tskTCB * pxNewTCB;
                                the suspended state - make this the current task. */\r
                                pxCurrentTCB =  pxNewTCB;\r
 \r
-                               if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1 )\r
+                               if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 )\r
                                {\r
                                        /* This is the first task to be created so do the preliminary\r
                                        initialisation required.  We will not recover if this call\r
                                        fails, but we will report the failure. */\r
                                        prvInitialiseTaskLists();\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
                        else\r
                        {\r
@@ -603,6 +680,14 @@ tskTCB * pxNewTCB;
                                        {\r
                                                pxCurrentTCB = pxNewTCB;\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
                        }\r
 \r
@@ -639,6 +724,14 @@ tskTCB * pxNewTCB;
                        {\r
                                taskYIELD_IF_USING_PREEMPTION();\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
        }\r
 \r
@@ -648,9 +741,9 @@ tskTCB * pxNewTCB;
 \r
 #if ( INCLUDE_vTaskDelete == 1 )\r
 \r
-       void vTaskDelete( xTaskHandle xTaskToDelete )\r
+       void vTaskDelete( TaskHandle_t xTaskToDelete )\r
        {\r
-       tskTCB *pxTCB;\r
+       TCB_t *pxTCB;\r
 \r
                taskENTER_CRITICAL();\r
                {\r
@@ -662,16 +755,24 @@ tskTCB * pxNewTCB;
                        This will stop the task from be scheduled.  The idle task will check\r
                        the termination list and free up any memory allocated by the\r
                        scheduler for the TCB and stack. */\r
-                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
                        {\r
                                taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
 \r
                        /* Is the task waiting on an event also? */\r
                        if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
                        {\r
                                ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
 \r
                        vListInsertEnd( &xTasksWaitingTermination, &( pxTCB->xGenericListItem ) );\r
 \r
@@ -708,7 +809,11 @@ tskTCB * pxNewTCB;
                        {\r
                                /* Reset the next expected unblock time in case it referred to\r
                                the task that has just been deleted. */\r
-                               prvResetNextTaskUnblockTime();\r
+                               taskENTER_CRITICAL();\r
+                               {\r
+                                       prvResetNextTaskUnblockTime();\r
+                               }\r
+                               taskEXIT_CRITICAL();\r
                        }\r
                }\r
        }\r
@@ -718,10 +823,10 @@ tskTCB * pxNewTCB;
 \r
 #if ( INCLUDE_vTaskDelayUntil == 1 )\r
 \r
-       void vTaskDelayUntil( portTickType * const pxPreviousWakeTime, const portTickType xTimeIncrement )\r
+       void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement )\r
        {\r
-       portTickType xTimeToWake;\r
-       portBASE_TYPE xAlreadyYielded, xShouldDelay = pdFALSE;\r
+       TickType_t xTimeToWake;\r
+       BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE;\r
 \r
                configASSERT( pxPreviousWakeTime );\r
                configASSERT( ( xTimeIncrement > 0U ) );\r
@@ -731,7 +836,7 @@ tskTCB * pxNewTCB;
                {\r
                        /* Minor optimisation.  The tick count cannot change in this\r
                        block. */\r
-                       const portTickType xConstTickCount = xTickCount;\r
+                       const TickType_t xConstTickCount = xTickCount;\r
 \r
                        /* Generate the tick time at which the task wants to wake. */\r
                        xTimeToWake = *pxPreviousWakeTime + xTimeIncrement;\r
@@ -747,6 +852,10 @@ tskTCB * pxNewTCB;
                                {\r
                                        xShouldDelay = pdTRUE;\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
                        else\r
                        {\r
@@ -757,6 +866,10 @@ tskTCB * pxNewTCB;
                                {\r
                                        xShouldDelay = pdTRUE;\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
 \r
                        /* Update the wake time ready for the next call. */\r
@@ -766,19 +879,26 @@ tskTCB * pxNewTCB;
                        {\r
                                traceTASK_DELAY_UNTIL();\r
 \r
-                               /* We must remove ourselves from the ready list before adding\r
-                               ourselves to the blocked list as the same list item is used for\r
-                               both lists. */\r
-                               if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+                               /* Remove the task from the ready list before adding it to the\r
+                               blocked list as the same list item is used for both lists. */\r
+                               if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
                                {\r
                                        /* The current task must be in a ready list, so there is\r
                                        no need to check, and the port reset macro can be called\r
                                        directly. */\r
                                        portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
 \r
                                prvAddCurrentTaskToDelayedList( xTimeToWake );\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                xAlreadyYielded = xTaskResumeAll();\r
 \r
@@ -788,6 +908,10 @@ tskTCB * pxNewTCB;
                {\r
                        portYIELD_WITHIN_API();\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
 \r
 #endif /* INCLUDE_vTaskDelayUntil */\r
@@ -795,14 +919,14 @@ tskTCB * pxNewTCB;
 \r
 #if ( INCLUDE_vTaskDelay == 1 )\r
 \r
-       void vTaskDelay( const portTickType xTicksToDelay )\r
+       void vTaskDelay( const TickType_t xTicksToDelay )\r
        {\r
-       portTickType xTimeToWake;\r
-       signed portBASE_TYPE xAlreadyYielded = pdFALSE;\r
+       TickType_t xTimeToWake;\r
+       BaseType_t xAlreadyYielded = pdFALSE;\r
 \r
 \r
                /* A delay time of zero just forces a reschedule. */\r
-               if( xTicksToDelay > ( portTickType ) 0U )\r
+               if( xTicksToDelay > ( TickType_t ) 0U )\r
                {\r
                        configASSERT( uxSchedulerSuspended == 0 );\r
                        vTaskSuspendAll();\r
@@ -824,17 +948,25 @@ tskTCB * pxNewTCB;
                                /* We must remove ourselves from the ready list before adding\r
                                ourselves to the blocked list as the same list item is used for\r
                                both lists. */\r
-                               if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+                               if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
                                {\r
                                        /* The current task must be in a ready list, so there is\r
                                        no need to check, and the port reset macro can be called\r
                                        directly. */\r
                                        portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                                prvAddCurrentTaskToDelayedList( xTimeToWake );\r
                        }\r
                        xAlreadyYielded = xTaskResumeAll();\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
 \r
                /* Force a reschedule if xTaskResumeAll has not already done so, we may\r
                have put ourselves to sleep. */\r
@@ -842,6 +974,10 @@ tskTCB * pxNewTCB;
                {\r
                        portYIELD_WITHIN_API();\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
 \r
 #endif /* INCLUDE_vTaskDelay */\r
@@ -849,11 +985,11 @@ tskTCB * pxNewTCB;
 \r
 #if ( INCLUDE_eTaskGetState == 1 )\r
 \r
-       eTaskState eTaskGetState( xTaskHandle xTask )\r
+       eTaskState eTaskGetState( TaskHandle_t xTask )\r
        {\r
        eTaskState eReturn;\r
-       xList *pxStateList;\r
-       const tskTCB * const pxTCB = ( tskTCB * ) xTask;\r
+       List_t *pxStateList;\r
+       const TCB_t * const pxTCB = ( TCB_t * ) xTask;\r
 \r
                configASSERT( pxTCB );\r
 \r
@@ -866,7 +1002,7 @@ tskTCB * pxNewTCB;
                {\r
                        taskENTER_CRITICAL();\r
                        {\r
-                               pxStateList = ( xList * ) listLIST_ITEM_CONTAINER( &( pxTCB->xGenericListItem ) );\r
+                               pxStateList = ( List_t * ) listLIST_ITEM_CONTAINER( &( pxTCB->xGenericListItem ) );\r
                        }\r
                        taskEXIT_CRITICAL();\r
 \r
@@ -903,7 +1039,7 @@ tskTCB * pxNewTCB;
                                }\r
                        #endif\r
 \r
-                       else\r
+                       else /*lint !e525 Negative indentation is intended to make use of pre-processor clearer. */\r
                        {\r
                                /* If the task is not in any other state, it must be in the\r
                                Ready (including pending ready) state. */\r
@@ -912,17 +1048,17 @@ tskTCB * pxNewTCB;
                }\r
 \r
                return eReturn;\r
-       }\r
+       } /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */\r
 \r
 #endif /* INCLUDE_eTaskGetState */\r
 /*-----------------------------------------------------------*/\r
 \r
 #if ( INCLUDE_uxTaskPriorityGet == 1 )\r
 \r
-       unsigned portBASE_TYPE uxTaskPriorityGet( xTaskHandle xTask )\r
+       UBaseType_t uxTaskPriorityGet( TaskHandle_t xTask )\r
        {\r
-       tskTCB *pxTCB;\r
-       unsigned portBASE_TYPE uxReturn;\r
+       TCB_t *pxTCB;\r
+       UBaseType_t uxReturn;\r
 \r
                taskENTER_CRITICAL();\r
                {\r
@@ -939,20 +1075,64 @@ tskTCB * pxNewTCB;
 #endif /* INCLUDE_uxTaskPriorityGet */\r
 /*-----------------------------------------------------------*/\r
 \r
+#if ( INCLUDE_uxTaskPriorityGet == 1 )\r
+\r
+       UBaseType_t uxTaskPriorityGetFromISR( TaskHandle_t xTask )\r
+       {\r
+       TCB_t *pxTCB;\r
+       UBaseType_t uxReturn, uxSavedInterruptState;\r
+\r
+               /* RTOS ports that support interrupt nesting have the concept of a\r
+               maximum system call (or maximum API call) interrupt priority.\r
+               Interrupts that are     above the maximum system call priority are keep\r
+               permanently enabled, even when the RTOS kernel is in a critical section,\r
+               but cannot make any calls to FreeRTOS API functions.  If configASSERT()\r
+               is defined in FreeRTOSConfig.h then\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+               failure if a FreeRTOS API function is called from an interrupt that has\r
+               been assigned a priority above the configured maximum system call\r
+               priority.  Only FreeRTOS functions that end in FromISR can be called\r
+               from interrupts that have been assigned a priority at or (logically)\r
+               below the maximum system call interrupt priority.  FreeRTOS maintains a\r
+               separate interrupt safe API to ensure interrupt entry is as fast and as\r
+               simple as possible.  More information (albeit Cortex-M specific) is\r
+               provided on the following link:\r
+               http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+               uxSavedInterruptState = portSET_INTERRUPT_MASK_FROM_ISR();\r
+               {\r
+                       /* If null is passed in here then it is the priority of the calling\r
+                       task that is being queried. */\r
+                       pxTCB = prvGetTCBFromHandle( xTask );\r
+                       uxReturn = pxTCB->uxPriority;\r
+               }\r
+               portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptState );\r
+\r
+               return uxReturn;\r
+       }\r
+\r
+#endif /* INCLUDE_uxTaskPriorityGet */\r
+/*-----------------------------------------------------------*/\r
+\r
 #if ( INCLUDE_vTaskPrioritySet == 1 )\r
 \r
-       void vTaskPrioritySet( xTaskHandle xTask, unsigned portBASE_TYPE uxNewPriority )\r
+       void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority )\r
        {\r
-       tskTCB *pxTCB;\r
-       unsigned portBASE_TYPE uxCurrentBasePriority, uxPriorityUsedOnEntry;\r
-       portBASE_TYPE xYieldRequired = pdFALSE;\r
+       TCB_t *pxTCB;\r
+       UBaseType_t uxCurrentBasePriority, uxPriorityUsedOnEntry;\r
+       BaseType_t xYieldRequired = pdFALSE;\r
 \r
                configASSERT( ( uxNewPriority < configMAX_PRIORITIES ) );\r
 \r
                /* Ensure the new priority is valid. */\r
-               if( uxNewPriority >= ( unsigned portBASE_TYPE ) configMAX_PRIORITIES )\r
+               if( uxNewPriority >= ( UBaseType_t ) configMAX_PRIORITIES )\r
                {\r
-                       uxNewPriority = ( unsigned portBASE_TYPE ) configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U;\r
+                       uxNewPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U;\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
 \r
                taskENTER_CRITICAL();\r
@@ -988,6 +1168,10 @@ tskTCB * pxNewTCB;
                                                {\r
                                                        xYieldRequired = pdTRUE;\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
                                        }\r
                                        else\r
                                        {\r
@@ -1023,6 +1207,10 @@ tskTCB * pxNewTCB;
                                        {\r
                                                pxTCB->uxPriority = uxNewPriority;\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
 \r
                                        /* The base priority gets set whatever. */\r
                                        pxTCB->uxBasePriority = uxNewPriority;\r
@@ -1035,9 +1223,13 @@ tskTCB * pxNewTCB;
 \r
                                /* Only reset the event list item value if the value is not\r
                                being used for anything else. */\r
-                               if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0 )\r
+                               if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL )\r
                                {\r
-                                       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( portTickType ) configMAX_PRIORITIES - ( portTickType ) uxNewPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                                       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxNewPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
 \r
                                /* If the task is in the blocked or suspended list we need do\r
@@ -1049,20 +1241,32 @@ tskTCB * pxNewTCB;
                                        /* The task is currently in its ready list - remove before adding\r
                                        it to it's new ready list.  As we are in a critical section we\r
                                        can do this even if the scheduler is suspended. */\r
-                                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+                                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
                                        {\r
                                                /* It is known that the task is in its ready list so\r
                                                there is no need to check again and the port level\r
                                                reset macro can be called directly. */\r
                                                portRESET_READY_PRIORITY( uxPriorityUsedOnEntry, uxTopReadyPriority );\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                        prvAddTaskToReadyList( pxTCB );\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
 \r
                                if( xYieldRequired == pdTRUE )\r
                                {\r
                                        taskYIELD_IF_USING_PREEMPTION();\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
 \r
                                /* Remove compiler warning about unused variables when the port\r
                                optimised task selection is not being used. */\r
@@ -1077,9 +1281,9 @@ tskTCB * pxNewTCB;
 \r
 #if ( INCLUDE_vTaskSuspend == 1 )\r
 \r
-       void vTaskSuspend( xTaskHandle xTaskToSuspend )\r
+       void vTaskSuspend( TaskHandle_t xTaskToSuspend )\r
        {\r
-       tskTCB *pxTCB;\r
+       TCB_t *pxTCB;\r
 \r
                taskENTER_CRITICAL();\r
                {\r
@@ -1091,16 +1295,24 @@ tskTCB * pxNewTCB;
 \r
                        /* Remove task from the ready/delayed list and place in the\r
                        suspended list. */\r
-                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
                        {\r
                                taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
 \r
                        /* Is the task waiting on an event also? */\r
                        if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
                        {\r
                                ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
 \r
                        vListInsertEnd( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) );\r
                }\r
@@ -1140,7 +1352,15 @@ tskTCB * pxNewTCB;
                                /* A task other than the currently running task was suspended,\r
                                reset the next expected unblock time in case it referred to the\r
                                task that is now in the Suspended state. */\r
-                               prvResetNextTaskUnblockTime();\r
+                               taskENTER_CRITICAL();\r
+                               {\r
+                                       prvResetNextTaskUnblockTime();\r
+                               }\r
+                               taskEXIT_CRITICAL();\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
                        }\r
                }\r
        }\r
@@ -1150,31 +1370,43 @@ tskTCB * pxNewTCB;
 \r
 #if ( INCLUDE_vTaskSuspend == 1 )\r
 \r
-       signed portBASE_TYPE xTaskIsTaskSuspended( const xTaskHandle xTask )\r
+       static BaseType_t prvTaskIsTaskSuspended( const TaskHandle_t xTask )\r
        {\r
-       signed portBASE_TYPE xReturn = pdFALSE;\r
-       const tskTCB * const pxTCB = ( tskTCB * ) xTask;\r
+       BaseType_t xReturn = pdFALSE;\r
+       const TCB_t * const pxTCB = ( TCB_t * ) xTask;\r
+\r
+               /* Accesses xPendingReadyList so must be called from a critical\r
+               section. */\r
 \r
                /* It does not make sense to check if the calling task is suspended. */\r
                configASSERT( xTask );\r
 \r
-               /* Is the task we are attempting to resume actually in the\r
-               suspended list? */\r
+               /* Is the task being resumed actually in the suspended list? */\r
                if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
                {\r
                        /* Has the task already been resumed from within an ISR? */\r
                        if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) == pdFALSE )\r
                        {\r
-                               /* Is it in the suspended list because it is in the\r
-                               Suspended state?  It is possible to be in the suspended\r
-                               list because it is blocked on a task with no timeout\r
-                               specified. */\r
+                               /* Is it in the suspended list because it is in the     Suspended\r
+                               state, or because is is blocked with no timeout? */\r
                                if( listIS_CONTAINED_WITHIN( NULL, &( pxTCB->xEventListItem ) ) != pdFALSE )\r
                                {\r
                                        xReturn = pdTRUE;\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
                        }\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
 \r
                return xReturn;\r
        } /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */\r
@@ -1184,9 +1416,9 @@ tskTCB * pxNewTCB;
 \r
 #if ( INCLUDE_vTaskSuspend == 1 )\r
 \r
-       void vTaskResume( xTaskHandle xTaskToResume )\r
+       void vTaskResume( TaskHandle_t xTaskToResume )\r
        {\r
-       tskTCB * const pxTCB = ( tskTCB * ) xTaskToResume;\r
+       TCB_t * const pxTCB = ( TCB_t * ) xTaskToResume;\r
 \r
                /* It does not make sense to resume the calling task. */\r
                configASSERT( xTaskToResume );\r
@@ -1197,7 +1429,7 @@ tskTCB * pxNewTCB;
                {\r
                        taskENTER_CRITICAL();\r
                        {\r
-                               if( xTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
+                               if( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
                                {\r
                                        traceTASK_RESUME( pxTCB );\r
 \r
@@ -1214,10 +1446,22 @@ tskTCB * pxNewTCB;
                                                next yield. */\r
                                                taskYIELD_IF_USING_PREEMPTION();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
                        }\r
                        taskEXIT_CRITICAL();\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
 \r
 #endif /* INCLUDE_vTaskSuspend */\r
@@ -1226,11 +1470,11 @@ tskTCB * pxNewTCB;
 \r
 #if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) )\r
 \r
-       portBASE_TYPE xTaskResumeFromISR( xTaskHandle xTaskToResume )\r
+       BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume )\r
        {\r
-       portBASE_TYPE xYieldRequired = pdFALSE;\r
-       tskTCB * const pxTCB = ( tskTCB * ) xTaskToResume;\r
-       unsigned portBASE_TYPE uxSavedInterruptStatus;\r
+       BaseType_t xYieldRequired = pdFALSE;\r
+       TCB_t * const pxTCB = ( TCB_t * ) xTaskToResume;\r
+       UBaseType_t uxSavedInterruptStatus;\r
 \r
                configASSERT( xTaskToResume );\r
 \r
@@ -1254,28 +1498,39 @@ tskTCB * pxNewTCB;
 \r
                uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
-                       if( xTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
+                       if( prvTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
                        {\r
                                traceTASK_RESUME_FROM_ISR( pxTCB );\r
 \r
-                               if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
+                               /* Check the ready lists can be accessed. */\r
+                               if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
                                {\r
+                                       /* Ready lists can be accessed so move the task from the\r
+                                       suspended list to the ready list directly. */\r
                                        if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
                                        {\r
                                                xYieldRequired = pdTRUE;\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
 \r
                                        ( void ) uxListRemove(  &( pxTCB->xGenericListItem ) );\r
                                        prvAddTaskToReadyList( pxTCB );\r
                                }\r
                                else\r
                                {\r
-                                       /* We cannot access the delayed or ready lists, so will hold this\r
-                                       task pending until the scheduler is resumed, at which point a\r
-                                       yield will be performed if necessary. */\r
+                                       /* The delayed or ready lists cannot be accessed so the task\r
+                                       is held in the pending ready list until the scheduler is\r
+                                       unsuspended. */\r
                                        vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) );\r
                                }\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
 \r
@@ -1287,19 +1542,19 @@ tskTCB * pxNewTCB;
 \r
 void vTaskStartScheduler( void )\r
 {\r
-portBASE_TYPE xReturn;\r
+BaseType_t xReturn;\r
 \r
        /* Add the idle task at the lowest priority. */\r
        #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
        {\r
                /* Create the idle task, storing its handle in xIdleTaskHandle so it can\r
                be returned by the xTaskGetIdleTaskHandle() function. */\r
-               xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), &xIdleTaskHandle ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */\r
+               xReturn = xTaskCreate( prvIdleTask, "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), &xIdleTaskHandle ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */\r
        }\r
        #else\r
        {\r
                /* Create the idle task without storing its handle. */\r
-               xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), NULL );  /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */\r
+               xReturn = xTaskCreate( prvIdleTask, "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), NULL );  /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */\r
        }\r
        #endif /* INCLUDE_xTaskGetIdleTaskHandle */\r
 \r
@@ -1309,6 +1564,10 @@ portBASE_TYPE xReturn;
                {\r
                        xReturn = xTimerCreateTimerTask();\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
        #endif /* configUSE_TIMERS */\r
 \r
@@ -1330,7 +1589,7 @@ portBASE_TYPE xReturn;
                #endif /* configUSE_NEWLIB_REENTRANT */\r
 \r
                xSchedulerRunning = pdTRUE;\r
-               xTickCount = ( portTickType ) 0U;\r
+               xTickCount = ( TickType_t ) 0U;\r
 \r
                /* If configGENERATE_RUN_TIME_STATS is defined then the following\r
                macro must be defined to configure the timer/counter used to generate\r
@@ -1373,7 +1632,7 @@ void vTaskEndScheduler( void )
 void vTaskSuspendAll( void )\r
 {\r
        /* A critical section is not required as the variable is of type\r
-       portBASE_TYPE.  Please read Richard Barry's reply in the following link to a\r
+       BaseType_t.  Please read Richard Barry's reply in the following link to a\r
        post in the FreeRTOS support forum before reporting this as a bug! -\r
        http://goo.gl/wu4acr */\r
        ++uxSchedulerSuspended;\r
@@ -1382,9 +1641,9 @@ void vTaskSuspendAll( void )
 \r
 #if ( configUSE_TICKLESS_IDLE != 0 )\r
 \r
-       static portTickType prvGetExpectedIdleTime( void )\r
+       static TickType_t prvGetExpectedIdleTime( void )\r
        {\r
-       portTickType xReturn;\r
+       TickType_t xReturn;\r
 \r
                if( pxCurrentTCB->uxPriority > tskIDLE_PRIORITY )\r
                {\r
@@ -1408,10 +1667,10 @@ void vTaskSuspendAll( void )
 #endif /* configUSE_TICKLESS_IDLE */\r
 /*----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xTaskResumeAll( void )\r
+BaseType_t xTaskResumeAll( void )\r
 {\r
-tskTCB *pxTCB;\r
-portBASE_TYPE xAlreadyYielded = pdFALSE;\r
+TCB_t *pxTCB;\r
+BaseType_t xAlreadyYielded = pdFALSE;\r
 \r
        /* If uxSchedulerSuspended is zero then this function does not match a\r
        previous call to vTaskSuspendAll(). */\r
@@ -1426,42 +1685,54 @@ portBASE_TYPE xAlreadyYielded = pdFALSE;
        {\r
                --uxSchedulerSuspended;\r
 \r
-               if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
+               if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
                {\r
-                       if( uxCurrentNumberOfTasks > ( unsigned portBASE_TYPE ) 0U )\r
+                       if( uxCurrentNumberOfTasks > ( UBaseType_t ) 0U )\r
                        {\r
                                /* Move any readied tasks from the pending list into the\r
                                appropriate ready list. */\r
                                while( listLIST_IS_EMPTY( &xPendingReadyList ) == pdFALSE )\r
                                {\r
-                                       pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList ) );\r
+                                       pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xPendingReadyList ) );\r
                                        ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
                                        ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
                                        prvAddTaskToReadyList( pxTCB );\r
 \r
-                                       /* If we have moved a task that has a priority higher than\r
-                                       the current task then we should yield. */\r
+                                       /* If the moved task has a priority higher than the current\r
+                                       task then a yield must be performed. */\r
                                        if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
                                        {\r
                                                xYieldPending = pdTRUE;\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
 \r
                                /* If any ticks occurred while the scheduler was suspended then\r
-                               they should be processed now.  This ensures the tick count does \r
-                               not     slip, and that any delayed tasks are resumed at the correct \r
+                               they should be processed now.  This ensures the tick count does\r
+                               not     slip, and that any delayed tasks are resumed at the correct\r
                                time. */\r
-                               if( uxPendedTicks > ( unsigned portBASE_TYPE ) 0U )\r
+                               if( uxPendedTicks > ( UBaseType_t ) 0U )\r
                                {\r
-                                       while( uxPendedTicks > ( unsigned portBASE_TYPE ) 0U )\r
+                                       while( uxPendedTicks > ( UBaseType_t ) 0U )\r
                                        {\r
                                                if( xTaskIncrementTick() != pdFALSE )\r
                                                {\r
                                                        xYieldPending = pdTRUE;\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
                                                --uxPendedTicks;\r
                                        }\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
 \r
                                if( xYieldPending == pdTRUE )\r
                                {\r
@@ -1472,8 +1743,16 @@ portBASE_TYPE xAlreadyYielded = pdFALSE;
                                        #endif\r
                                        taskYIELD_IF_USING_PREEMPTION();\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
        taskEXIT_CRITICAL();\r
 \r
@@ -1481,25 +1760,25 @@ portBASE_TYPE xAlreadyYielded = pdFALSE;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-portTickType xTaskGetTickCount( void )\r
+TickType_t xTaskGetTickCount( void )\r
 {\r
-portTickType xTicks;\r
+TickType_t xTicks;\r
 \r
        /* Critical section required if running on a 16 bit processor. */\r
-       taskENTER_CRITICAL();\r
+       portTICK_TYPE_ENTER_CRITICAL();\r
        {\r
                xTicks = xTickCount;\r
        }\r
-       taskEXIT_CRITICAL();\r
+       portTICK_TYPE_EXIT_CRITICAL();\r
 \r
        return xTicks;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-portTickType xTaskGetTickCountFromISR( void )\r
+TickType_t xTaskGetTickCountFromISR( void )\r
 {\r
-portTickType xReturn;\r
-unsigned portBASE_TYPE uxSavedInterruptStatus;\r
+TickType_t xReturn;\r
+UBaseType_t uxSavedInterruptStatus;\r
 \r
        /* RTOS ports that support interrupt nesting have the concept of a maximum\r
        system call (or maximum API call) interrupt priority.  Interrupts that are\r
@@ -1517,27 +1796,29 @@ unsigned portBASE_TYPE uxSavedInterruptStatus;
        link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
        portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
 \r
-       uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
-       xReturn = xTickCount;\r
-       portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+       uxSavedInterruptStatus = portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               xReturn = xTickCount;\r
+       }\r
+       portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
 \r
        return xReturn;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )\r
+UBaseType_t uxTaskGetNumberOfTasks( void )\r
 {\r
        /* A critical section is not required because the variables are of type\r
-       portBASE_TYPE. */\r
+       BaseType_t. */\r
        return uxCurrentNumberOfTasks;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 #if ( INCLUDE_pcTaskGetTaskName == 1 )\r
 \r
-       signed char *pcTaskGetTaskName( xTaskHandle xTaskToQuery )\r
+       char *pcTaskGetTaskName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
        {\r
-       tskTCB *pxTCB;\r
+       TCB_t *pxTCB;\r
 \r
                /* If null is passed in here then the name of the calling task is being queried. */\r
                pxTCB = prvGetTCBFromHandle( xTaskToQuery );\r
@@ -1550,32 +1831,32 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       unsigned portBASE_TYPE uxTaskGetSystemState( xTaskStatusType *pxTaskStatusArray, unsigned portBASE_TYPE uxArraySize, unsigned long *pulTotalRunTime )\r
+       UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime )\r
        {\r
-       unsigned portBASE_TYPE uxTask = 0, uxQueue = configMAX_PRIORITIES;\r
+       UBaseType_t uxTask = 0, uxQueue = configMAX_PRIORITIES;\r
 \r
                vTaskSuspendAll();\r
                {\r
                        /* Is there a space in the array for each task in the system? */\r
                        if( uxArraySize >= uxCurrentNumberOfTasks )\r
                        {\r
-                               /* Fill in an xTaskStatusType structure with information on each\r
+                               /* Fill in an TaskStatus_t structure with information on each\r
                                task in the Ready state. */\r
                                do\r
                                {\r
                                        uxQueue--;\r
                                        uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady );\r
 \r
-                               } while( uxQueue > ( unsigned portBASE_TYPE ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                               } while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
 \r
-                               /* Fill in an xTaskStatusType structure with information on each\r
+                               /* Fill in an TaskStatus_t structure with information on each\r
                                task in the Blocked state. */\r
-                               uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( xList * ) pxDelayedTaskList, eBlocked );\r
-                               uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( xList * ) pxOverflowDelayedTaskList, eBlocked );\r
+                               uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked );\r
+                               uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxOverflowDelayedTaskList, eBlocked );\r
 \r
                                #if( INCLUDE_vTaskDelete == 1 )\r
                                {\r
-                                       /* Fill in an xTaskStatusType structure with information on\r
+                                       /* Fill in an TaskStatus_t structure with information on\r
                                        each task that has been deleted but not yet cleaned up. */\r
                                        uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xTasksWaitingTermination, eDeleted );\r
                                }\r
@@ -1583,7 +1864,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
 \r
                                #if ( INCLUDE_vTaskSuspend == 1 )\r
                                {\r
-                                       /* Fill in an xTaskStatusType structure with information on\r
+                                       /* Fill in an TaskStatus_t structure with information on\r
                                        each task in the Suspended state. */\r
                                        uxTask += prvListTaskWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xSuspendedTaskList, eSuspended );\r
                                }\r
@@ -1609,6 +1890,10 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
                                }\r
                                #endif\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                ( void ) xTaskResumeAll();\r
 \r
@@ -1620,7 +1905,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
 \r
 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
 \r
-       xTaskHandle xTaskGetIdleTaskHandle( void )\r
+       TaskHandle_t xTaskGetIdleTaskHandle( void )\r
        {\r
                /* If xTaskGetIdleTaskHandle() is called before the scheduler has been\r
                started, then xIdleTaskHandle will be NULL. */\r
@@ -1637,7 +1922,7 @@ implementations require configUSE_TICKLESS_IDLE to be set to a value other than
 1. */\r
 #if ( configUSE_TICKLESS_IDLE != 0 )\r
 \r
-       void vTaskStepTick( portTickType xTicksToJump )\r
+       void vTaskStepTick( const TickType_t xTicksToJump )\r
        {\r
                /* Correct the tick count value after a period during which the tick\r
                was suppressed.  Note this does *not* call the tick hook function for\r
@@ -1650,17 +1935,17 @@ implementations require configUSE_TICKLESS_IDLE to be set to a value other than
 #endif /* configUSE_TICKLESS_IDLE */\r
 /*----------------------------------------------------------*/\r
 \r
-portBASE_TYPE xTaskIncrementTick( void )\r
+BaseType_t xTaskIncrementTick( void )\r
 {\r
-tskTCB * pxTCB;\r
-portTickType xItemValue;\r
-portBASE_TYPE xSwitchRequired = pdFALSE;\r
+TCB_t * pxTCB;\r
+TickType_t xItemValue;\r
+BaseType_t xSwitchRequired = pdFALSE;\r
 \r
        /* Called by the portable layer each time a tick interrupt occurs.\r
        Increments the tick then checks to see if the new tick value will cause any\r
        tasks to be unblocked. */\r
        traceTASK_INCREMENT_TICK( xTickCount );\r
-       if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
+       if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
        {\r
                /* Increment the RTOS tick, switching the delayed and overflowed\r
                delayed lists if it wraps to 0. */\r
@@ -1669,17 +1954,21 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                {\r
                        /* Minor optimisation.  The tick count cannot change in this\r
                        block. */\r
-                       const portTickType xConstTickCount = xTickCount;\r
+                       const TickType_t xConstTickCount = xTickCount;\r
 \r
-                       if( xConstTickCount == ( portTickType ) 0U )\r
+                       if( xConstTickCount == ( TickType_t ) 0U )\r
                        {\r
                                taskSWITCH_DELAYED_LISTS();\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
 \r
                        /* See if this tick has made a timeout expire.  Tasks are stored in\r
                        the     queue in the order of their wake time - meaning once one task\r
                        has been found whose block time has not expired there is no need to\r
-                       look any further        down the list. */\r
+                       look any further down the list. */\r
                        if( xConstTickCount >= xNextTaskUnblockTime )\r
                        {\r
                                for( ;; )\r
@@ -1700,7 +1989,7 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                                                item at the head of the delayed list.  This is the time\r
                                                at which the task at the head of the delayed list must\r
                                                be removed from the Blocked state. */\r
-                                               pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
+                                               pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
                                                xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) );\r
 \r
                                                if( xConstTickCount < xItemValue )\r
@@ -1713,6 +2002,10 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                                                        xNextTaskUnblockTime = xItemValue;\r
                                                        break;\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
 \r
                                                /* It is time to remove the item from the Blocked state. */\r
                                                ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
@@ -1723,6 +2016,10 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                                                {\r
                                                        ( void ) uxListRemove( &( pxTCB->xEventListItem ) );\r
                                                }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
 \r
                                                /* Place the unblocked task into the appropriate ready\r
                                                list. */\r
@@ -1740,6 +2037,10 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                                                        {\r
                                                                xSwitchRequired = pdTRUE;\r
                                                        }\r
+                                                       else\r
+                                                       {\r
+                                                               mtCOVERAGE_TEST_MARKER();\r
+                                                       }\r
                                                }\r
                                                #endif /* configUSE_PREEMPTION */\r
                                        }\r
@@ -1752,10 +2053,14 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                writer has not explicitly turned time slicing off. */\r
                #if ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) )\r
                {\r
-                       if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( unsigned portBASE_TYPE ) 1 )\r
+                       if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( UBaseType_t ) 1 )\r
                        {\r
                                xSwitchRequired = pdTRUE;\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */\r
 \r
@@ -1763,10 +2068,14 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                {\r
                        /* Guard against the tick hook being called when the pended tick\r
                        count is being unwound (when the scheduler is being unlocked). */\r
-                       if( uxPendedTicks == ( unsigned portBASE_TYPE ) 0U )\r
+                       if( uxPendedTicks == ( UBaseType_t ) 0U )\r
                        {\r
                                vApplicationTickHook();\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                #endif /* configUSE_TICK_HOOK */\r
        }\r
@@ -1789,6 +2098,10 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
                {\r
                        xSwitchRequired = pdTRUE;\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
        #endif /* configUSE_PREEMPTION */\r
 \r
@@ -1798,19 +2111,19 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
 \r
 #if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
 \r
-       void vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxHookFunction )\r
+       void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction )\r
        {\r
-       tskTCB *xTCB;\r
+       TCB_t *xTCB;\r
 \r
                /* If xTask is NULL then it is the task hook of the calling task that is\r
                getting set. */\r
                if( xTask == NULL )\r
                {\r
-                       xTCB = ( tskTCB * ) pxCurrentTCB;\r
+                       xTCB = ( TCB_t * ) pxCurrentTCB;\r
                }\r
                else\r
                {\r
-                       xTCB = ( tskTCB * ) xTask;\r
+                       xTCB = ( TCB_t * ) xTask;\r
                }\r
 \r
                /* Save the hook function in the TCB.  A critical section is required as\r
@@ -1825,25 +2138,27 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
 \r
 #if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
 \r
-       pdTASK_HOOK_CODE xTaskGetApplicationTaskTag( xTaskHandle xTask )\r
+       TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask )\r
        {\r
-       tskTCB *xTCB;\r
-       pdTASK_HOOK_CODE xReturn;\r
+       TCB_t *xTCB;\r
+       TaskHookFunction_t xReturn;\r
 \r
                /* If xTask is NULL then we are setting our own task hook. */\r
                if( xTask == NULL )\r
                {\r
-                       xTCB = ( tskTCB * ) pxCurrentTCB;\r
+                       xTCB = ( TCB_t * ) pxCurrentTCB;\r
                }\r
                else\r
                {\r
-                       xTCB = ( tskTCB * ) xTask;\r
+                       xTCB = ( TCB_t * ) xTask;\r
                }\r
 \r
                /* Save the hook function in the TCB.  A critical section is required as\r
                the value can be accessed from an interrupt. */\r
                taskENTER_CRITICAL();\r
+               {\r
                        xReturn = xTCB->pxTaskTag;\r
+               }\r
                taskEXIT_CRITICAL();\r
 \r
                return xReturn;\r
@@ -1854,19 +2169,19 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
 \r
 #if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
 \r
-       portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter )\r
+       BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter )\r
        {\r
-       tskTCB *xTCB;\r
-       portBASE_TYPE xReturn;\r
+       TCB_t *xTCB;\r
+       BaseType_t xReturn;\r
 \r
                /* If xTask is NULL then we are calling our own task hook. */\r
                if( xTask == NULL )\r
                {\r
-                       xTCB = ( tskTCB * ) pxCurrentTCB;\r
+                       xTCB = ( TCB_t * ) pxCurrentTCB;\r
                }\r
                else\r
                {\r
-                       xTCB = ( tskTCB * ) xTask;\r
+                       xTCB = ( TCB_t * ) xTask;\r
                }\r
 \r
                if( xTCB->pxTaskTag != NULL )\r
@@ -1886,7 +2201,7 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
 \r
 void vTaskSwitchContext( void )\r
 {\r
-       if( uxSchedulerSuspended != ( unsigned portBASE_TYPE ) pdFALSE )\r
+       if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE )\r
        {\r
                /* The scheduler is currently suspended - do not allow a context\r
                switch. */\r
@@ -1916,15 +2231,21 @@ void vTaskSwitchContext( void )
                                {\r
                                        pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                                ulTaskSwitchedInTime = ulTotalRunTime;\r
                }\r
                #endif /* configGENERATE_RUN_TIME_STATS */\r
 \r
+               /* Check for stack overflow, if configured. */\r
                taskFIRST_CHECK_FOR_STACK_OVERFLOW();\r
                taskSECOND_CHECK_FOR_STACK_OVERFLOW();\r
 \r
+               /* Select a new task to run using either the generic C or port\r
+               optimised asm code. */\r
                taskSELECT_HIGHEST_PRIORITY_TASK();\r
-\r
                traceTASK_SWITCHED_IN();\r
 \r
                #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
@@ -1938,43 +2259,49 @@ void vTaskSwitchContext( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vTaskPlaceOnEventList( xList * const pxEventList, const portTickType xTicksToWait )\r
+void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait )\r
 {\r
-portTickType xTimeToWake;\r
+TickType_t xTimeToWake;\r
 \r
        configASSERT( pxEventList );\r
 \r
-       /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE\r
-       SCHEDULER SUSPENDED. */\r
+       /* THIS FUNCTION MUST BE CALLED WITH EITHER INTERRUPTS DISABLED OR THE\r
+       SCHEDULER SUSPENDED AND THE QUEUE BEING ACCESSED LOCKED. */\r
 \r
        /* Place the event list item of the TCB in the appropriate event list.\r
        This is placed in the list in priority order so the highest priority task\r
-       is the first to be woken by the event. */\r
+       is the first to be woken by the event.  The queue that contains the event\r
+       list is locked, preventing simultaneous access from interrupts. */\r
        vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
 \r
-       /* We must remove ourselves from the ready list before adding ourselves\r
-       to the blocked list as the same list item is used for both lists.  We have\r
-       exclusive access to the ready lists as the scheduler is locked. */\r
-       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+       /* The task must be removed from from the ready list before it is added to\r
+       the blocked list as the same list item is used for both lists.  Exclusive\r
+       access to the ready lists guaranteed because the scheduler is locked. */\r
+       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
        {\r
                /* The current task must be in a ready list, so there is no need to\r
                check, and the port reset macro can be called directly. */\r
                portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
        }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
 \r
        #if ( INCLUDE_vTaskSuspend == 1 )\r
        {\r
                if( xTicksToWait == portMAX_DELAY )\r
                {\r
-                       /* Add ourselves to the suspended task list instead of a delayed task\r
-                       list to ensure we are not woken by a timing event.  We will block\r
-                       indefinitely. */\r
+                       /* Add the task to the suspended task list instead of a delayed task\r
+                       list to ensure the task is not woken by a timing event.  It will\r
+                       block indefinitely. */\r
                        vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
                }\r
                else\r
                {\r
-                       /* Calculate the time at which the task should be woken if the event does\r
-                       not occur.  This may overflow but this doesn't matter. */\r
+                       /* Calculate the time at which the task should be woken if the event\r
+                       does not occur.  This may overflow but this doesn't matter, the\r
+                       scheduler will handle it. */\r
                        xTimeToWake = xTickCount + xTicksToWait;\r
                        prvAddCurrentTaskToDelayedList( xTimeToWake );\r
                }\r
@@ -1982,7 +2309,8 @@ portTickType xTimeToWake;
        #else /* INCLUDE_vTaskSuspend */\r
        {\r
                        /* Calculate the time at which the task should be woken if the event does\r
-                       not occur.  This may overflow but this doesn't matter. */\r
+                       not occur.  This may overflow but this doesn't matter, the scheduler\r
+                       will handle it. */\r
                        xTimeToWake = xTickCount + xTicksToWait;\r
                        prvAddCurrentTaskToDelayedList( xTimeToWake );\r
        }\r
@@ -1990,31 +2318,41 @@ portTickType xTimeToWake;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vTaskPlaceOnUnorderedEventList( xList * pxEventList, portTickType xItemValue, const portTickType xTicksToWait )\r
+void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait )\r
 {\r
-portTickType xTimeToWake;\r
+TickType_t xTimeToWake;\r
 \r
        configASSERT( pxEventList );\r
 \r
-       /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE\r
-       SCHEDULER SUSPENDED. */\r
+       /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED.  It is used by\r
+       the event groups implementation. */\r
+       configASSERT( uxSchedulerSuspended != 0 );\r
 \r
-       /* Store the item value in the event list item. */\r
+       /* Store the item value in the event list item.  It is safe to access the\r
+       event list item here as interrupts won't access the event list item of a\r
+       task that is not in the Blocked state. */\r
        listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );\r
 \r
        /* Place the event list item of the TCB at the end of the appropriate event\r
-       list. */\r
+       list.  It is safe to access the event list here because it is part of an\r
+       event group implementation - and interrupts don't access event groups\r
+       directly (instead they access them indirectly by pending function calls to\r
+       the task level). */\r
        vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
 \r
        /* The task must be removed from the ready list before it is added to the\r
        blocked list.  Exclusive access can be assured to the ready list as the\r
        scheduler is locked. */\r
-       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
        {\r
                /* The current task must be in a ready list, so there is no need to\r
                check, and the port reset macro can be called directly. */\r
                portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
        }\r
+       else\r
+       {\r
+               mtCOVERAGE_TEST_MARKER();\r
+       }\r
 \r
        #if ( INCLUDE_vTaskSuspend == 1 )\r
        {\r
@@ -2027,8 +2365,9 @@ portTickType xTimeToWake;
                }\r
                else\r
                {\r
-                       /* Calculate the time at which the task should be woken if the event does\r
-                       not occur.  This may overflow but this doesn't matter. */\r
+                       /* Calculate the time at which the task should be woken if the event\r
+                       does not occur.  This may overflow but this doesn't matter, the\r
+                       kernel will manage it correctly. */\r
                        xTimeToWake = xTickCount + xTicksToWait;\r
                        prvAddCurrentTaskToDelayedList( xTimeToWake );\r
                }\r
@@ -2036,7 +2375,8 @@ portTickType xTimeToWake;
        #else /* INCLUDE_vTaskSuspend */\r
        {\r
                        /* Calculate the time at which the task should be woken if the event does\r
-                       not occur.  This may overflow but this doesn't matter. */\r
+                       not occur.  This may overflow but this doesn't matter, the kernel\r
+                       will manage it correctly. */\r
                        xTimeToWake = xTickCount + xTicksToWait;\r
                        prvAddCurrentTaskToDelayedList( xTimeToWake );\r
        }\r
@@ -2046,16 +2386,16 @@ portTickType xTimeToWake;
 \r
 #if configUSE_TIMERS == 1\r
 \r
-       void vTaskPlaceOnEventListRestricted( xList * const pxEventList, portTickType xTicksToWait )\r
+       void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait )\r
        {\r
-       portTickType xTimeToWake;\r
+       TickType_t xTimeToWake;\r
 \r
                configASSERT( pxEventList );\r
 \r
                /* This function should not be called by application code hence the\r
                'Restricted' in its name.  It is not part of the public API.  It is\r
                designed for use by kernel code, and has special calling requirements -\r
-               it should be called from a critical section. */\r
+               it should be called with the scheduler suspended. */\r
 \r
 \r
                /* Place the event list item of the TCB in the appropriate event list.\r
@@ -2066,13 +2406,18 @@ portTickType xTimeToWake;
 \r
                /* We must remove this task from the ready list before adding it to the\r
                blocked list as the same list item is used for both lists.  This\r
-               function is called form a critical section. */\r
-               if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+               function is called with the scheduler locked so interrupts will not\r
+               access the lists at the same time. */\r
+               if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
                {\r
                        /* The current task must be in a ready list, so there is no need to\r
                        check, and the port reset macro can be called directly. */\r
                        portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
 \r
                /* Calculate the time at which the task should be woken if the event does\r
                not occur.  This may overflow but this doesn't matter. */\r
@@ -2085,46 +2430,45 @@ portTickType xTimeToWake;
 #endif /* configUSE_TIMERS */\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xTaskRemoveFromEventList( const xList * const pxEventList )\r
+BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList )\r
 {\r
-tskTCB *pxUnblockedTCB;\r
-portBASE_TYPE xReturn;\r
+TCB_t *pxUnblockedTCB;\r
+BaseType_t xReturn;\r
 \r
-       /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE\r
-       SCHEDULER SUSPENDED.  It can also be called from within an ISR. */\r
+       /* THIS FUNCTION MUST BE CALLED FROM A CRITICAL SECTION.  It can also be\r
+       called from a critical section within an ISR. */\r
 \r
-       /* The event list is sorted in priority order, so we can remove the\r
-       first in the list, remove the TCB from the delayed list, and add\r
-       it to the ready list.\r
+       /* The event list is sorted in priority order, so the first in the list can\r
+       be removed as it is known to be the highest priority.  Remove the TCB from\r
+       the delayed list, and add it to the ready list.\r
 \r
        If an event is for a queue that is locked then this function will never\r
        get called - the lock count on the queue will get modified instead.  This\r
-       means we can always expect exclusive access to the event list here.\r
+       means exclusive access to the event list is guaranteed here.\r
 \r
        This function assumes that a check has already been made to ensure that\r
        pxEventList is not empty. */\r
-       pxUnblockedTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );\r
+       pxUnblockedTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );\r
        configASSERT( pxUnblockedTCB );\r
        ( void ) uxListRemove( &( pxUnblockedTCB->xEventListItem ) );\r
 \r
-       if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
+       if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
        {\r
                ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
                prvAddTaskToReadyList( pxUnblockedTCB );\r
        }\r
        else\r
        {\r
-               /* We cannot access the delayed or ready lists, so will hold this\r
-               task pending until the scheduler is resumed. */\r
+               /* The delayed and ready lists cannot be accessed, so hold this task\r
+               pending until the scheduler is resumed. */\r
                vListInsertEnd( &( xPendingReadyList ), &( pxUnblockedTCB->xEventListItem ) );\r
        }\r
 \r
-       if( pxUnblockedTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
+       if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority )\r
        {\r
-               /* Return true if the task removed from the event list has\r
-               a higher priority than the calling task.  This allows\r
-               the calling task to know if it should force a context\r
-               switch now. */\r
+               /* Return true if the task removed from the event list has a higher\r
+               priority than the calling task.  This allows the calling task to know if\r
+               it should force a context switch now. */\r
                xReturn = pdTRUE;\r
 \r
                /* Mark that a yield is pending in case the user is not using the\r
@@ -2136,40 +2480,49 @@ portBASE_TYPE xReturn;
                xReturn = pdFALSE;\r
        }\r
 \r
+       #if( configUSE_TICKLESS_IDLE == 1 )\r
+       {\r
+               /* If a task is blocked on a kernel object then xNextTaskUnblockTime\r
+               might be set to the blocked task's time out time.  If the task is\r
+               unblocked for a reason other than a timeout xNextTaskUnblockTime is\r
+               normally left unchanged, because it is automatically get reset to a new\r
+               value when the tick count equals xNextTaskUnblockTime.  However if\r
+               tickless idling is used it might be more important to enter sleep mode\r
+               at the earliest possible time - so reset xNextTaskUnblockTime here to\r
+               ensure it is updated at the earliest possible time. */\r
+               prvResetNextTaskUnblockTime();\r
+       }\r
+       #endif\r
+\r
        return xReturn;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xTaskRemoveFromUnorderedEventList( xListItem * pxEventListItem, portTickType xItemValue )\r
+BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue )\r
 {\r
-tskTCB *pxUnblockedTCB;\r
-portBASE_TYPE xReturn;\r
+TCB_t *pxUnblockedTCB;\r
+BaseType_t xReturn;\r
 \r
-       /* THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED OR THE\r
-       SCHEDULER SUSPENDED.  It can also be called from within an ISR. */\r
+       /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED.  It is used by\r
+       the event flags implementation. */\r
+       configASSERT( uxSchedulerSuspended != pdFALSE );\r
 \r
        /* Store the new item value in the event list. */\r
        listSET_LIST_ITEM_VALUE( pxEventListItem, xItemValue | taskEVENT_LIST_ITEM_VALUE_IN_USE );\r
 \r
-       /* Remove the TCB from the delayed list, and add it to the ready list. */\r
-\r
-       pxUnblockedTCB = ( tskTCB * ) listGET_LIST_ITEM_OWNER( pxEventListItem );\r
+       /* Remove the event list form the event flag.  Interrupts do not access\r
+       event flags. */\r
+       pxUnblockedTCB = ( TCB_t * ) listGET_LIST_ITEM_OWNER( pxEventListItem );\r
        configASSERT( pxUnblockedTCB );\r
        ( void ) uxListRemove( pxEventListItem );\r
 \r
-       if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
-       {\r
-               ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
-               prvAddTaskToReadyList( pxUnblockedTCB );\r
-       }\r
-       else\r
-       {\r
-               /* Cannot access the delayed or ready lists, so will hold this task\r
-               pending until the scheduler is resumed. */\r
-               vListInsertEnd( &( xPendingReadyList ), pxEventListItem );\r
-       }\r
+       /* Remove the task from the delayed list and add it to the ready list.  The\r
+       scheduler is suspended so interrupts will not be accessing the ready\r
+       lists. */\r
+       ( void ) uxListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
+       prvAddTaskToReadyList( pxUnblockedTCB );\r
 \r
-       if( pxUnblockedTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
+       if( pxUnblockedTCB->uxPriority > pxCurrentTCB->uxPriority )\r
        {\r
                /* Return true if the task removed from the event list has\r
                a higher priority than the calling task.  This allows\r
@@ -2190,7 +2543,7 @@ portBASE_TYPE xReturn;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut )\r
+void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )\r
 {\r
        configASSERT( pxTimeOut );\r
        pxTimeOut->xOverflowCount = xNumOfOverflows;\r
@@ -2198,9 +2551,9 @@ void vTaskSetTimeOutState( xTimeOutType * const pxTimeOut )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType * const pxTicksToWait )\r
+BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait )\r
 {\r
-portBASE_TYPE xReturn;\r
+BaseType_t xReturn;\r
 \r
        configASSERT( pxTimeOut );\r
        configASSERT( pxTicksToWait );\r
@@ -2208,7 +2561,7 @@ portBASE_TYPE xReturn;
        taskENTER_CRITICAL();\r
        {\r
                /* Minor optimisation.  The tick count cannot change in this block. */\r
-               const portTickType xConstTickCount = xTickCount;\r
+               const TickType_t xConstTickCount = xTickCount;\r
 \r
                #if ( INCLUDE_vTaskSuspend == 1 )\r
                        /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is\r
@@ -2255,14 +2608,14 @@ void vTaskMissedYield( void )
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask )\r
+       UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask )\r
        {\r
-       unsigned portBASE_TYPE uxReturn;\r
-       tskTCB *pxTCB;\r
+       UBaseType_t uxReturn;\r
+       TCB_t *pxTCB;\r
 \r
                if( xTask != NULL )\r
                {\r
-                       pxTCB = ( tskTCB * ) xTask;\r
+                       pxTCB = ( TCB_t * ) xTask;\r
                        uxReturn = pxTCB->uxTaskNumber;\r
                }\r
                else\r
@@ -2278,13 +2631,13 @@ void vTaskMissedYield( void )
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       void vTaskSetTaskNumber( xTaskHandle xTask, unsigned portBASE_TYPE uxHandle )\r
+       void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle )\r
        {\r
-       tskTCB *pxTCB;\r
+       TCB_t *pxTCB;\r
 \r
                if( xTask != NULL )\r
                {\r
-                       pxTCB = ( tskTCB * ) xTask;\r
+                       pxTCB = ( TCB_t * ) xTask;\r
                        pxTCB->uxTaskNumber = uxHandle;\r
                }\r
        }\r
@@ -2333,10 +2686,14 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
                        the list, and an occasional incorrect value will not matter.  If\r
                        the ready list at the idle priority contains more than one task\r
                        then a task other than the idle task is ready to execute. */\r
-                       if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( unsigned portBASE_TYPE ) 1 )\r
+                       if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ tskIDLE_PRIORITY ] ) ) > ( UBaseType_t ) 1 )\r
                        {\r
                                taskYIELD();\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                #endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configIDLE_SHOULD_YIELD == 1 ) ) */\r
 \r
@@ -2359,7 +2716,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
                configUSE_TICKLESS_IDLE to be set to a value other than 1. */\r
                #if ( configUSE_TICKLESS_IDLE != 0 )\r
                {\r
-               portTickType xExpectedIdleTime;\r
+               TickType_t xExpectedIdleTime;\r
 \r
                        /* It is not desirable to suspend then resume the scheduler on\r
                        each iteration of the idle task.  Therefore, a preliminary\r
@@ -2384,9 +2741,17 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
                                                portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime );\r
                                                traceLOW_POWER_IDLE_END();\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
                                }\r
                                ( void ) xTaskResumeAll();\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
                #endif /* configUSE_TICKLESS_IDLE */\r
        }\r
@@ -2414,7 +2779,7 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
                        #if configUSE_TIMERS == 0\r
                        {\r
                                /* The idle task exists in addition to the application tasks. */\r
-                               const unsigned portBASE_TYPE uxNonApplicationTasks = 1;\r
+                               const UBaseType_t uxNonApplicationTasks = 1;\r
 \r
                                /* If timers are not being used and all the tasks are in the\r
                                suspended list (which might mean they have an infinite block\r
@@ -2424,6 +2789,10 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
                                {\r
                                        eReturn = eNoTasksWaitingTimeout;\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
                        #endif /* configUSE_TIMERS */\r
                }\r
@@ -2433,12 +2802,12 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
 #endif /* configUSE_TICKLESS_IDLE */\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvInitialiseTCBVariables( tskTCB *pxTCB, const signed char * const pcName, unsigned portBASE_TYPE uxPriority, const xMemoryRegion * const xRegions, unsigned short usStackDepth )\r
+static void prvInitialiseTCBVariables( TCB_t * const pxTCB, const char * const pcName, UBaseType_t uxPriority, const MemoryRegion_t * const xRegions, const uint16_t usStackDepth ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 {\r
-unsigned portBASE_TYPE x;\r
+UBaseType_t x;\r
 \r
        /* Store the task name in the TCB. */\r
-       for( x = ( unsigned portBASE_TYPE ) 0; x < ( unsigned portBASE_TYPE ) configMAX_TASK_NAME_LEN; x++ )\r
+       for( x = ( UBaseType_t ) 0; x < ( UBaseType_t ) configMAX_TASK_NAME_LEN; x++ )\r
        {\r
                pxTCB->pcTaskName[ x ] = pcName[ x ];\r
 \r
@@ -2449,40 +2818,49 @@ unsigned portBASE_TYPE x;
                {\r
                        break;\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
 \r
        /* Ensure the name string is terminated in the case that the string length\r
        was greater or equal to configMAX_TASK_NAME_LEN. */\r
-       pxTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = ( signed char ) '\0';\r
+       pxTCB->pcTaskName[ configMAX_TASK_NAME_LEN - 1 ] = '\0';\r
 \r
        /* This is used as an array index so must ensure it's not too large.  First\r
        remove the privilege bit if one is present. */\r
-       if( uxPriority >= ( unsigned portBASE_TYPE ) configMAX_PRIORITIES )\r
+       if( uxPriority >= ( UBaseType_t ) configMAX_PRIORITIES )\r
+       {\r
+               uxPriority = ( UBaseType_t ) configMAX_PRIORITIES - ( UBaseType_t ) 1U;\r
+       }\r
+       else\r
        {\r
-               uxPriority = ( unsigned portBASE_TYPE ) configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U;\r
+               mtCOVERAGE_TEST_MARKER();\r
        }\r
 \r
        pxTCB->uxPriority = uxPriority;\r
        #if ( configUSE_MUTEXES == 1 )\r
        {\r
                pxTCB->uxBasePriority = uxPriority;\r
+               pxTCB->uxMutexesHeld = 0;\r
        }\r
        #endif /* configUSE_MUTEXES */\r
 \r
        vListInitialiseItem( &( pxTCB->xGenericListItem ) );\r
        vListInitialiseItem( &( pxTCB->xEventListItem ) );\r
 \r
-       /* Set the pxTCB as a link back from the xListItem.  This is so we can get\r
+       /* Set the pxTCB as a link back from the ListItem_t.  This is so we can get\r
        back to the containing TCB from a generic item in a list. */\r
        listSET_LIST_ITEM_OWNER( &( pxTCB->xGenericListItem ), pxTCB );\r
 \r
        /* Event lists are always in priority order. */\r
-       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( portTickType ) configMAX_PRIORITIES - ( portTickType ) uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
        listSET_LIST_ITEM_OWNER( &( pxTCB->xEventListItem ), pxTCB );\r
 \r
        #if ( portCRITICAL_NESTING_IN_TCB == 1 )\r
        {\r
-               pxTCB->uxCriticalNesting = ( unsigned portBASE_TYPE ) 0U;\r
+               pxTCB->uxCriticalNesting = ( UBaseType_t ) 0U;\r
        }\r
        #endif /* portCRITICAL_NESTING_IN_TCB */\r
 \r
@@ -2509,6 +2887,22 @@ unsigned portBASE_TYPE x;
        }\r
        #endif /* portUSING_MPU_WRAPPERS */\r
 \r
+       #if( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )\r
+       {\r
+               for( x = 0; x < ( UBaseType_t ) configNUM_THREAD_LOCAL_STORAGE_POINTERS; x++ )\r
+               {\r
+                       pxTCB->pvThreadLocalStoragePointers[ x ] = NULL;\r
+               }\r
+       }\r
+       #endif\r
+\r
+       #if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
+       {\r
+               pxTCB->ulNotifiedValue = 0;\r
+               pxTCB->eNotifyState = eNotWaitingNotification;\r
+       }\r
+       #endif\r
+\r
        #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
        {\r
                /* Initialise this task's Newlib reent structure. */\r
@@ -2518,11 +2912,50 @@ unsigned portBASE_TYPE x;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )\r
+\r
+       void vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue )\r
+       {\r
+       TCB_t *pxTCB;\r
+\r
+               if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS )\r
+               {\r
+                       pxTCB = prvGetTCBFromHandle( xTaskToSet );\r
+                       pxTCB->pvThreadLocalStoragePointers[ xIndex ] = pvValue;\r
+               }\r
+       }\r
+\r
+#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )\r
+\r
+       void *pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex )\r
+       {\r
+       void *pvReturn = NULL;\r
+       TCB_t *pxTCB;\r
+\r
+               if( xIndex < configNUM_THREAD_LOCAL_STORAGE_POINTERS )\r
+               {\r
+                       pxTCB = prvGetTCBFromHandle( xTaskToQuery );\r
+                       pvReturn = pxTCB->pvThreadLocalStoragePointers[ xIndex ];\r
+               }\r
+               else\r
+               {\r
+                       pvReturn = NULL;\r
+               }\r
+\r
+               return pvReturn;\r
+       }\r
+\r
+#endif /* configNUM_THREAD_LOCAL_STORAGE_POINTERS */\r
+/*-----------------------------------------------------------*/\r
+\r
 #if ( portUSING_MPU_WRAPPERS == 1 )\r
 \r
-       void vTaskAllocateMPURegions( xTaskHandle xTaskToModify, const xMemoryRegion * const xRegions )\r
+       void vTaskAllocateMPURegions( TaskHandle_t xTaskToModify, const MemoryRegion_t * const xRegions )\r
        {\r
-       tskTCB *pxTCB;\r
+       TCB_t *pxTCB;\r
 \r
                /* If null is passed in here then we are deleting ourselves. */\r
                pxTCB = prvGetTCBFromHandle( xTaskToModify );\r
@@ -2535,9 +2968,9 @@ unsigned portBASE_TYPE x;
 \r
 static void prvInitialiseTaskLists( void )\r
 {\r
-unsigned portBASE_TYPE uxPriority;\r
+UBaseType_t uxPriority;\r
 \r
-       for( uxPriority = ( unsigned portBASE_TYPE ) 0U; uxPriority < ( unsigned portBASE_TYPE ) configMAX_PRIORITIES; uxPriority++ )\r
+       for( uxPriority = ( UBaseType_t ) 0U; uxPriority < ( UBaseType_t ) configMAX_PRIORITIES; uxPriority++ )\r
        {\r
                vListInitialise( &( pxReadyTasksLists[ uxPriority ] ) );\r
        }\r
@@ -2569,23 +3002,25 @@ static void prvCheckTasksWaitingTermination( void )
 {\r
        #if ( INCLUDE_vTaskDelete == 1 )\r
        {\r
-               portBASE_TYPE xListIsEmpty;\r
+               BaseType_t xListIsEmpty;\r
 \r
                /* ucTasksDeleted is used to prevent vTaskSuspendAll() being called\r
                too often in the idle task. */\r
-               while( uxTasksDeleted > ( unsigned portBASE_TYPE ) 0U )\r
+               while( uxTasksDeleted > ( UBaseType_t ) 0U )\r
                {\r
                        vTaskSuspendAll();\r
+                       {\r
                                xListIsEmpty = listLIST_IS_EMPTY( &xTasksWaitingTermination );\r
+                       }\r
                        ( void ) xTaskResumeAll();\r
 \r
                        if( xListIsEmpty == pdFALSE )\r
                        {\r
-                               tskTCB *pxTCB;\r
+                               TCB_t *pxTCB;\r
 \r
                                taskENTER_CRITICAL();\r
                                {\r
-                                       pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );\r
+                                       pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );\r
                                        ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
                                        --uxCurrentNumberOfTasks;\r
                                        --uxTasksDeleted;\r
@@ -2594,13 +3029,17 @@ static void prvCheckTasksWaitingTermination( void )
 \r
                                prvDeleteTCB( pxTCB );\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
                }\r
        }\r
        #endif /* vTaskDelete */\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvAddCurrentTaskToDelayedList( portTickType xTimeToWake )\r
+static void prvAddCurrentTaskToDelayedList( const TickType_t xTimeToWake )\r
 {\r
        /* The list item will be inserted in wake time order. */\r
        listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );\r
@@ -2622,42 +3061,84 @@ static void prvAddCurrentTaskToDelayedList( portTickType xTimeToWake )
                {\r
                        xNextTaskUnblockTime = xTimeToWake;\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static tskTCB *prvAllocateTCBAndStack( unsigned short usStackDepth, portSTACK_TYPE *puxStackBuffer )\r
+static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer )\r
 {\r
-tskTCB *pxNewTCB;\r
-\r
-       /* Allocate space for the TCB.  Where the memory comes from depends on\r
-       the implementation of the port malloc function. */\r
-       pxNewTCB = ( tskTCB * ) pvPortMalloc( sizeof( tskTCB ) );\r
+TCB_t *pxNewTCB;\r
 \r
-       if( pxNewTCB != NULL )\r
+       /* If the stack grows down then allocate the stack then the TCB so the stack\r
+       does not grow into the TCB.  Likewise if the stack grows up then allocate\r
+       the TCB then the stack. */\r
+       #if( portSTACK_GROWTH > 0 )\r
        {\r
-               /* Allocate space for the stack used by the task being created.\r
-               The base of the stack memory stored in the TCB so the task can\r
-               be deleted later if required. */\r
-               pxNewTCB->pxStack = ( portSTACK_TYPE * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( portSTACK_TYPE ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+               /* Allocate space for the TCB.  Where the memory comes from depends on\r
+               the implementation of the port malloc function. */\r
+               pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) );\r
 \r
-               if( pxNewTCB->pxStack == NULL )\r
+               if( pxNewTCB != NULL )\r
                {\r
-                       /* Could not allocate the stack.  Delete the allocated TCB. */\r
-                       vPortFree( pxNewTCB );\r
-                       pxNewTCB = NULL;\r
+                       /* Allocate space for the stack used by the task being created.\r
+                       The base of the stack memory stored in the TCB so the task can\r
+                       be deleted later if required. */\r
+                       pxNewTCB->pxStack = ( StackType_t * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+\r
+                       if( pxNewTCB->pxStack == NULL )\r
+                       {\r
+                               /* Could not allocate the stack.  Delete the allocated TCB. */\r
+                               vPortFree( pxNewTCB );\r
+                               pxNewTCB = NULL;\r
+                       }\r
                }\r
-               else\r
+       }\r
+       #else /* portSTACK_GROWTH */\r
+       {\r
+       StackType_t *pxStack;\r
+\r
+               /* Allocate space for the stack used by the task being created. */\r
+               pxStack = ( StackType_t * ) pvPortMallocAligned( ( ( ( size_t ) usStackDepth ) * sizeof( StackType_t ) ), puxStackBuffer ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+\r
+               if( pxStack != NULL )\r
                {\r
-                       /* Avoid dependency on memset() if it is not required. */\r
-                       #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
+                       /* Allocate space for the TCB.  Where the memory comes from depends\r
+                       on the implementation of the port malloc function. */\r
+                       pxNewTCB = ( TCB_t * ) pvPortMalloc( sizeof( TCB_t ) );\r
+\r
+                       if( pxNewTCB != NULL )\r
+                       {\r
+                               /* Store the stack location in the TCB. */\r
+                               pxNewTCB->pxStack = pxStack;\r
+                       }\r
+                       else\r
                        {\r
-                               /* Just to help debugging. */\r
-                               ( void ) memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) usStackDepth * sizeof( portSTACK_TYPE ) );\r
+                               /* The stack cannot be used as the TCB was not created.  Free it\r
+                               again. */\r
+                               vPortFree( pxStack );\r
                        }\r
-                       #endif /* ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) ) */\r
+               }\r
+               else\r
+               {\r
+                       pxNewTCB = NULL;\r
                }\r
        }\r
+       #endif /* portSTACK_GROWTH */\r
+\r
+       if( pxNewTCB != NULL )\r
+       {\r
+               /* Avoid dependency on memset() if it is not required. */\r
+               #if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
+               {\r
+                       /* Just to help debugging. */\r
+                       ( void ) memset( pxNewTCB->pxStack, ( int ) tskSTACK_FILL_BYTE, ( size_t ) usStackDepth * sizeof( StackType_t ) );\r
+               }\r
+               #endif /* ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) || ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) ) */\r
+       }\r
 \r
        return pxNewTCB;\r
 }\r
@@ -2665,29 +3146,44 @@ tskTCB *pxNewTCB;
 \r
 #if ( configUSE_TRACE_FACILITY == 1 )\r
 \r
-       static unsigned portBASE_TYPE prvListTaskWithinSingleList( xTaskStatusType *pxTaskStatusArray, xList *pxList, eTaskState eState )\r
+       static UBaseType_t prvListTaskWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState )\r
        {\r
-       volatile tskTCB *pxNextTCB, *pxFirstTCB;\r
-       unsigned portBASE_TYPE uxTask = 0;\r
+       volatile TCB_t *pxNextTCB, *pxFirstTCB;\r
+       UBaseType_t uxTask = 0;\r
 \r
-               if( listCURRENT_LIST_LENGTH( pxList ) > ( unsigned portBASE_TYPE ) 0 )\r
+               if( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 )\r
                {\r
                        listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );\r
 \r
-                       /* Populate an xTaskStatusType structure within the\r
+                       /* Populate an TaskStatus_t structure within the\r
                        pxTaskStatusArray array for each task that is referenced from\r
-                       pxList.  See the definition of xTaskStatusType in task.h for the\r
-                       meaning of each xTaskStatusType structure member. */\r
+                       pxList.  See the definition of TaskStatus_t in task.h for the\r
+                       meaning of each TaskStatus_t structure member. */\r
                        do\r
                        {\r
                                listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );\r
 \r
-                               pxTaskStatusArray[ uxTask ].xHandle = ( xTaskHandle ) pxNextTCB;\r
-                               pxTaskStatusArray[ uxTask ].pcTaskName = ( const signed char * ) &( pxNextTCB->pcTaskName [ 0 ] );\r
+                               pxTaskStatusArray[ uxTask ].xHandle = ( TaskHandle_t ) pxNextTCB;\r
+                               pxTaskStatusArray[ uxTask ].pcTaskName = ( const char * ) &( pxNextTCB->pcTaskName [ 0 ] );\r
                                pxTaskStatusArray[ uxTask ].xTaskNumber = pxNextTCB->uxTCBNumber;\r
                                pxTaskStatusArray[ uxTask ].eCurrentState = eState;\r
                                pxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority;\r
 \r
+                               #if ( INCLUDE_vTaskSuspend == 1 )\r
+                               {\r
+                                       /* If the task is in the suspended list then there is a chance\r
+                                       it is actually just blocked indefinitely - so really it should\r
+                                       be reported as being in the Blocked state. */\r
+                                       if( eState == eSuspended )\r
+                                       {\r
+                                               if( listLIST_ITEM_CONTAINER( &( pxNextTCB->xEventListItem ) ) != NULL )\r
+                                               {\r
+                                                       pxTaskStatusArray[ uxTask ].eCurrentState = eBlocked;\r
+                                               }\r
+                                       }\r
+                               }\r
+                               #endif /* INCLUDE_vTaskSuspend */\r
+\r
                                #if ( configUSE_MUTEXES == 1 )\r
                                {\r
                                        pxTaskStatusArray[ uxTask ].uxBasePriority = pxNextTCB->uxBasePriority;\r
@@ -2710,11 +3206,11 @@ tskTCB *pxNewTCB;
 \r
                                #if ( portSTACK_GROWTH > 0 )\r
                                {\r
-                                       pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxEndOfStack );\r
+                                       pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxEndOfStack );\r
                                }\r
                                #else\r
                                {\r
-                                       pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( unsigned char * ) pxNextTCB->pxStack );\r
+                                       pxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxStack );\r
                                }\r
                                #endif\r
 \r
@@ -2722,6 +3218,10 @@ tskTCB *pxNewTCB;
 \r
                        } while( pxNextTCB != pxFirstTCB );\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
 \r
                return uxTask;\r
        }\r
@@ -2731,19 +3231,19 @@ tskTCB *pxNewTCB;
 \r
 #if ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) )\r
 \r
-       static unsigned short prvTaskCheckFreeStackSpace( const unsigned char * pucStackByte )\r
+       static uint16_t prvTaskCheckFreeStackSpace( const uint8_t * pucStackByte )\r
        {\r
-       unsigned long ulCount = 0U;\r
+       uint32_t ulCount = 0U;\r
 \r
-               while( *pucStackByte == tskSTACK_FILL_BYTE )\r
+               while( *pucStackByte == ( uint8_t ) tskSTACK_FILL_BYTE )\r
                {\r
                        pucStackByte -= portSTACK_GROWTH;\r
                        ulCount++;\r
                }\r
 \r
-               ulCount /= ( unsigned long ) sizeof( portSTACK_TYPE );\r
+               ulCount /= ( uint32_t ) sizeof( StackType_t ); /*lint !e961 Casting is not redundant on smaller architectures. */\r
 \r
-               return ( unsigned short ) ulCount;\r
+               return ( uint16_t ) ulCount;\r
        }\r
 \r
 #endif /* ( ( configUSE_TRACE_FACILITY == 1 ) || ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) ) */\r
@@ -2751,25 +3251,25 @@ tskTCB *pxNewTCB;
 \r
 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )\r
 \r
-       unsigned portBASE_TYPE uxTaskGetStackHighWaterMark( xTaskHandle xTask )\r
+       UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask )\r
        {\r
-       tskTCB *pxTCB;\r
-       unsigned char *pcEndOfStack;\r
-       unsigned portBASE_TYPE uxReturn;\r
+       TCB_t *pxTCB;\r
+       uint8_t *pucEndOfStack;\r
+       UBaseType_t uxReturn;\r
 \r
                pxTCB = prvGetTCBFromHandle( xTask );\r
 \r
                #if portSTACK_GROWTH < 0\r
                {\r
-                       pcEndOfStack = ( unsigned char * ) pxTCB->pxStack;\r
+                       pucEndOfStack = ( uint8_t * ) pxTCB->pxStack;\r
                }\r
                #else\r
                {\r
-                       pcEndOfStack = ( unsigned char * ) pxTCB->pxEndOfStack;\r
+                       pucEndOfStack = ( uint8_t * ) pxTCB->pxEndOfStack;\r
                }\r
                #endif\r
 \r
-               uxReturn = ( unsigned portBASE_TYPE ) prvTaskCheckFreeStackSpace( pcEndOfStack );\r
+               uxReturn = ( UBaseType_t ) prvTaskCheckFreeStackSpace( pucEndOfStack );\r
 \r
                return uxReturn;\r
        }\r
@@ -2779,16 +3279,36 @@ tskTCB *pxNewTCB;
 \r
 #if ( INCLUDE_vTaskDelete == 1 )\r
 \r
-       static void prvDeleteTCB( tskTCB *pxTCB )\r
+       static void prvDeleteTCB( TCB_t *pxTCB )\r
        {\r
                /* This call is required specifically for the TriCore port.  It must be\r
                above the vPortFree() calls.  The call is also used by ports/demos that\r
                want to allocate and clean RAM statically. */\r
                portCLEAN_UP_TCB( pxTCB );\r
 \r
-               /* Free up the memory allocated by the scheduler for the task.  It is up to\r
-               the task to free any memory allocated at the application level. */\r
-               vPortFreeAligned( pxTCB->pxStack );\r
+               /* Free up the memory allocated by the scheduler for the task.  It is up\r
+               to the task to free any memory allocated at the application level. */\r
+               #if ( configUSE_NEWLIB_REENTRANT == 1 )\r
+               {\r
+                       _reclaim_reent( &( pxTCB->xNewLib_reent ) );\r
+               }\r
+               #endif /* configUSE_NEWLIB_REENTRANT */\r
+\r
+               #if( portUSING_MPU_WRAPPERS == 1 )\r
+               {\r
+                       /* Only free the stack if it was allocated dynamically in the first\r
+                       place. */\r
+                       if( pxTCB->xUsingStaticallyAllocatedStack == pdFALSE )\r
+                       {\r
+                               vPortFreeAligned( pxTCB->pxStack );\r
+                       }\r
+               }\r
+               #else\r
+               {\r
+                       vPortFreeAligned( pxTCB->pxStack );\r
+               }\r
+               #endif\r
+\r
                vPortFree( pxTCB );\r
        }\r
 \r
@@ -2797,13 +3317,12 @@ tskTCB *pxNewTCB;
 \r
 static void prvResetNextTaskUnblockTime( void )\r
 {\r
-tskTCB *pxTCB;\r
+TCB_t *pxTCB;\r
 \r
        if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE )\r
        {\r
-               /* The new current delayed list is empty.  Set\r
-               xNextTaskUnblockTime to the maximum possible value so it is\r
-               extremely unlikely that the\r
+               /* The new current delayed list is empty.  Set xNextTaskUnblockTime to\r
+               the maximum possible value so it is     extremely unlikely that the\r
                if( xTickCount >= xNextTaskUnblockTime ) test will pass until\r
                there is an item in the delayed list. */\r
                xNextTaskUnblockTime = portMAX_DELAY;\r
@@ -2814,7 +3333,7 @@ tskTCB *pxTCB;
                the item at the head of the delayed list.  This is the time at\r
                which the task at the head of the delayed list should be removed\r
                from the Blocked state. */\r
-               ( pxTCB ) = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
+               ( pxTCB ) = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
                xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( ( pxTCB )->xGenericListItem ) );\r
        }\r
 }\r
@@ -2822,9 +3341,9 @@ tskTCB *pxTCB;
 \r
 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )\r
 \r
-       xTaskHandle xTaskGetCurrentTaskHandle( void )\r
+       TaskHandle_t xTaskGetCurrentTaskHandle( void )\r
        {\r
-       xTaskHandle xReturn;\r
+       TaskHandle_t xReturn;\r
 \r
                /* A critical section is not required as this is not called from\r
                an interrupt and the current TCB will always be the same for any\r
@@ -2839,9 +3358,9 @@ tskTCB *pxTCB;
 \r
 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )\r
 \r
-       portBASE_TYPE xTaskGetSchedulerState( void )\r
+       BaseType_t xTaskGetSchedulerState( void )\r
        {\r
-       portBASE_TYPE xReturn;\r
+       BaseType_t xReturn;\r
 \r
                if( xSchedulerRunning == pdFALSE )\r
                {\r
@@ -2849,7 +3368,7 @@ tskTCB *pxTCB;
                }\r
                else\r
                {\r
-                       if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
+                       if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
                        {\r
                                xReturn = taskSCHEDULER_RUNNING;\r
                        }\r
@@ -2867,32 +3386,43 @@ tskTCB *pxTCB;
 \r
 #if ( configUSE_MUTEXES == 1 )\r
 \r
-       void vTaskPriorityInherit( xTaskHandle const pxMutexHolder )\r
+       void vTaskPriorityInherit( TaskHandle_t const pxMutexHolder )\r
        {\r
-       tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder;\r
+       TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder;\r
 \r
                /* If the mutex was given back by an interrupt while the queue was\r
                locked then the mutex holder might now be NULL. */\r
                if( pxMutexHolder != NULL )\r
                {\r
+                       /* If the holder of the mutex has a priority below the priority of\r
+                       the task attempting to obtain the mutex then it will temporarily\r
+                       inherit the priority of the task attempting to obtain the mutex. */\r
                        if( pxTCB->uxPriority < pxCurrentTCB->uxPriority )\r
                        {\r
                                /* Adjust the mutex holder state to account for its new\r
                                priority.  Only reset the event list item value if the value is\r
                                not     being used for anything else. */\r
-                               if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0 )\r
+                               if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL )\r
                                {\r
-                                       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( portTickType ) configMAX_PRIORITIES - ( portTickType ) pxCurrentTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                                       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
 \r
-                               /* If the task being modified is in the ready state it will need to\r
-                               be moved into a new list. */\r
+                               /* If the task being modified is in the ready state it will need\r
+                               to be moved into a new list. */\r
                                if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
                                {\r
-                                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+                                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
                                        {\r
                                                taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
                                        }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
 \r
                                        /* Inherit the priority before being moved into the new list. */\r
                                        pxTCB->uxPriority = pxCurrentTCB->uxPriority;\r
@@ -2906,6 +3436,14 @@ tskTCB *pxTCB;
 \r
                                traceTASK_PRIORITY_INHERIT( pxTCB, pxCurrentTCB->uxPriority );\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
        }\r
 \r
@@ -2914,35 +3452,80 @@ tskTCB *pxTCB;
 \r
 #if ( configUSE_MUTEXES == 1 )\r
 \r
-       void vTaskPriorityDisinherit( xTaskHandle const pxMutexHolder )\r
+       BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder )\r
        {\r
-       tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder;\r
+       TCB_t * const pxTCB = ( TCB_t * ) pxMutexHolder;\r
+       BaseType_t xReturn = pdFALSE;\r
 \r
                if( pxMutexHolder != NULL )\r
                {\r
+                       /* A task can only have an inherited priority if it holds the mutex.\r
+                       If the mutex is held by a task then it cannot be given from an\r
+                       interrupt, and if a mutex is given by the holding task then it must\r
+                       be the running state task. */\r
+                       configASSERT( pxTCB == pxCurrentTCB );\r
+\r
+                       configASSERT( pxTCB->uxMutexesHeld );\r
+                       ( pxTCB->uxMutexesHeld )--;\r
+\r
+                       /* Has the holder of the mutex inherited the priority of another\r
+                       task? */\r
                        if( pxTCB->uxPriority != pxTCB->uxBasePriority )\r
                        {\r
-                               /* We must be the running task to be able to give the mutex back.\r
-                               Remove ourselves from the ready list we currently appear in. */\r
-                               if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( unsigned portBASE_TYPE ) 0 )\r
+                               /* Only disinherit if no other mutexes are held. */\r
+                               if( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 )\r
                                {\r
-                                       taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
-                               }\r
+                                       /* A task can only have an inherited priority if it holds\r
+                                       the mutex.  If the mutex is held by a task then it cannot be\r
+                                       given from an interrupt, and if a mutex is given by the\r
+                                       holding task then it must be the running state task.  Remove\r
+                                       the     holding task from the ready     list. */\r
+                                       if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                                       {\r
+                                               taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
 \r
-                               /* Disinherit the priority before adding the task into the new\r
-                               ready list. */\r
-                               traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority );\r
-                               pxTCB->uxPriority = pxTCB->uxBasePriority;\r
+                                       /* Disinherit the priority before adding the task into the\r
+                                       new     ready list. */\r
+                                       traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority );\r
+                                       pxTCB->uxPriority = pxTCB->uxBasePriority;\r
 \r
-                               /* Only reset the event list item value if the value is not\r
-                               being used for anything else. */\r
-                               if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0 )\r
+                                       /* Reset the event list item value.  It cannot be in use for\r
+                                       any other purpose if this task is running, and it must be\r
+                                       running to give back the mutex. */\r
+                                       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+\r
+                                       /* Return true to indicate that a context switch is required.\r
+                                       This is only actually required in the corner case whereby\r
+                                       multiple mutexes were held and the mutexes were given back\r
+                                       in an order different to that in which they were taken.\r
+                                       If a context switch did not occur when the first mutex was\r
+                                       returned, even if a task was waiting on it, then a context\r
+                                       switch should occur when the last mutex is returned whether\r
+                                       a task is waiting on it or not. */\r
+                                       xReturn = pdTRUE;\r
+                               }\r
+                               else\r
                                {\r
-                                       listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( portTickType ) configMAX_PRIORITIES - ( portTickType ) pxTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+                                       mtCOVERAGE_TEST_MARKER();\r
                                }\r
-                               prvAddTaskToReadyList( pxTCB );\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
                        }\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
+\r
+               return xReturn;\r
        }\r
 \r
 #endif /* configUSE_MUTEXES */\r
@@ -2957,6 +3540,22 @@ tskTCB *pxTCB;
                if( xSchedulerRunning != pdFALSE )\r
                {\r
                        ( pxCurrentTCB->uxCriticalNesting )++;\r
+\r
+                       /* This is not the interrupt safe version of the enter critical\r
+                       function so     assert() if it is being called from an interrupt\r
+                       context.  Only API functions that end in "FromISR" can be used in an\r
+                       interrupt.  Only assert if the critical nesting count is 1 to\r
+                       protect against recursive calls if the assert function also uses a\r
+                       critical section. */\r
+                       if( pxCurrentTCB->uxCriticalNesting == 1 )\r
+                       {\r
+                               portASSERT_IF_IN_ISR();\r
+                       }\r
+\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
        }\r
 \r
@@ -2977,20 +3576,58 @@ tskTCB *pxTCB;
                                {\r
                                        portENABLE_INTERRUPTS();\r
                                }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
                }\r
        }\r
 \r
 #endif /* portCRITICAL_NESTING_IN_TCB */\r
 /*-----------------------------------------------------------*/\r
 \r
-#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) )\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )\r
+\r
+       static char *prvWriteNameToBuffer( char *pcBuffer, const char *pcTaskName )\r
+       {\r
+       BaseType_t x;\r
+\r
+               /* Start by copying the entire string. */\r
+               strcpy( pcBuffer, pcTaskName );\r
+\r
+               /* Pad the end of the string with spaces to ensure columns line up when\r
+               printed out. */\r
+               for( x = strlen( pcBuffer ); x < ( configMAX_TASK_NAME_LEN - 1 ); x++ )\r
+               {\r
+                       pcBuffer[ x ] = ' ';\r
+               }\r
+\r
+               /* Terminate. */\r
+               pcBuffer[ x ] = 0x00;\r
+\r
+               /* Return the new end of string. */\r
+               return &( pcBuffer[ x ] );\r
+       }\r
+\r
+#endif /* ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )\r
 \r
-       void vTaskList( signed char *pcWriteBuffer )\r
+       void vTaskList( char * pcWriteBuffer )\r
        {\r
-       xTaskStatusType *pxTaskStatusArray;\r
-       volatile unsigned portBASE_TYPE uxArraySize, x;\r
-       signed char cStatus;\r
+       TaskStatus_t *pxTaskStatusArray;\r
+       volatile UBaseType_t uxArraySize, x;\r
+       char cStatus;\r
 \r
                /*\r
                 * PLEASE NOTE:\r
@@ -3025,7 +3662,7 @@ tskTCB *pxTCB;
                uxArraySize = uxCurrentNumberOfTasks;\r
 \r
                /* Allocate an array index for each task. */\r
-               pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( xTaskStatusType ) );\r
+               pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) );\r
 \r
                if( pxTaskStatusArray != NULL )\r
                {\r
@@ -3037,43 +3674,58 @@ tskTCB *pxTCB;
                        {\r
                                switch( pxTaskStatusArray[ x ].eCurrentState )\r
                                {\r
-                               case eReady:            cStatus = tskREADY_CHAR;\r
-                                                                       break;\r
+                                       case eReady:            cStatus = tskREADY_CHAR;\r
+                                                                               break;\r
 \r
-                               case eBlocked:          cStatus = tskBLOCKED_CHAR;\r
-                                                                       break;\r
+                                       case eBlocked:          cStatus = tskBLOCKED_CHAR;\r
+                                                                               break;\r
 \r
-                               case eSuspended:        cStatus = tskSUSPENDED_CHAR;\r
-                                                                       break;\r
+                                       case eSuspended:        cStatus = tskSUSPENDED_CHAR;\r
+                                                                               break;\r
 \r
-                               case eDeleted:          cStatus = tskDELETED_CHAR;\r
-                                                                       break;\r
+                                       case eDeleted:          cStatus = tskDELETED_CHAR;\r
+                                                                               break;\r
 \r
-                               default:                        /* Should not get here, but it is included\r
-                                                                       to prevent static checking errors. */\r
-                                                                       cStatus = 0x00;\r
-                                                                       break;\r
+                                       default:                        /* Should not get here, but it is included\r
+                                                                               to prevent static checking errors. */\r
+                                                                               cStatus = 0x00;\r
+                                                                               break;\r
                                }\r
 \r
-                               sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%c\t%u\t%u\t%u\r\n", pxTaskStatusArray[ x ].pcTaskName, ( char ) cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );\r
-                               pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );\r
+                               /* Write the task name to the string, padding with spaces so it\r
+                               can be printed in tabular form more easily. */\r
+                               pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );\r
+\r
+                               /* Write the rest of the string. */\r
+                               sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );\r
+                               pcWriteBuffer += strlen( pcWriteBuffer );\r
                        }\r
 \r
                        /* Free the array again. */\r
                        vPortFree( pxTaskStatusArray );\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
 \r
-#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) ) */\r
+#endif /* ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) */\r
 /*----------------------------------------------------------*/\r
 \r
-#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) )\r
+#if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )\r
 \r
-       void vTaskGetRunTimeStats( signed char *pcWriteBuffer )\r
+       void vTaskGetRunTimeStats( char *pcWriteBuffer )\r
        {\r
-       xTaskStatusType *pxTaskStatusArray;\r
-       volatile unsigned portBASE_TYPE uxArraySize, x;\r
-       unsigned long ulTotalTime, ulStatsAsPercentage;\r
+       TaskStatus_t *pxTaskStatusArray;\r
+       volatile UBaseType_t uxArraySize, x;\r
+       uint32_t ulTotalTime, ulStatsAsPercentage;\r
+\r
+               #if( configUSE_TRACE_FACILITY != 1 )\r
+               {\r
+                       #error configUSE_TRACE_FACILITY must also be set to 1 in FreeRTOSConfig.h to use vTaskGetRunTimeStats().\r
+               }\r
+               #endif\r
 \r
                /*\r
                 * PLEASE NOTE:\r
@@ -3108,7 +3760,7 @@ tskTCB *pxTCB;
                uxArraySize = uxCurrentNumberOfTasks;\r
 \r
                /* Allocate an array index for each task. */\r
-               pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( xTaskStatusType ) );\r
+               pxTaskStatusArray = pvPortMalloc( uxCurrentNumberOfTasks * sizeof( TaskStatus_t ) );\r
 \r
                if( pxTaskStatusArray != NULL )\r
                {\r
@@ -3129,17 +3781,22 @@ tskTCB *pxTCB;
                                        ulTotalRunTimeDiv100 has already been divided by 100. */\r
                                        ulStatsAsPercentage = pxTaskStatusArray[ x ].ulRunTimeCounter / ulTotalTime;\r
 \r
+                                       /* Write the task name to the string, padding with\r
+                                       spaces so it can be printed in tabular form more\r
+                                       easily. */\r
+                                       pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );\r
+\r
                                        if( ulStatsAsPercentage > 0UL )\r
                                        {\r
                                                #ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
                                                {\r
-                                                       sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );\r
+                                                       sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );\r
                                                }\r
                                                #else\r
                                                {\r
                                                        /* sizeof( int ) == sizeof( long ) so a smaller\r
                                                        printf() library can be used. */\r
-                                                       sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%u\t\t%u%%\r\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );\r
+                                                       sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );\r
                                                }\r
                                                #endif\r
                                        }\r
@@ -3149,43 +3806,581 @@ tskTCB *pxTCB;
                                                consumed less than 1% of the total run time. */\r
                                                #ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
                                                {\r
-                                                       sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+                                                       sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter );\r
                                                }\r
                                                #else\r
                                                {\r
                                                        /* sizeof( int ) == sizeof( long ) so a smaller\r
                                                        printf() library can be used. */\r
-                                                       sprintf( ( char * ) pcWriteBuffer, ( char * ) "%s\t\t%u\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+                                                       sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );\r
                                                }\r
                                                #endif\r
                                        }\r
 \r
-                                       pcWriteBuffer += strlen( ( char * ) pcWriteBuffer );\r
+                                       pcWriteBuffer += strlen( pcWriteBuffer );\r
                                }\r
                        }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
 \r
                        /* Free the array again. */\r
                        vPortFree( pxTaskStatusArray );\r
                }\r
+               else\r
+               {\r
+                       mtCOVERAGE_TEST_MARKER();\r
+               }\r
        }\r
 \r
-#endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) ) */\r
+#endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) ) */\r
 /*-----------------------------------------------------------*/\r
 \r
-portTickType uxTaskResetEventItemValue( void )\r
+TickType_t uxTaskResetEventItemValue( void )\r
 {\r
-portTickType uxReturn;\r
+TickType_t uxReturn;\r
 \r
        uxReturn = listGET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ) );\r
 \r
        /* Reset the event list item to its normal value - so it can be used with\r
        queues and semaphores. */\r
-       listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), ( ( portTickType ) configMAX_PRIORITIES - ( portTickType ) pxCurrentTCB->uxPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+       listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), ( ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ) ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
 \r
        return uxReturn;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+#if ( configUSE_MUTEXES == 1 )\r
+\r
+       void *pvTaskIncrementMutexHeldCount( void )\r
+       {\r
+               /* If xSemaphoreCreateMutex() is called before any tasks have been created\r
+               then pxCurrentTCB will be NULL. */\r
+               if( pxCurrentTCB != NULL )\r
+               {\r
+                       ( pxCurrentTCB->uxMutexesHeld )++;\r
+               }\r
+\r
+               return pxCurrentTCB;\r
+       }\r
+\r
+#endif /* configUSE_MUTEXES */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait )\r
+       {\r
+       TickType_t xTimeToWake;\r
+       uint32_t ulReturn;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* Only block if the notification count is not already non-zero. */\r
+                       if( pxCurrentTCB->ulNotifiedValue == 0UL )\r
+                       {\r
+                               /* Mark this task as waiting for a notification. */\r
+                               pxCurrentTCB->eNotifyState = eWaitingNotification;\r
+\r
+                               if( xTicksToWait > ( TickType_t ) 0 )\r
+                               {\r
+                                       /* The task is going to block.  First it must be removed\r
+                                       from the ready list. */\r
+                                       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                                       {\r
+                                               /* The current task must be in a ready list, so there is\r
+                                               no need to check, and the port reset macro can be called\r
+                                               directly. */\r
+                                               portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       #if ( INCLUDE_vTaskSuspend == 1 )\r
+                                       {\r
+                                               if( xTicksToWait == portMAX_DELAY )\r
+                                               {\r
+                                                       /* Add the task to the suspended task list instead\r
+                                                       of a delayed task list to ensure the task is not\r
+                                                       woken by a timing event.  It will block\r
+                                                       indefinitely. */\r
+                                                       vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       /* Calculate the time at which the task should be\r
+                                                       woken if no notification events occur.  This may\r
+                                                       overflow but this doesn't matter, the scheduler will\r
+                                                       handle it. */\r
+                                                       xTimeToWake = xTickCount + xTicksToWait;\r
+                                                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                                               }\r
+                                       }\r
+                                       #else /* INCLUDE_vTaskSuspend */\r
+                                       {\r
+                                                       /* Calculate the time at which the task should be\r
+                                                       woken if the event does not occur.  This may\r
+                                                       overflow but this doesn't matter, the scheduler will\r
+                                                       handle it. */\r
+                                                       xTimeToWake = xTickCount + xTicksToWait;\r
+                                                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                                       }\r
+                                       #endif /* INCLUDE_vTaskSuspend */\r
+\r
+                                       /* All ports are written to allow a yield in a critical\r
+                                       section (some will yield immediately, others wait until the\r
+                                       critical section exits) - but it is not something that\r
+                                       application code should ever do. */\r
+                                       portYIELD_WITHIN_API();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       ulReturn = pxCurrentTCB->ulNotifiedValue;\r
+\r
+                       if( ulReturn != 0UL )\r
+                       {\r
+                               if( xClearCountOnExit != pdFALSE )\r
+                               {\r
+                                       pxCurrentTCB->ulNotifiedValue = 0UL;\r
+                               }\r
+                               else\r
+                               {\r
+                                       ( pxCurrentTCB->ulNotifiedValue )--;\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+\r
+                       pxCurrentTCB->eNotifyState = eNotWaitingNotification;\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return ulReturn;\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait )\r
+       {\r
+       TickType_t xTimeToWake;\r
+       BaseType_t xReturn;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       /* Only block if a notification is not already pending. */\r
+                       if( pxCurrentTCB->eNotifyState != eNotified )\r
+                       {\r
+                               /* Clear bits in the task's notification value as bits may get\r
+                               set     by the notifying task or interrupt.  This can be used to\r
+                               clear the value to zero. */\r
+                               pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnEntry;\r
+\r
+                               /* Mark this task as waiting for a notification. */\r
+                               pxCurrentTCB->eNotifyState = eWaitingNotification;\r
+\r
+                               if( xTicksToWait > ( TickType_t ) 0 )\r
+                               {\r
+                                       /* The task is going to block.  First it must be removed\r
+                                       from the        ready list. */\r
+                                       if( uxListRemove( &( pxCurrentTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )\r
+                                       {\r
+                                               /* The current task must be in a ready list, so there is\r
+                                               no need to check, and the port reset macro can be called\r
+                                               directly. */\r
+                                               portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               mtCOVERAGE_TEST_MARKER();\r
+                                       }\r
+\r
+                                       #if ( INCLUDE_vTaskSuspend == 1 )\r
+                                       {\r
+                                               if( xTicksToWait == portMAX_DELAY )\r
+                                               {\r
+                                                       /* Add the task to the suspended task list instead\r
+                                                       of a delayed task list to ensure the task is not\r
+                                                       woken by a timing event.  It will block\r
+                                                       indefinitely. */\r
+                                                       vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       /* Calculate the time at which the task should be\r
+                                                       woken if no notification events occur.  This may\r
+                                                       overflow but this doesn't matter, the scheduler will\r
+                                                       handle it. */\r
+                                                       xTimeToWake = xTickCount + xTicksToWait;\r
+                                                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                                               }\r
+                                       }\r
+                                       #else /* INCLUDE_vTaskSuspend */\r
+                                       {\r
+                                                       /* Calculate the time at which the task should be\r
+                                                       woken if the event does not occur.  This may\r
+                                                       overflow but this doesn't matter, the scheduler will\r
+                                                       handle it. */\r
+                                                       xTimeToWake = xTickCount + xTicksToWait;\r
+                                                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+                                       }\r
+                                       #endif /* INCLUDE_vTaskSuspend */\r
+\r
+                                       /* All ports are written to allow a yield in a critical\r
+                                       section (some will yield immediately, others wait until the\r
+                                       critical section exits) - but it is not something that\r
+                                       application code should ever do. */\r
+                                       portYIELD_WITHIN_API();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       if( pulNotificationValue != NULL )\r
+                       {\r
+                               /* Output the current notification value, which may or may not\r
+                               have changed. */\r
+                               *pulNotificationValue = pxCurrentTCB->ulNotifiedValue;\r
+                       }\r
+\r
+                       /* If eNotifyValue is set then either the task never entered the\r
+                       blocked state (because a notification was already pending) or the\r
+                       task unblocked because of a notification.  Otherwise the task\r
+                       unblocked because of a timeout. */\r
+                       if( pxCurrentTCB->eNotifyState == eWaitingNotification )\r
+                       {\r
+                               /* A notification was not received. */\r
+                               xReturn = pdFALSE;\r
+                       }\r
+                       else\r
+                       {\r
+                               /* A notification was already pending or a notification was\r
+                               received while the task was waiting. */\r
+                               pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnExit;\r
+                               xReturn = pdTRUE;\r
+                       }\r
+\r
+                       pxCurrentTCB->eNotifyState = eNotWaitingNotification;\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue )\r
+       {\r
+       TCB_t * pxTCB;\r
+       eNotifyValue eOriginalNotifyState;\r
+       BaseType_t xReturn = pdPASS;\r
+\r
+               configASSERT( xTaskToNotify );\r
+               pxTCB = ( TCB_t * ) xTaskToNotify;\r
+\r
+               taskENTER_CRITICAL();\r
+               {\r
+                       if( pulPreviousNotificationValue != NULL )\r
+                       {\r
+                               *pulPreviousNotificationValue = pxTCB->ulNotifiedValue;\r
+                       }\r
+\r
+                       eOriginalNotifyState = pxTCB->eNotifyState;\r
+\r
+                       pxTCB->eNotifyState = eNotified;\r
+\r
+                       switch( eAction )\r
+                       {\r
+                               case eSetBits   :\r
+                                       pxTCB->ulNotifiedValue |= ulValue;\r
+                                       break;\r
+\r
+                               case eIncrement :\r
+                                       ( pxTCB->ulNotifiedValue )++;\r
+                                       break;\r
+\r
+                               case eSetValueWithOverwrite     :\r
+                                       pxTCB->ulNotifiedValue = ulValue;\r
+                                       break;\r
+\r
+                               case eSetValueWithoutOverwrite :\r
+                                       if( eOriginalNotifyState != eNotified )\r
+                                       {\r
+                                               pxTCB->ulNotifiedValue = ulValue;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* The value could not be written to the task. */\r
+                                               xReturn = pdFAIL;\r
+                                       }\r
+                                       break;\r
+\r
+                               case eNoAction:\r
+                                       /* The task is being notified without its notify value being\r
+                                       updated. */\r
+                                       break;\r
+                       }\r
+\r
+\r
+                       /* If the task is in the blocked state specifically to wait for a\r
+                       notification then unblock it now. */\r
+                       if( eOriginalNotifyState == eWaitingNotification )\r
+                       {\r
+                               ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
+                               prvAddTaskToReadyList( pxTCB );\r
+\r
+                               /* The task should not have been on an event list. */\r
+                               configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
+\r
+                               if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )\r
+                               {\r
+                                       /* The notified task has a priority above the currently\r
+                                       executing task so a yield is required. */\r
+                                       taskYIELD_IF_USING_PREEMPTION();\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+               taskEXIT_CRITICAL();\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, BaseType_t *pxHigherPriorityTaskWoken )\r
+       {\r
+       TCB_t * pxTCB;\r
+       eNotifyValue eOriginalNotifyState;\r
+       BaseType_t xReturn = pdPASS;\r
+       UBaseType_t uxSavedInterruptStatus;\r
+\r
+               configASSERT( xTaskToNotify );\r
+\r
+               /* RTOS ports that support interrupt nesting have the concept of a\r
+               maximum system call (or maximum API call) interrupt priority.\r
+               Interrupts that are     above the maximum system call priority are keep\r
+               permanently enabled, even when the RTOS kernel is in a critical section,\r
+               but cannot make any calls to FreeRTOS API functions.  If configASSERT()\r
+               is defined in FreeRTOSConfig.h then\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+               failure if a FreeRTOS API function is called from an interrupt that has\r
+               been assigned a priority above the configured maximum system call\r
+               priority.  Only FreeRTOS functions that end in FromISR can be called\r
+               from interrupts that have been assigned a priority at or (logically)\r
+               below the maximum system call interrupt priority.  FreeRTOS maintains a\r
+               separate interrupt safe API to ensure interrupt entry is as fast and as\r
+               simple as possible.  More information (albeit Cortex-M specific) is\r
+               provided on the following link:\r
+               http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+               pxTCB = ( TCB_t * ) xTaskToNotify;\r
+\r
+               uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+               {\r
+                       eOriginalNotifyState = pxTCB->eNotifyState;\r
+\r
+                       pxTCB->eNotifyState = eNotified;\r
+\r
+                       switch( eAction )\r
+                       {\r
+                               case eSetBits   :\r
+                                       pxTCB->ulNotifiedValue |= ulValue;\r
+                                       break;\r
+\r
+                               case eIncrement :\r
+                                       ( pxTCB->ulNotifiedValue )++;\r
+                                       break;\r
+\r
+                               case eSetValueWithOverwrite     :\r
+                                       pxTCB->ulNotifiedValue = ulValue;\r
+                                       break;\r
+\r
+                               case eSetValueWithoutOverwrite :\r
+                                       if( eOriginalNotifyState != eNotified )\r
+                                       {\r
+                                               pxTCB->ulNotifiedValue = ulValue;\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               /* The value could not be written to the task. */\r
+                                               xReturn = pdFAIL;\r
+                                       }\r
+                                       break;\r
+\r
+                               case eNoAction :\r
+                                       /* The task is being notified without its notify value being\r
+                                       updated. */\r
+                                       break;\r
+                       }\r
+\r
+\r
+                       /* If the task is in the blocked state specifically to wait for a\r
+                       notification then unblock it now. */\r
+                       if( eOriginalNotifyState == eWaitingNotification )\r
+                       {\r
+                               /* The task should not have been on an event list. */\r
+                               configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
+\r
+                               if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
+                               {\r
+                                       ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* The delayed and ready lists cannot be accessed, so hold\r
+                                       this task pending until the scheduler is resumed. */\r
+                                       vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) );\r
+                               }\r
+\r
+                               if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )\r
+                               {\r
+                                       /* The notified task has a priority above the currently\r
+                                       executing task so a yield is required. */\r
+                                       if( pxHigherPriorityTaskWoken != NULL )\r
+                                       {\r
+                                               *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+               }\r
+               portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+               return xReturn;\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( configUSE_TASK_NOTIFICATIONS == 1 )\r
+\r
+       void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken )\r
+       {\r
+       TCB_t * pxTCB;\r
+       eNotifyValue eOriginalNotifyState;\r
+       UBaseType_t uxSavedInterruptStatus;\r
+\r
+               configASSERT( xTaskToNotify );\r
+\r
+               /* RTOS ports that support interrupt nesting have the concept of a\r
+               maximum system call (or maximum API call) interrupt priority.\r
+               Interrupts that are     above the maximum system call priority are keep\r
+               permanently enabled, even when the RTOS kernel is in a critical section,\r
+               but cannot make any calls to FreeRTOS API functions.  If configASSERT()\r
+               is defined in FreeRTOSConfig.h then\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion\r
+               failure if a FreeRTOS API function is called from an interrupt that has\r
+               been assigned a priority above the configured maximum system call\r
+               priority.  Only FreeRTOS functions that end in FromISR can be called\r
+               from interrupts that have been assigned a priority at or (logically)\r
+               below the maximum system call interrupt priority.  FreeRTOS maintains a\r
+               separate interrupt safe API to ensure interrupt entry is as fast and as\r
+               simple as possible.  More information (albeit Cortex-M specific) is\r
+               provided on the following link:\r
+               http://www.freertos.org/RTOS-Cortex-M3-M4.html */\r
+               portASSERT_IF_INTERRUPT_PRIORITY_INVALID();\r
+\r
+               pxTCB = ( TCB_t * ) xTaskToNotify;\r
+\r
+               uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+               {\r
+                       eOriginalNotifyState = pxTCB->eNotifyState;\r
+                       pxTCB->eNotifyState = eNotified;\r
+\r
+                       /* 'Giving' is equivalent to incrementing a count in a counting\r
+                       semaphore. */\r
+                       ( pxTCB->ulNotifiedValue )++;\r
+\r
+                       /* If the task is in the blocked state specifically to wait for a\r
+                       notification then unblock it now. */\r
+                       if( eOriginalNotifyState == eWaitingNotification )\r
+                       {\r
+                               /* The task should not have been on an event list. */\r
+                               configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
+\r
+                               if( uxSchedulerSuspended == ( UBaseType_t ) pdFALSE )\r
+                               {\r
+                                       ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* The delayed and ready lists cannot be accessed, so hold\r
+                                       this task pending until the scheduler is resumed. */\r
+                                       vListInsertEnd( &( xPendingReadyList ), &( pxTCB->xEventListItem ) );\r
+                               }\r
+\r
+                               if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )\r
+                               {\r
+                                       /* The notified task has a priority above the currently\r
+                                       executing task so a yield is required. */\r
+                                       if( pxHigherPriorityTaskWoken != NULL )\r
+                                       {\r
+                                               *pxHigherPriorityTaskWoken = pdTRUE;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+               }\r
+               portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+       }\r
+\r
+#endif /* configUSE_TASK_NOTIFICATIONS */\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
 #ifdef FREERTOS_MODULE_TEST\r
        #include "tasks_test_access_functions.h"\r
 #endif\r