Skip to content

Commit b8471ba

Browse files
committed
Reset xNextTaskUnblockTime in task notify FromISR APIs
If a task is blocked waiting for a notification then xNextTaskUnblockTime might be set to the blocked task's timeout time. If the task is unblocked for a reason other than a timeout xNextTaskUnblockTime is normally left unchanged, because it will automatically get reset to a new value when the tick count equals xNextTaskUnblockTime. However if tickless idle is used it is important to enter sleep mode at the earliest possible time - so reset xNextTaskUnblockTime here to ensure it is updated at the earliest possible time. This was reported here - https://forums.freertos.org/t/the-vtaskgenericnotifygivefromisr-function-need-call-prvresetnexttaskunblocktime/21090 Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
1 parent fffed5e commit b8471ba

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tasks.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8059,6 +8059,22 @@ TickType_t uxTaskResetEventItemValue( void )
80598059
{
80608060
listREMOVE_ITEM( &( pxTCB->xStateListItem ) );
80618061
prvAddTaskToReadyList( pxTCB );
8062+
8063+
#if ( configUSE_TICKLESS_IDLE != 0 )
8064+
{
8065+
/* If a task is blocked waiting for a notification then
8066+
* xNextTaskUnblockTime might be set to the blocked task's time
8067+
* out time. If the task is unblocked for a reason other than
8068+
* a timeout xNextTaskUnblockTime is normally left unchanged,
8069+
* because it will automatically get reset to a new value when
8070+
* the tick count equals xNextTaskUnblockTime. However if
8071+
* tickless idling is used it might be more important to enter
8072+
* sleep mode at the earliest possible time - so reset
8073+
* xNextTaskUnblockTime here to ensure it is updated at the
8074+
* earliest possible time. */
8075+
prvResetNextTaskUnblockTime();
8076+
}
8077+
#endif
80628078
}
80638079
else
80648080
{
@@ -8177,6 +8193,22 @@ TickType_t uxTaskResetEventItemValue( void )
81778193
{
81788194
listREMOVE_ITEM( &( pxTCB->xStateListItem ) );
81798195
prvAddTaskToReadyList( pxTCB );
8196+
8197+
#if ( configUSE_TICKLESS_IDLE != 0 )
8198+
{
8199+
/* If a task is blocked waiting for a notification then
8200+
* xNextTaskUnblockTime might be set to the blocked task's time
8201+
* out time. If the task is unblocked for a reason other than
8202+
* a timeout xNextTaskUnblockTime is normally left unchanged,
8203+
* because it will automatically get reset to a new value when
8204+
* the tick count equals xNextTaskUnblockTime. However if
8205+
* tickless idling is used it might be more important to enter
8206+
* sleep mode at the earliest possible time - so reset
8207+
* xNextTaskUnblockTime here to ensure it is updated at the
8208+
* earliest possible time. */
8209+
prvResetNextTaskUnblockTime();
8210+
}
8211+
#endif
81808212
}
81818213
else
81828214
{

0 commit comments

Comments
 (0)