]> git.sur5r.net Git - freertos/commitdiff
FreeRTOS source:
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 10 Feb 2016 12:58:15 +0000 (12:58 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 10 Feb 2016 12:58:15 +0000 (12:58 +0000)
 - Major refactor to consolidate the multiple places where a task is removed from a ready list and placed in a delay list into a single function, reducing code size, and enabling the easy addition of up-coming functionality.
 - Replace the enum used for task notification states with a uint8_t to reduce the TCB struct size with some compilers, and allow additional members to be added without increasing its size.
 - Rearrange FreeRTOS.h so all INCLUDE_ defaults are grouped together.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2415 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace/Include/trcKernelPort.h
FreeRTOS/Source/include/FreeRTOS.h
FreeRTOS/Source/include/task.h
FreeRTOS/Source/tasks.c

index 7c8244137969340dbbb0680b7f076db03df9a58c..47b6fdcf86bd9f4dddb5b0587790cad38049cafb 100644 (file)
@@ -56,7 +56,7 @@ extern int uiInEventGroupSetBitsFromISR;
 #define TRACE_CPU_CLOCK_HZ configCPU_CLOCK_HZ /* Defined in "FreeRTOSConfig.h" */\r
 \r
 #if (SELECTED_PORT == PORT_ARM_CortexM)\r
-       \r
+\r
        /* Uses CMSIS API */\r
 \r
        #define TRACE_SR_ALLOC_CRITICAL_SECTION() int __irq_status;\r
@@ -571,8 +571,8 @@ void* prvTraceGetCurrentTaskHandle(void);
 \r
 /* Called on vTaskDelayUntil - note the use of FreeRTOS variable xTimeToWake */\r
 #undef traceTASK_DELAY_UNTIL\r
-#define traceTASK_DELAY_UNTIL() \\r
-       trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY_UNTIL, pxCurrentTCB, xTimeToWake); \\r
+#define traceTASK_DELAY_UNTIL( xTickTimeToWake ) \\r
+       trcKERNEL_HOOKS_TASK_DELAY(TASK_DELAY_UNTIL, pxCurrentTCB, ( xTickTimeToWake)); \\r
        trcKERNEL_HOOKS_SET_TASK_INSTANCE_FINISHED();\r
 \r
 #if (INCLUDE_OBJECT_DELETE == 1)\r
@@ -819,7 +819,7 @@ else \
 \r
 #undef traceTASK_NOTIFY_TAKE\r
 #define traceTASK_NOTIFY_TAKE() \\r
-       if (pxCurrentTCB->eNotifyState == eNotified) \\r
+       if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \\r
                vTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_TAKE, TRACE_CLASS_TASK, uxTaskGetTaskNumber(pxCurrentTCB), xTicksToWait); \\r
        else \\r
                vTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_TAKE_FAILED, TRACE_CLASS_TASK, uxTaskGetTaskNumber(pxCurrentTCB), xTicksToWait);\r
@@ -831,7 +831,7 @@ else \
 \r
 #undef traceTASK_NOTIFY_WAIT\r
 #define traceTASK_NOTIFY_WAIT() \\r
-       if (pxCurrentTCB->eNotifyState == eNotified) \\r
+       if (pxCurrentTCB->ucNotifyState == taskNOTIFICATION_RECEIVED) \\r
                vTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT, TRACE_CLASS_TASK, uxTaskGetTaskNumber(pxCurrentTCB), xTicksToWait); \\r
        else \\r
                vTraceStoreKernelCallWithParam(TRACE_TASK_NOTIFY_WAIT_FAILED, TRACE_CLASS_TASK, uxTaskGetTaskNumber(pxCurrentTCB), xTicksToWait);\r
@@ -848,7 +848,7 @@ else \
 #undef traceTASK_NOTIFY_FROM_ISR\r
 #define traceTASK_NOTIFY_FROM_ISR() \\r
        vTraceStoreKernelCall(TRACE_TASK_NOTIFY_FROM_ISR, TRACE_CLASS_TASK, uxTaskGetTaskNumber(xTaskToNotify));\r
-       \r
+\r
 #undef traceTASK_NOTIFY_GIVE_FROM_ISR\r
 #define traceTASK_NOTIFY_GIVE_FROM_ISR() \\r
        vTraceStoreKernelCall(TRACE_TASK_NOTIFY_GIVE_FROM_ISR, TRACE_CLASS_TASK, uxTaskGetTaskNumber(xTaskToNotify));\r
