From a8a25d0062fbb557b71e3a7a567b1c85fb2e4720 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Sat, 28 Mar 2020 17:26:21 +0530 Subject: [PATCH] tasks.c: disable interrupts in critical section only if scheduler is started Behaviour of `vTaskEnterCritical` and `vTaskExitCritical` was asymmetrical, in the sense, if these APIs were invoked prior to scheduler start condition then one would disable interrupts but other would not re-enable again. This commit ensure that behaviour is symmetrical for pre-scheduler start condition. --- tasks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks.c b/tasks.c index d63f6ccfd..cd0ce5d91 100644 --- a/tasks.c +++ b/tasks.c @@ -4291,10 +4291,10 @@ static void prvResetNextTaskUnblockTime( void ) void vTaskEnterCritical( void ) { - portDISABLE_INTERRUPTS(); - if( xSchedulerRunning != pdFALSE ) { + portDISABLE_INTERRUPTS(); + ( pxCurrentTCB->uxCriticalNesting )++; /* This is not the interrupt safe version of the enter critical