pxDelayedTaskList = pxOverflowDelayedTaskList; \\r
pxOverflowDelayedTaskList = pxTemp; \\r
xNumOfOverflows++; \\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
- if( xTickCount >= xNextTaskUnblockTime ) test will pass until \\r
- there is an item in the delayed list. */ \\r
- xNextTaskUnblockTime = portMAX_DELAY; \\r
- } \\r
- else \\r
- { \\r
- /* The new current delayed list is not empty, get the value of \\r
- 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
- xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) ); \\r
- } \\r
+ prvResetNextTaskUnblockTime(); \\r
}\r
\r
/*-----------------------------------------------------------*/\r
\r
#endif\r
\r
+/*\r
+ * Set xNextTaskUnblockTime to the time at which the next Blocked state task\r
+ * will exit the Blocked state.\r
+ */\r
+static void prvResetNextTaskUnblockTime( void );\r
+\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
{\r
signed portBASE_TYPE xReturn;\r
\r
/* The pre-delete hook is primarily for the Windows simulator,\r
in which Windows specific clean up operations are performed,\r
- after which it is not possible to yield away from this task - \r
+ after which it is not possible to yield away from this task -\r
hence xYieldPending is used to latch that a context switch is\r
required. */\r
portPRE_TASK_DELETE_HOOK( pxTCB, &xYieldPending );\r
}\r
else\r
{\r
- /* Reset the next expected unblock time in case it referred to the task \r
- that has just been deleted. */\r
- pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
- xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) );\r
+ /* Reset the next expected unblock time in case it referred to\r
+ the task that has just been deleted. */\r
+ prvResetNextTaskUnblockTime();\r
}\r
}\r
}\r
\r
traceTASK_SUSPEND( pxTCB );\r
\r
- /* Remove task from the ready/delayed list and place in the \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
{\r
{\r
if( xSchedulerRunning != pdFALSE )\r
{\r
- /* A task other than the currently running task was suspended, reset\r
- the next expected unblock time in case it referred to the task that\r
- is now in the Suspended state. */\r
- pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxDelayedTaskList );\r
- xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) );\r
+ /* 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
}\r
}\r
}\r
taskSWITCH_DELAYED_LISTS();\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
+ /* 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
if( xConstTickCount >= xNextTaskUnblockTime )\r
{\r
{\r
if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE )\r
{\r
- /* The delayed list is empty. Set xNextTaskUnblockTime \r
- to the maximum possible value so it is extremely \r
- unlikely that the \r
+ /* The delayed list is empty. Set xNextTaskUnblockTime\r
+ to the maximum possible value so it is extremely\r
+ unlikely that the\r
if( xTickCount >= xNextTaskUnblockTime ) test will pass\r
next time through. */\r
xNextTaskUnblockTime = portMAX_DELAY;\r
}\r
else\r
{\r
- /* The delayed list is not empty, get the value of the \r
- 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
+ /* The delayed list is not empty, get the value of the\r
+ 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
xItemValue = listGET_LIST_ITEM_VALUE( &( pxTCB->xGenericListItem ) );\r
\r
if( xConstTickCount < xItemValue )\r
{\r
- /* It is not time to unblock this item yet, but the \r
- item value is the time at which the task at the head \r
- of the blocked list must be removed from the Blocked \r
- state - so record the item value in \r
+ /* It is not time to unblock this item yet, but the\r
+ item value is the time at which the task at the head\r
+ of the blocked list must be removed from the Blocked\r
+ state - so record the item value in\r
xNextTaskUnblockTime. */\r
xNextTaskUnblockTime = xItemValue;\r
break;\r
/* It is time to remove the item from the Blocked state. */\r
( void ) uxListRemove( &( pxTCB->xGenericListItem ) );\r
\r
- /* Is the task waiting on an event also? If so remove \r
+ /* Is the task waiting on an event also? If so remove\r
it from the event list. */\r
if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) != NULL )\r
{\r
list. */\r
prvAddTaskToReadyList( pxTCB );\r
\r
- /* A task being unblocked cannot cause an immediate \r
+ /* A task being unblocked cannot cause an immediate\r
context switch if preemption is turned off. */\r
#if ( configUSE_PREEMPTION == 1 )\r
{\r
- /* Preemption is on, but a context switch should \r
- only be performed if the unblocked task has a \r
- priority that is equal to or higher than the \r
+ /* Preemption is on, but a context switch should\r
+ only be performed if the unblocked task has a\r
+ priority that is equal to or higher than the\r
currently executing task. */\r
if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
{\r
#endif /* INCLUDE_vTaskDelete */\r
/*-----------------------------------------------------------*/\r
\r
+static void prvResetNextTaskUnblockTime( void )\r
+{\r
+tskTCB *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
+ if( xTickCount >= xNextTaskUnblockTime ) test will pass until\r
+ there is an item in the delayed list. */\r
+ xNextTaskUnblockTime = portMAX_DELAY;\r
+ }\r
+ else\r
+ {\r
+ /* The new current delayed list is not empty, get the value of\r
+ 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
+ xNextTaskUnblockTime = listGET_LIST_ITEM_VALUE( &( ( pxTCB )->xGenericListItem ) );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
#if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )\r
\r
xTaskHandle xTaskGetCurrentTaskHandle( void )\r