index 33a4d79f137cd9785a5e98d36afd710b7de6c068..55306add005b84923d8d9549d862a25d7014f824 100644 (file)
@@ -129,56 +129,50 @@ extern "C" {
        #error Missing definition:  configUSE_TICK_HOOK must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
 #endif\r
 \r
-#ifndef INCLUDE_vTaskPrioritySet\r
-       #error Missing definition:  INCLUDE_vTaskPrioritySet must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
-#endif\r
-\r
-#ifndef INCLUDE_uxTaskPriorityGet\r
-       #error Missing definition:  INCLUDE_uxTaskPriorityGet must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
-#endif\r
-\r
-#ifndef INCLUDE_vTaskDelete\r
-       #error Missing definition:  INCLUDE_vTaskDelete must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef configUSE_16_BIT_TICKS\r
+       #error Missing definition:  configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
 #endif\r
 \r
-#ifndef INCLUDE_vTaskSuspend\r
-       #error Missing definition:  INCLUDE_vTaskSuspend must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef configMAX_PRIORITIES\r
+       #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.\r
 #endif\r
 \r
-#ifndef INCLUDE_vTaskDelayUntil\r
-       #error Missing definition:  INCLUDE_vTaskDelayUntil must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef configUSE_CO_ROUTINES\r
+       #define configUSE_CO_ROUTINES 0\r
 #endif\r
 \r
-#ifndef INCLUDE_vTaskDelay\r
-       #error Missing definition:  INCLUDE_vTaskDelay must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef INCLUDE_vTaskPrioritySet\r
+       #define INCLUDE_vTaskPrioritySet 0\r
 #endif\r
 \r
-#ifndef configUSE_16_BIT_TICKS\r
-       #error Missing definition:  configUSE_16_BIT_TICKS must be defined in FreeRTOSConfig.h as either 1 or 0.  See the Configuration section of the FreeRTOS API documentation for details.\r
+#ifndef INCLUDE_uxTaskPriorityGet\r
+       #define INCLUDE_uxTaskPriorityGet 0\r
 #endif\r
 \r
-#ifndef configMAX_PRIORITIES\r
-       #error configMAX_PRIORITIES must be defined to be greater than or equal to 1.\r
+#ifndef INCLUDE_vTaskDelete\r
+       #define INCLUDE_vTaskDelete 0\r
 #endif\r
 \r
-#ifndef configUSE_CO_ROUTINES\r
-       #define configUSE_CO_ROUTINES 0\r
+#ifndef INCLUDE_vTaskSuspend\r
+       #define INCLUDE_vTaskSuspend 0\r
 #endif\r
 \r
-#if configUSE_CO_ROUTINES != 0\r
-       #ifndef configMAX_CO_ROUTINE_PRIORITIES\r
-               #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1.\r
-       #endif\r
+#ifndef INCLUDE_vTaskDelayUntil\r
+       #define INCLUDE_vTaskDelayUntil 0\r
 #endif\r
 \r
-#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK\r
-       #define configUSE_DAEMON_TASK_STARTUP_HOOK 0\r
+#ifndef INCLUDE_vTaskDelay\r
+       #define INCLUDE_vTaskDelay 0\r
 #endif\r
 \r
 #ifndef INCLUDE_xTaskGetIdleTaskHandle\r
        #define INCLUDE_xTaskGetIdleTaskHandle 0\r
 #endif\r
 \r
+#ifndef INCLUDE_xTaskAbortDelay\r
+       #define INCLUDE_xTaskAbortDelay 0\r
+#endif\r
+\r
 #ifndef INCLUDE_xTimerGetTimerDaemonTaskHandle\r
        #define INCLUDE_xTimerGetTimerDaemonTaskHandle 0\r
 #endif\r
@@ -199,14 +193,6 @@ extern "C" {
        #define INCLUDE_xTaskGetTaskHandle 0\r
 #endif\r
 \r
-#ifndef configUSE_APPLICATION_TASK_TAG\r
-       #define configUSE_APPLICATION_TASK_TAG 0\r
-#endif\r
-\r
-#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS\r
-       #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0\r
-#endif\r
-\r
 #ifndef INCLUDE_uxTaskGetStackHighWaterMark\r
        #define INCLUDE_uxTaskGetStackHighWaterMark 0\r
 #endif\r
@@ -215,6 +201,40 @@ extern "C" {
        #define INCLUDE_eTaskGetState 0\r
 #endif\r
 \r
+#ifndef INCLUDE_xTaskResumeFromISR\r
+       #define INCLUDE_xTaskResumeFromISR 1\r
+#endif\r
+\r
+#ifndef INCLUDE_xTimerPendFunctionCall\r
+       #define INCLUDE_xTimerPendFunctionCall 0\r
+#endif\r
+\r
+#ifndef INCLUDE_xTaskGetSchedulerState\r
+       #define INCLUDE_xTaskGetSchedulerState 0\r
+#endif\r
+\r
+#ifndef INCLUDE_xTaskGetCurrentTaskHandle\r
+       #define INCLUDE_xTaskGetCurrentTaskHandle 0\r
+#endif\r
+\r
+#if configUSE_CO_ROUTINES != 0\r
+       #ifndef configMAX_CO_ROUTINE_PRIORITIES\r
+               #error configMAX_CO_ROUTINE_PRIORITIES must be greater than or equal to 1.\r
+       #endif\r
+#endif\r
+\r
+#ifndef configUSE_DAEMON_TASK_STARTUP_HOOK\r
+       #define configUSE_DAEMON_TASK_STARTUP_HOOK 0\r
+#endif\r
+\r
+#ifndef configUSE_APPLICATION_TASK_TAG\r
+       #define configUSE_APPLICATION_TASK_TAG 0\r
+#endif\r
+\r
+#ifndef configNUM_THREAD_LOCAL_STORAGE_POINTERS\r
+       #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 0\r
+#endif\r
+\r
 #ifndef configUSE_RECURSIVE_MUTEXES\r
        #define configUSE_RECURSIVE_MUTEXES 0\r
 #endif\r
@@ -251,14 +271,6 @@ extern "C" {
        #error configMAX_TASK_NAME_LEN must be set to a minimum of 1 in FreeRTOSConfig.h\r
 #endif\r
 \r
-#ifndef INCLUDE_xTaskResumeFromISR\r
-       #define INCLUDE_xTaskResumeFromISR 1\r
-#endif\r
-\r
-#ifndef INCLUDE_xTimerPendFunctionCall\r
-       #define INCLUDE_xTimerPendFunctionCall 0\r
-#endif\r
-\r
 #ifndef configASSERT\r
        #define configASSERT( x )\r
        #define configASSERT_DEFINED 0\r
@@ -283,15 +295,6 @@ extern "C" {
 \r
 #endif /* configUSE_TIMERS */\r
 \r
-#ifndef INCLUDE_xTaskGetSchedulerState\r
-       #define INCLUDE_xTaskGetSchedulerState 0\r
-#endif\r
-\r
-#ifndef INCLUDE_xTaskGetCurrentTaskHandle\r
-       #define INCLUDE_xTaskGetCurrentTaskHandle 0\r
-#endif\r
-\r
-\r
 #ifndef portSET_INTERRUPT_MASK_FROM_ISR\r
        #define portSET_INTERRUPT_MASK_FROM_ISR() 0\r
 #endif\r
@@ -515,7 +518,7 @@ extern "C" {
 #endif\r
 \r
 #ifndef traceTASK_DELAY_UNTIL\r
-       #define traceTASK_DELAY_UNTIL()\r
+       #define traceTASK_DELAY_UNTIL( x )\r
 #endif\r
 \r
 #ifndef traceTASK_DELAY\r
@@ -877,12 +880,6 @@ typedef struct xSTATIC_LIST
        StaticMiniListItem_t xDummy3;\r
 } StaticList_t;\r
 \r
-/* For data hiding purposes. */\r
-typedef enum\r
-{\r
-       eNothing = 0\r
-} eDummy;\r
-\r
 /*\r
  * In line with software engineering best practice, especially when supplying a\r
  * library that is likely to change in future versions, FreeRTOS implements a\r
@@ -932,7 +929,7 @@ typedef struct xSTATIC_TCB
        #endif\r
        #if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
                uint32_t                ulDummy18;\r
-               eDummy                  eDummy19;\r
+               uint8_t                 ucDummy19;\r
        #endif\r
        #if ( configSUPPORT_STATIC_ALLOCATION == 1 )\r
                uint8_t                 uxDummy20;\r
index b736b6010881bca898c47b177ba9937d985f0da1..182d359125c12e5b52f6f9e44a1b41f4bb082786 100644 (file)
@@ -185,14 +185,6 @@ typedef enum
        eNoTasksWaitingTimeout  /* No tasks are waiting for a timeout so it is safe to enter a sleep mode that can only be exited by an external interrupt. */\r
 } eSleepModeStatus;\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
  * Defines the priority used by the idle task.  This must not be modified.\r
  *\r
@@ -2105,7 +2097,7 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xIte
  * indefinitely, whereas vTaskPlaceOnEventList() does.\r
  *\r
  */\r
-void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;\r
+void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE.  IT IS AN\r
index d65e91698356579e6b71f9d23b962ee1a26e69db..3dcb0049e342140069cba1af7b5ee4eb7df926cc 100644 (file)
@@ -129,6 +129,11 @@ deleted. */
 #define taskSTATICALLY_ALLOCATED_STACK ( ( uint8_t ) 0x01 )\r
 #define taskSTATICALLY_ALLOCATED_TCB   ( ( uint8_t ) 0x02 )\r
 \r
+/* Values that can be assigned to the ucNotifyState member of the TCB. */\r
+#define taskNOT_WAITING_NOTIFICATION   ( ( uint8_t ) 0 )\r
+#define taskWAITING_NOTIFICATION               ( ( uint8_t ) 1 )\r
+#define taskNOTIFICATION_RECEIVED              ( ( uint8_t ) 2 )\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
@@ -174,7 +179,7 @@ typedef struct tskTaskControlBlock
                void *pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];\r
        #endif\r
 \r
-       #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+       #if( configGENERATE_RUN_TIME_STATS == 1 )\r
                uint32_t                ulRunTimeCounter;       /*< Stores the amount of time the task has spent in the Running state. */\r
        #endif\r
 \r
@@ -189,16 +194,16 @@ typedef struct tskTaskControlBlock
                struct  _reent xNewLib_reent;\r
        #endif\r
 \r
-       #if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
+       #if( configUSE_TASK_NOTIFICATIONS == 1 )\r
                volatile uint32_t ulNotifiedValue;\r
-               volatile eNotifyValue eNotifyState;\r
+               volatile uint8_t ucNotifyState;\r
        #endif\r
 \r
        #if ( configSUPPORT_STATIC_ALLOCATION == 1 )\r
                uint8_t         ucStaticAllocationFlags; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */\r
        #endif\r
 \r
-       } tskTCB;\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
@@ -489,7 +494,7 @@ 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( const TickType_t xTimeToWake ) PRIVILEGED_FUNCTION;\r
+static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, const BaseType_t xCanBlockIndefinitely ) PRIVILEGED_FUNCTION;\r
 \r
 /*\r
  * Allocates memory from the heap for a TCB and associated stack.  Checks the\r
@@ -615,7 +620,7 @@ StackType_t *pxTopOfStack;
                        /* 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
                        other extreme of the stack space. */\r
-                       pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );\r
+                       pxNewTCB->pxEndOfStack = pxNewTCB->pxStack + ( usStackDepth - ( uint16_t ) 1 );\r
                }\r
                #endif /* portSTACK_GROWTH */\r
 \r
