From b8471ba5660f90af15e3dd7556d3923c90ae0711 Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Mon, 5 Aug 2024 14:57:48 +0530 Subject: [PATCH 1/2] 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 --- tasks.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tasks.c b/tasks.c index b5ab5ad59e..a0bdabea15 100644 --- a/tasks.c +++ b/tasks.c @@ -8059,6 +8059,22 @@ TickType_t uxTaskResetEventItemValue( void ) { listREMOVE_ITEM( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); + + #if ( configUSE_TICKLESS_IDLE != 0 ) + { + /* If a task is blocked waiting for a notification then + * xNextTaskUnblockTime might be set to the blocked task's time + * out 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 idling is used it might be more important to enter + * sleep mode at the earliest possible time - so reset + * xNextTaskUnblockTime here to ensure it is updated at the + * earliest possible time. */ + prvResetNextTaskUnblockTime(); + } + #endif } else { @@ -8177,6 +8193,22 @@ TickType_t uxTaskResetEventItemValue( void ) { listREMOVE_ITEM( &( pxTCB->xStateListItem ) ); prvAddTaskToReadyList( pxTCB ); + + #if ( configUSE_TICKLESS_IDLE != 0 ) + { + /* If a task is blocked waiting for a notification then + * xNextTaskUnblockTime might be set to the blocked task's time + * out 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 idling is used it might be more important to enter + * sleep mode at the earliest possible time - so reset + * xNextTaskUnblockTime here to ensure it is updated at the + * earliest possible time. */ + prvResetNextTaskUnblockTime(); + } + #endif } else { From f6190bef9984871cb8c0dc63d42042a4168bacf0 Mon Sep 17 00:00:00 2001 From: Gaurav Aggarwal Date: Mon, 5 Aug 2024 18:09:03 +0000 Subject: [PATCH 2/2] Trigger Sonar