]> git.sur5r.net Git - freertos/commitdiff
Only check once before re-setting ready priority
authorgaurav-aws <gaurav-aws@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 3 Jul 2019 00:08:16 +0000 (00:08 +0000)
committergaurav-aws <gaurav-aws@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 3 Jul 2019 00:08:16 +0000 (00:08 +0000)
The macro taskRESET_READY_PRIORITY checks if the task being removed from the
ready list is the last one and only then resets the top ready priority
by calling portRESET_READY_PRIORITY. If we already know that it is the
last ready task being removed then there is no need to perform the check
again and the macro portRESET_READY_PRIORITY can be called directly. We were
doing the unnecessary check at two places and this commit fixes them.

This commit also increases the time period of check task to ensure that all
the demo tasks get a chance to run before the check is performed.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2670 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Demo/WIN32-MSVC/main_full.c
FreeRTOS/Source/tasks.c

index 5c241be4704fb576f91679b8b1b0bb15a8be92f9..3f19db32e89f18b5d905a58152d28d7f6d821670 100644 (file)
@@ -244,7 +244,7 @@ int main_full( void )
 static void prvCheckTask( void *pvParameters )\r
 {\r
 TickType_t xNextWakeTime;\r
-const TickType_t xCycleFrequency = pdMS_TO_TICKS( 2500UL );\r
+const TickType_t xCycleFrequency = pdMS_TO_TICKS( 4000UL );\r
 \r
        /* Just to remove compiler warning. */\r
        ( void ) pvParameters;\r
index 3274e830f185083789b6dbc8b6983bfeb7143d83..f15d1ddf5fd55cf383767e8a9bb692aee0d8b9dd 100644 (file)
@@ -1164,7 +1164,7 @@ static void prvAddNewTaskToReadyList( TCB_t *pxNewTCB )
                        being deleted. */\r
                        pxTCB = prvGetTCBFromHandle( xTaskToDelete );\r
 \r
-                       /* Remove task from the ready list. */\r
+                       /* Remove task from the ready/delayed list. */\r
                        if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )\r
                        {\r
                                taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
@@ -3981,7 +3981,10 @@ TCB_t *pxTCB;
                                {\r
                                        if( uxListRemove( &( pxMutexHolderTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )\r
                                        {\r
-                                               taskRESET_READY_PRIORITY( pxMutexHolderTCB->uxPriority );\r
+                                               /* It is known that the task is in its ready list so\r
+                                               there is no need to check again and the port level\r
+                                               reset macro can be called directly. */\r
+                                               portRESET_READY_PRIORITY( pxMutexHolderTCB->uxPriority, uxTopReadyPriority );\r
                                        }\r
                                        else\r
                                        {\r
@@ -4061,7 +4064,7 @@ TCB_t *pxTCB;
                                        the mutex.  If the mutex is held by a task then it cannot be\r
                                        given from an interrupt, and if a mutex is given by the\r
                                        holding task then it must be the running state task.  Remove\r
-                                       the holding task from the ready list. */\r
+                                       the holding task from the ready/delayed list. */\r
                                        if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )\r
                                        {\r
                                                taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
@@ -4182,7 +4185,10 @@ TCB_t *pxTCB;
                                        {\r
                                                if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )\r
                                                {\r
-                                                       taskRESET_READY_PRIORITY( pxTCB->uxPriority );\r
+                                                       /* It is known that the task is in its ready list so\r
+                                                       there is no need to check again and the port level\r
+                                                       reset macro can be called directly. */\r
+                                                       portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority );\r
                                                }\r
                                                else\r
                                                {\r