@@ -889,23 +894,11 @@ StackType_t *pxTopOfStack;
 \r
                        if( xShouldDelay != pdFALSE )\r
                        {\r
-                               traceTASK_DELAY_UNTIL();\r
+                               traceTASK_DELAY_UNTIL( xTimeToWake );\r
 \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
+                               /* prvAddCurrentTaskToDelayedList() needs the block time, not\r
+                               the time to wake, so subtract the current tick count. */\r
+                               prvAddCurrentTaskToDelayedList( xTimeToWake - xConstTickCount, pdFALSE );\r
                        }\r
                        else\r
                        {\r
@@ -933,10 +926,8 @@ StackType_t *pxTopOfStack;
 \r
        void vTaskDelay( const TickType_t xTicksToDelay )\r
        {\r
-       TickType_t xTimeToWake;\r
        BaseType_t xAlreadyYielded = pdFALSE;\r
 \r
-\r
                /* A delay time of zero just forces a reschedule. */\r
                if( xTicksToDelay > ( TickType_t ) 0U )\r
                {\r
@@ -952,26 +943,7 @@ StackType_t *pxTopOfStack;
 \r
                                This task cannot be in an event list as it is the currently\r
                                executing task. */\r
-\r
-                               /* Calculate the time to wake - this may overflow but this is\r
-                               not a problem. */\r
-                               xTimeToWake = xTickCount + xTicksToDelay;\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 ) ) == ( 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
+                               prvAddCurrentTaskToDelayedList( xTicksToDelay, pdFALSE );\r
                        }\r
                        xAlreadyYielded = xTaskResumeAll();\r
                }\r
