#endif /* configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) */\r
\r
/* Sanity check the configuration. */\r
-#if configUSE_TICKLESS_IDLE != 0\r
- #if INCLUDE_vTaskSuspend != 1\r
+#if( configUSE_TICKLESS_IDLE != 0 )\r
+ #if( INCLUDE_vTaskSuspend != 1 )\r
#error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0\r
#endif /* INCLUDE_vTaskSuspend */\r
#endif /* configUSE_TICKLESS_IDLE */\r
\r
#if configUSE_TIMERS == 1\r
\r
- void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait )\r
+ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, const TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely )\r
{\r
TickType_t xTimeToWake;\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
- xTimeToWake = xTickCount + xTicksToWait;\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
+ {\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
+ }\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
- traceTASK_DELAY_UNTIL();\r
- prvAddCurrentTaskToDelayedList( xTimeToWake );\r
+ /* Remove compiler warnings when INCLUDE_vTaskSuspend() is not\r
+ defined. */\r
+ ( void ) xWaitIndefinitely;\r
+ }\r
+ #endif\r
}\r
\r
#endif /* configUSE_TIMERS */\r
xReturn = pdFALSE;\r
}\r
\r
- #if( configUSE_TICKLESS_IDLE == 1 )\r
+ #if( configUSE_TICKLESS_IDLE != 0 )\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
+ normally left unchanged, because it is automatically 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
}\r
/*-----------------------------------------------------------*/\r
\r
-#if configUSE_TICKLESS_IDLE != 0\r
+#if( configUSE_TICKLESS_IDLE != 0 )\r
\r
eSleepModeStatus eTaskConfirmSleepModeStatus( void )\r
{\r
+ /* The idle task exists in addition to the application tasks. */\r
+ const UBaseType_t uxNonApplicationTasks = 1;\r
eSleepModeStatus eReturn = eStandardSleep;\r
\r
if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 )\r
}\r
else\r
{\r
- #if configUSE_TIMERS == 0\r
+ /* If all the tasks are in the suspended list (which might mean they\r
+ have an infinite block time rather than actually being suspended)\r
+ then it is safe to turn all clocks off and just wait for external\r
+ interrupts. */\r
+ if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) )\r
{\r
- /* The idle task exists in addition to the application tasks. */\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
- time rather than actually being suspended) then it is safe to\r
- turn all clocks off and just wait for external interrupts. */\r
- if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) )\r
- {\r
- eReturn = eNoTasksWaitingTimeout;\r
- }\r
- else\r
- {\r
- mtCOVERAGE_TEST_MARKER();\r
- }\r
+ eReturn = eNoTasksWaitingTimeout;\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
}\r
- #endif /* configUSE_TIMERS */\r
}\r
\r
return eReturn;\r
}\r
+\r
#endif /* configUSE_TICKLESS_IDLE */\r
/*-----------------------------------------------------------*/\r
\r
{\r
TCB_t *pxTCB;\r
\r
- /* If null is passed in here then we are deleting ourselves. */\r
+ /* If null is passed in here then we are modifying the MPU settings of\r
+ the calling task. */\r
pxTCB = prvGetTCBFromHandle( xTaskToModify );\r
\r
vPortStoreTaskMPUSettings( &( pxTCB->xMPUSettings ), xRegions, NULL, 0 );\r
/* The task should not have been on an event list. */\r
configASSERT( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL );\r
\r
+ #if( configUSE_TICKLESS_IDLE != 0 )\r
+ {\r
+ /* If a task is blocked waiting for a notification then\r
+ xNextTaskUnblockTime might be set to the blocked task's time\r
+ out time. If the task is unblocked for a reason other than\r
+ a timeout xNextTaskUnblockTime is normally left unchanged,\r
+ because it will automatically get reset to a new value when\r
+ the tick count equals xNextTaskUnblockTime. However if\r
+ tickless idling is used it might be more important to enter\r
+ sleep mode at the earliest possible time - so reset\r
+ xNextTaskUnblockTime here to ensure it is updated at the\r
+ earliest possible time. */\r
+ prvResetNextTaskUnblockTime();\r
+ }\r
+ #endif\r
+\r
if( pxTCB->uxPriority > pxCurrentTCB->uxPriority )\r
{\r
/* The notified task has a priority above the currently\r