Skip to content

Commit 94cb87a

Browse files
Assign idle task to each core before SMP scheduler start (FreeRTOS#945)
Co-authored-by: Rahul Kar <[email protected]>
1 parent 460e953 commit 94cb87a

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

tasks.c

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,29 +2108,9 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
21082108
mtCOVERAGE_TEST_MARKER();
21092109
}
21102110

2111-
if( ( pxNewTCB->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) != 0U )
2112-
{
2113-
BaseType_t xCoreID;
2114-
2115-
/* Check if a core is free. */
2116-
for( xCoreID = ( BaseType_t ) 0; xCoreID < ( BaseType_t ) configNUMBER_OF_CORES; xCoreID++ )
2117-
{
2118-
if( pxCurrentTCBs[ xCoreID ] == NULL )
2119-
{
2120-
pxNewTCB->xTaskRunState = xCoreID;
2121-
pxCurrentTCBs[ xCoreID ] = pxNewTCB;
2122-
break;
2123-
}
2124-
else
2125-
{
2126-
mtCOVERAGE_TEST_MARKER();
2127-
}
2128-
}
2129-
}
2130-
else
2131-
{
2132-
mtCOVERAGE_TEST_MARKER();
2133-
}
2111+
/* All the cores start with idle tasks before the SMP scheduler
2112+
* is running. Idle tasks are assigned to cores when they are
2113+
* created in prvCreateIdleTasks(). */
21342114
}
21352115

21362116
uxTaskNumber++;
@@ -3645,7 +3625,17 @@ static BaseType_t prvCreateIdleTasks( void )
36453625
}
36463626
else
36473627
{
3648-
mtCOVERAGE_TEST_MARKER();
3628+
#if ( configNUMBER_OF_CORES == 1 )
3629+
{
3630+
mtCOVERAGE_TEST_MARKER();
3631+
}
3632+
#else
3633+
{
3634+
/* Assign idle task to each core before SMP scheduler is running. */
3635+
xIdleTaskHandles[ xCoreID ]->xTaskRunState = xCoreID;
3636+
pxCurrentTCBs[ xCoreID ] = xIdleTaskHandles[ xCoreID ];
3637+
}
3638+
#endif
36493639
}
36503640
}
36513641

0 commit comments

Comments
 (0)