@@ -2447,8 +2419,6 @@ void vTaskSwitchContext( void )
 \r
 void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait )\r
 {\r
-TickType_t xTimeToWake;\r
-\r
        configASSERT( pxEventList );\r
 \r
        /* THIS FUNCTION MUST BE CALLED WITH EITHER INTERRUPTS DISABLED OR THE\r
@@ -2460,54 +2430,12 @@ TickType_t xTimeToWake;
        list is locked, preventing simultaneous access from interrupts. */\r
        vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
 \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 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\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
-       }\r
-       #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, the scheduler\r
-                       will handle it. */\r
-                       xTimeToWake = xTickCount + xTicksToWait;\r
-                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
-       }\r
-       #endif /* INCLUDE_vTaskSuspend */\r
+       prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait )\r
 {\r
-TickType_t xTimeToWake;\r
-\r
        configASSERT( pxEventList );\r
 \r
        /* THIS FUNCTION MUST BE CALLED WITH THE SCHEDULER SUSPENDED.  It is used by\r
@@ -2526,56 +2454,14 @@ TickType_t xTimeToWake;
        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 ) ) == ( 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 the task to the suspended task list instead of a delayed task\r
-                       list to ensure it is not 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 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
-       }\r
-       #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, the kernel\r
-                       will manage it correctly. */\r
-                       xTimeToWake = xTickCount + xTicksToWait;\r
-                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
-       }\r
-       #endif /* INCLUDE_vTaskSuspend */\r
+       prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-#if configUSE_TIMERS == 1\r
+#if( configUSE_TIMERS == 1 )\r
 \r
