Skip to content

Commit 53c7e7c

Browse files
authored
Reset xNextTaskUnblockTime in task notify FromISR APIs (#1111)
* 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 <[email protected]>
1 parent d750173 commit 53c7e7c

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
@@ -8080,6 +8080,22 @@ TickType_t uxTaskResetEventItemValue( void )
80808080
{
80818081
listREMOVE_ITEM( &( pxTCB->xStateListItem ) );
80828082
prvAddTaskToReadyList( pxTCB );
8083+
8084+
#if ( configUSE_TICKLESS_IDLE != 0 )
8085+
{
8086+
/* If a task is blocked waiting for a notification then
8087+
* xNextTaskUnblockTime might be set to the blocked task's time
8088+
* out time. If the task is unblocked for a reason other than
8089+
* a timeout xNextTaskUnblockTime is normally left unchanged,
8090+
* because it will automatically get reset to a new value when
8091+
* the tick count equals xNextTaskUnblockTime. However if
8092+
* tickless idling is used it might be more important to enter
8093+
* sleep mode at the earliest possible time - so reset
8094+
* xNextTaskUnblockTime here to ensure it is updated at the
8095+
* earliest possible time. */
8096+
prvResetNextTaskUnblockTime();
8097+
}
8098+
#endif
80838099
}
80848100
else
80858101
{
@@ -8198,6 +8214,22 @@ TickType_t uxTaskResetEventItemValue( void )
81988214
{
81998215
listREMOVE_ITEM( &( pxTCB->xStateListItem ) );
82008216
prvAddTaskToReadyList( pxTCB );
8217+
8218+
#if ( configUSE_TICKLESS_IDLE != 0 )
8219+
{
8220+
/* If a task is blocked waiting for a notification then
8221+
* xNextTaskUnblockTime might be set to the blocked task's time
8222+
* out time. If the task is unblocked for a reason other than
8223+
* a timeout xNextTaskUnblockTime is normally left unchanged,
8224+
* because it will automatically get reset to a new value when
8225+
* the tick count equals xNextTaskUnblockTime. However if
8226+
* tickless idling is used it might be more important to enter
8227+
* sleep mode at the earliest possible time - so reset
8228+
* xNextTaskUnblockTime here to ensure it is updated at the
8229+
* earliest possible time. */
8230+
prvResetNextTaskUnblockTime();
8231+
}
8232+
#endif
82018233
}
82028234
else
82038235
{

0 commit comments

Comments
 (0)