*/\r
#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) ( 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
+priority order). However, it is occasionally borrowed for other purposes. It\r
+is important its value is not updated due to a task priority change while it is\r
+being used for another purpose. The following bit definition is used to inform\r
+the scheduler that the value should not be changed - in which case it is the\r
+responsibility of whichever module is using the value to ensure it gets set back\r
+to its original value when it is released. */\r
+#if configUSE_16_BIT_TICKS == 1\r
+ #define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x8000U\r
+#else\r
+ #define taskEVENT_LIST_ITEM_VALUE_IN_USE 0x80000000UL\r
+#endif\r
+\r
/* Callback function prototypes. --------------------------*/\r
-extern void vApplicationStackOverflowHook( xTaskHandle xTask, signed char *pcTaskName );\r
-extern void vApplicationTickHook( void );\r
+#if configCHECK_FOR_STACK_OVERFLOW > 0\r
+ extern void vApplicationStackOverflowHook( xTaskHandle xTask, signed char *pcTaskName );\r
+#endif\r
+\r
+#if configUSE_TICK_HOOK > 0\r
+ extern void vApplicationTickHook( void );\r
+#endif\r
\r
/* File private functions. --------------------------------*/\r
\r
}\r
#endif\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
+ /* 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
+ {\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
+ }\r
\r
/* If the task is in the blocked or suspended list we need do\r
nothing more than change it's priority variable. However, if\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 not\r
- slip, and that any delayed tasks are resumed at the correct time. */\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
{\r
while( uxPendedTicks > ( unsigned portBASE_TYPE ) 0U )\r
SCHEDULER SUSPENDED. */\r
\r
/* Store the item value in the event list item. */\r
- listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xEventListItem ), xItemValue );\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
SCHEDULER SUSPENDED. It can also be called from within an ISR. */\r
\r
/* Store the new item value in the event list. */\r
- listSET_LIST_ITEM_VALUE( pxEventListItem, xItemValue );\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
{\r
if( pxTCB->uxPriority < pxCurrentTCB->uxPriority )\r
{\r
- /* Adjust the mutex holder state to account for its new priority. */\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
+ /* 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
+ {\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
+ }\r
\r
/* If the task being modified is in the ready state it will need to\r
be moved into a new list. */\r
ready list. */\r
traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority );\r
pxTCB->uxPriority = pxTCB->uxBasePriority;\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
+\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
+ {\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
+ }\r
prvAddTaskToReadyList( pxTCB );\r
}\r
}\r
}\r
/*-----------------------------------------------------------*/\r
\r
+#ifdef FREERTOS_MODULE_TEST\r
+ #include "tasks_test_access_functions.h"\r
+#endif\r
\r