-       void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )\r
+       void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )\r
        {\r
-       TickType_t xTimeToWake;\r
-\r
                configASSERT( pxEventList );\r
 \r
                /* This function should not be called by application code hence the\r
@@ -2590,59 +2476,16 @@ TickType_t xTimeToWake;
                can be used in place of vListInsert. */\r
                vListInsertEnd( pxEventList, &( pxCurrentTCB->xEventListItem ) );\r
 \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 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
-               /* If vTaskSuspend() is available then the suspended task list is also\r
-               available and a task that is blocking indefinitely can enter the\r
-               suspended state (it is not really suspended as it will re-enter the\r
-               Ready state when the event it is waiting indefinitely for occurs).\r
-               Blocking indefinitely is useful when using tickless idle mode as when\r
-               all tasks are blocked indefinitely all timers can be turned off. */\r
-               #if( INCLUDE_vTaskSuspend == 1 )\r
+               /* If the task should block indefinitely then set the block time to a\r
+               value that will be recognised as an indefinite delay inside the\r
+               prvAddCurrentTaskToDelayedList() function. */\r
+               if( xWaitIndefinitely == pdTRUE )\r
                {\r
-                       if( xWaitIndefinitely == pdTRUE )\r
-                       {\r
-                               /* Add the task to the suspended task list instead of a delayed\r
-                               task list to ensure the task is not woken by a timing event.  It\r
-                               will block indefinitely. */\r
-                               vListInsertEnd( &xSuspendedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
-                       }\r
-                       else\r
-                       {\r
-                               /* Calculate the time at which the task should be woken if the\r
-                               event does not occur.  This may overflow but this doesn't\r
-                               matter. */\r
-                               xTimeToWake = xTickCount + xTicksToWait;\r
-                               traceTASK_DELAY_UNTIL();\r
-                               prvAddCurrentTaskToDelayedList( xTimeToWake );\r
-                       }\r
+                       xTicksToWait = portMAX_DELAY;\r
                }\r
-               #else\r
-               {\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. */\r
-                       xTimeToWake = xTickCount + xTicksToWait;\r
-                       traceTASK_DELAY_UNTIL();\r
-                       prvAddCurrentTaskToDelayedList( xTimeToWake );\r
 \r
-                       /* Remove compiler warnings when INCLUDE_vTaskSuspend() is not\r
-                       defined. */\r
-                       ( void ) xWaitIndefinitely;\r
-               }\r
-               #endif\r
+               traceTASK_DELAY_UNTIL( ( xTickCount + xTicksToWait ) );\r
+               prvAddCurrentTaskToDelayedList( xTicksToWait, xWaitIndefinitely );\r
        }\r
 \r
 #endif /* configUSE_TIMERS */\r
@@ -2782,9 +2625,9 @@ BaseType_t xReturn;
                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
-                       the maximum block time then the task should block indefinitely, and\r
-                       therefore never time out. */\r
+                       /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified\r
+                       is the maximum block time then the task should block indefinitely,\r
+                       and therefore never time out. */\r
                        if( *pxTicksToWait == portMAX_DELAY )\r
                        {\r
                                xReturn = pdFALSE;\r
@@ -2794,16 +2637,17 @@ BaseType_t xReturn;
 \r
                if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xConstTickCount >= pxTimeOut->xTimeOnEntering ) ) /*lint !e525 Indentation preferred as is to make code within pre-processor directives clearer. */\r
                {\r
-                       /* The tick count is greater than the time at which vTaskSetTimeout()\r
-                       was called, but has also overflowed since vTaskSetTimeOut() was called.\r
-                       It must have wrapped all the way around and gone past us again. This\r
-                       passed since vTaskSetTimeout() was called. */\r
+                       /* The tick count is greater than the time at which\r
+                       vTaskSetTimeout() was called, but has also overflowed since\r
+                       vTaskSetTimeOut() was called.  It must have wrapped all the way\r
+                       around and gone past again. This passed since vTaskSetTimeout()\r
+                       was called. */\r
                        xReturn = pdTRUE;\r
                }\r
