MCPcopy Create free account
hub / github.com/FreeRTOS/FreeRTOS-Kernel / prvAddNewTaskToReadyList

Function prvAddNewTaskToReadyList

tasks.c:1584–1656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1582/*-----------------------------------------------------------*/
1583
1584static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
1585{
1586 /* Ensure interrupts don't access the task lists while the lists are being
1587 * updated. */
1588 taskENTER_CRITICAL();
1589 {
1590 uxCurrentNumberOfTasks++;
1591
1592 if( xSchedulerRunning == pdFALSE )
1593 {
1594 if( uxCurrentNumberOfTasks == ( UBaseType_t ) 1 )
1595 {
1596 /* This is the first task to be created so do the preliminary
1597 * initialisation required. We will not recover if this call
1598 * fails, but we will report the failure. */
1599 prvInitialiseTaskLists();
1600 }
1601 else
1602 {
1603 mtCOVERAGE_TEST_MARKER();
1604 }
1605
1606 if( pxNewTCB->xIsIdle != pdFALSE )
1607 {
1608 BaseType_t xCoreID;
1609
1610 /* Check if a core is free. */
1611 for( xCoreID = ( UBaseType_t ) 0; xCoreID < ( UBaseType_t ) configNUM_CORES; xCoreID++ )
1612 {
1613 if( pxCurrentTCBs[ xCoreID ] == NULL )
1614 {
1615 pxNewTCB->xTaskRunState = xCoreID;
1616 pxCurrentTCBs[ xCoreID ] = pxNewTCB;
1617 break;
1618 }
1619 }
1620 }
1621 }
1622 else
1623 {
1624 mtCOVERAGE_TEST_MARKER();
1625 }
1626
1627 uxTaskNumber++;
1628
1629 #if ( configUSE_TRACE_FACILITY == 1 )
1630 {
1631 /* Add a counter into the TCB for tracing only. */
1632 pxNewTCB->uxTCBNumber = uxTaskNumber;
1633 }
1634 #endif /* configUSE_TRACE_FACILITY */
1635 traceTASK_CREATE( pxNewTCB );
1636
1637 prvAddTaskToReadyList( pxNewTCB );
1638
1639 portSETUP_TCB( pxNewTCB );
1640
1641 if( xSchedulerRunning != pdFALSE )

Callers 4

xTaskCreateStaticFunction · 0.85
xTaskCreateRestrictedFunction · 0.85
xTaskCreateFunction · 0.85

Calls 2

prvInitialiseTaskListsFunction · 0.85
prvYieldForTaskFunction · 0.85

Tested by

no test coverage detected