-               else if( ( xConstTickCount - pxTimeOut->xTimeOnEntering ) < *pxTicksToWait )\r
+               else if( ( ( TickType_t ) ( xConstTickCount - pxTimeOut->xTimeOnEntering ) ) < *pxTicksToWait )\r
                {\r
                        /* Not a genuine timeout. Adjust parameters for time remaining. */\r
-                       *pxTicksToWait -= ( xConstTickCount -  pxTimeOut->xTimeOnEntering );\r
+                       *pxTicksToWait -= ( xConstTickCount - pxTimeOut->xTimeOnEntering );\r
                        vTaskSetTimeOutState( pxTimeOut );\r
                        xReturn = pdFALSE;\r
                }\r
@@ -3117,7 +2961,7 @@ UBaseType_t x;
        #if ( configUSE_TASK_NOTIFICATIONS == 1 )\r
        {\r
                pxTCB->ulNotifiedValue = 0;\r
-               pxTCB->eNotifyState = eNotWaitingNotification;\r
+               pxTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;\r
        }\r
        #endif\r
 \r
@@ -3126,7 +2970,7 @@ UBaseType_t x;
                /* Initialise this task's Newlib reent structure. */\r
                _REENT_INIT_PTR( ( &( pxTCB->xNewLib_reent ) ) );\r
        }\r
-       #endif /* configUSE_NEWLIB_REENTRANT */\r
+       #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -3261,36 +3105,6 @@ static void prvCheckTasksWaitingTermination( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \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
-\r
-       if( xTimeToWake < xTickCount )\r
-       {\r
-               /* Wake time has overflowed.  Place this item in the overflow list. */\r
-               vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
-       }\r
-       else\r
-       {\r
-               /* The wake time has not overflowed, so the current block list is used. */\r
-               vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
-\r
-               /* If the task entering the blocked state was placed at the head of the\r
-               list of blocked tasks then xNextTaskUnblockTime needs to be updated\r
-               too. */\r
-               if( xTimeToWake < xNextTaskUnblockTime )\r
-               {\r
-                       xNextTaskUnblockTime = xTimeToWake;\r
-               }\r
-               else\r
-               {\r
-                       mtCOVERAGE_TEST_MARKER();\r
-               }\r
-       }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
 static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t * const puxStackBuffer, TCB_t * const pxTaskBuffer )\r
 {\r
 TCB_t *pxNewTCB;\r
@@ -4190,7 +4004,6 @@ TickType_t uxReturn;
 \r
        uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait )\r
        {\r
-       TickType_t xTimeToWake;\r
        uint32_t ulReturn;\r
 \r
                taskENTER_CRITICAL();\r
@@ -4199,55 +4012,11 @@ TickType_t uxReturn;
                        if( pxCurrentTCB->ulNotifiedValue == 0UL )\r
                        {\r
                                /* Mark this task as waiting for a notification. */\r
-                               pxCurrentTCB->eNotifyState = eWaitingNotification;\r
+                               pxCurrentTCB->ucNotifyState = taskWAITING_NOTIFICATION;\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
+                                       prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE );\r
                                        traceTASK_NOTIFY_TAKE_BLOCK();\r
 \r
                                        /* All ports are written to allow a yield in a critical\r
@@ -4289,7 +4058,7 @@ TickType_t uxReturn;
                                mtCOVERAGE_TEST_MARKER();\r
                        }\r
 \r
-                       pxCurrentTCB->eNotifyState = eNotWaitingNotification;\r
+                       pxCurrentTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;\r
                }\r
                taskEXIT_CRITICAL();\r
 \r
@@ -4303,13 +4072,12 @@ TickType_t uxReturn;
 \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
+                       if( pxCurrentTCB->ucNotifyState != taskNOTIFICATION_RECEIVED )\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
@@ -4317,55 +4085,11 @@ TickType_t uxReturn;
                                pxCurrentTCB->ulNotifiedValue &= ~ulBitsToClearOnEntry;\r
 \r
                                /* Mark this task as waiting for a notification. */\r
-                               pxCurrentTCB->eNotifyState = eWaitingNotification;\r
+                               pxCurrentTCB->ucNotifyState = taskWAITING_NOTIFICATION;\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
+                                       prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE );\r
                                        traceTASK_NOTIFY_WAIT_BLOCK();\r
 \r
                                        /* All ports are written to allow a yield in a critical\r
@@ -4397,11 +4121,11 @@ TickType_t uxReturn;
                                *pulNotificationValue = pxCurrentTCB->ulNotifiedValue;\r
                        }\r
 \r
-                       /* If eNotifyValue is set then either the task never entered the\r
+                       /* If ucNotifyValue 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
+                       if( pxCurrentTCB->ucNotifyState == taskWAITING_NOTIFICATION )\r
                        {\r
                                /* A notification was not received. */\r
                                xReturn = pdFALSE;\r
@@ -4414,7 +4138,7 @@ TickType_t uxReturn;
                                xReturn = pdTRUE;\r
                        }\r
 \r
-                       pxCurrentTCB->eNotifyState = eNotWaitingNotification;\r
+                       pxCurrentTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;\r
                }\r
                taskEXIT_CRITICAL();\r
 \r
@@ -4429,8 +4153,8 @@ TickType_t uxReturn;
        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
+       uint8_t ucOriginalNotifyState;\r
 \r
                configASSERT( xTaskToNotify );\r
                pxTCB = ( TCB_t * ) xTaskToNotify;\r
@@ -4442,9 +4166,9 @@ TickType_t uxReturn;
                                *pulPreviousNotificationValue = pxTCB->ulNotifiedValue;\r
                        }\r
 \r
-                       eOriginalNotifyState = pxTCB->eNotifyState;\r
+                       ucOriginalNotifyState = pxTCB->ucNotifyState;\r
 \r
-                       pxTCB->eNotifyState = eNotified;\r
+                       pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED;\r
 \r
                        switch( eAction )\r
                        {\r
@@ -4461,7 +4185,7 @@ TickType_t uxReturn;
                                        break;\r
 \r
                                case eSetValueWithoutOverwrite :\r
-                                       if( eOriginalNotifyState != eNotified )\r
+                                       if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED )\r
                                        {\r
                                                pxTCB->ulNotifiedValue = ulValue;\r
                                        }\r
@@ -4482,7 +4206,7 @@ TickType_t uxReturn;
 \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
+                       if( ucOriginalNotifyState == taskWAITING_NOTIFICATION )\r
                        {\r
                                ( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
                                prvAddTaskToReadyList( pxTCB );\r
@@ -4535,7 +4259,7 @@ TickType_t uxReturn;
        BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue, BaseType_t *pxHigherPriorityTaskWoken )\r
        {\r
        TCB_t * pxTCB;\r
-       eNotifyValue eOriginalNotifyState;\r
+       uint8_t ucOriginalNotifyState;\r
        BaseType_t xReturn = pdPASS;\r
        UBaseType_t uxSavedInterruptStatus;\r
 \r
@@ -4568,8 +4292,8 @@ TickType_t uxReturn;
                                *pulPreviousNotificationValue = pxTCB->ulNotifiedValue;\r
                        }\r
 \r
-                       eOriginalNotifyState = pxTCB->eNotifyState;\r
-                       pxTCB->eNotifyState = eNotified;\r
+                       ucOriginalNotifyState = pxTCB->ucNotifyState;\r
+                       pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED;\r
 \r
                        switch( eAction )\r
                        {\r
@@ -4586,7 +4310,7 @@ TickType_t uxReturn;
                                        break;\r
 \r
                                case eSetValueWithoutOverwrite :\r
-                                       if( eOriginalNotifyState != eNotified )\r
+                                       if( ucOriginalNotifyState != taskNOTIFICATION_RECEIVED )\r
                                        {\r
                                                pxTCB->ulNotifiedValue = ulValue;\r
                                        }\r
@@ -4607,7 +4331,7 @@ TickType_t uxReturn;
 \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
+                       if( ucOriginalNotifyState == taskWAITING_NOTIFICATION )\r
                        {\r
                                /* The task should not have been on an event list. */\r
                                configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
@@ -4659,7 +4383,7 @@ TickType_t uxReturn;
        void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, BaseType_t *pxHigherPriorityTaskWoken )\r
        {\r
        TCB_t * pxTCB;\r
-       eNotifyValue eOriginalNotifyState;\r
+       uint8_t ucOriginalNotifyState;\r
        UBaseType_t uxSavedInterruptStatus;\r
 \r
                configASSERT( xTaskToNotify );\r
@@ -4686,8 +4410,8 @@ TickType_t uxReturn;
 \r
                uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
                {\r
-                       eOriginalNotifyState = pxTCB->eNotifyState;\r
-                       pxTCB->eNotifyState = eNotified;\r
+                       ucOriginalNotifyState = pxTCB->ucNotifyState;\r
+                       pxTCB->ucNotifyState = taskNOTIFICATION_RECEIVED;\r
 \r
                        /* 'Giving' is equivalent to incrementing a count in a counting\r
                        semaphore. */\r
@@ -4697,7 +4421,7 @@ TickType_t uxReturn;
 \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
+                       if( ucOriginalNotifyState == taskWAITING_NOTIFICATION )\r
                        {\r
                                /* The task should not have been on an event list. */\r
                                configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
@@ -4756,9 +4480,9 @@ TickType_t uxReturn;
 \r
                taskENTER_CRITICAL();\r
                {\r
-                       if( pxTCB->eNotifyState == eNotified )\r
+                       if( pxTCB->ucNotifyState == taskNOTIFICATION_RECEIVED )\r
                        {\r
-                               pxTCB->eNotifyState = eNotWaitingNotification;\r
+                               pxTCB->ucNotifyState = taskNOT_WAITING_NOTIFICATION;\r
                                xReturn = pdPASS;\r
                        }\r
                        else\r
@@ -4775,6 +4499,109 @@ TickType_t uxReturn;
 /*-----------------------------------------------------------*/\r
 \r
 \r
+static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait, BaseType_t xCanBlockIndefinitely )\r
+{\r
+TickType_t xTimeToWake;\r
+\r
+       /* Remove the task from the ready list before adding it to the blocked list\r
+       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 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
+\r
+       #if ( INCLUDE_vTaskSuspend == 1 )\r
+       {\r
+               if( ( xTicksToWait == portMAX_DELAY ) && ( xCanBlockIndefinitely != pdFALSE ) )\r
+               {\r
+                       /* Add the task to the suspended task list instead of a delayed task\r
+                       list to ensure it is not 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 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
+\r
+                       /* The list item will be inserted in wake time order. */\r
+                       listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );\r
+\r
+                       if( xTimeToWake < xTickCount )\r
+                       {\r
+                               /* Wake time has overflowed.  Place this item in the overflow\r
+                               list. */\r
+                               vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+                       }\r
+                       else\r
+                       {\r
+                               /* The wake time has not overflowed, so the current block list\r
+                               is used. */\r
+                               vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+\r
+                               /* If the task entering the blocked state was placed at the\r
+                               head of the list of blocked tasks then xNextTaskUnblockTime\r
+                               needs to be updated too. */\r
+                               if( xTimeToWake < xNextTaskUnblockTime )\r
+                               {\r
+                                       xNextTaskUnblockTime = xTimeToWake;\r
+                               }\r
+                               else\r
+                               {\r
+                                       mtCOVERAGE_TEST_MARKER();\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       #else /* INCLUDE_vTaskSuspend */\r
+       {\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 kernel\r
+               will manage it correctly. */\r
+               xTimeToWake = xTickCount + xTicksToWait;\r
+\r
+               /* The list item will be inserted in wake time order. */\r
+               listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );\r
+\r
+               if( xTimeToWake < xTickCount )\r
+               {\r
+                       /* Wake time has overflowed.  Place this item in the overflow list. */\r
+                       vListInsert( pxOverflowDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+               }\r
+               else\r
+               {\r
+                       /* The wake time has not overflowed, so the current block list is used. */\r
+                       vListInsert( pxDelayedTaskList, &( pxCurrentTCB->xGenericListItem ) );\r
+\r
+                       /* If the task entering the blocked state was placed at the head of the\r
+                       list of blocked tasks then xNextTaskUnblockTime needs to be updated\r
+                       too. */\r
+                       if( xTimeToWake < xNextTaskUnblockTime )\r
+                       {\r
+                               xNextTaskUnblockTime = xTimeToWake;\r
+                       }\r
+                       else\r
+                       {\r
+                               mtCOVERAGE_TEST_MARKER();\r
+                       }\r
+               }\r
+\r
+               /* Avoid compiler warning when INCLUDE_vTaskSuspend is not 1. */\r
+               ( void ) xCanBlockIndefinitely;\r
+       }\r
+       #endif /* INCLUDE_vTaskSuspend */\r
+}\r
+\r
+\r
 #ifdef FREERTOS_MODULE_TEST\r
        #include "tasks_test_access_functions.h"\r
 #endif\r