Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FreeRTOS/FreeRTOS-Kernel.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchinglee-iot <61685396+chinglee-iot@users.noreply.github.com>2023-01-24 11:25:36 +0300
committerGitHub <noreply@github.com>2023-01-24 11:25:36 +0300
commit0f9e6e5b521009f585018b47f7e8aa573f010206 (patch)
tree94ff100cfb99b90f5454e6a4376a2c469767aac4
parent8128208bdee1f997f83cae631b861f36aeea9b1f (diff)
Remove prvSelectHighestPriorityTask call in vTaskSuspend (#610)
* Remove prvSelectHighestPriorityTask call in vTaskSuspend * Every core starts with an idle task in SMP implementation and taskTASK_IS_RUNNING only return ture when the task is idle task before scheduler started. So prvSelectHighestPriorityTask won't be called in vTaskSuspend before scheduler started. * Update prvSelectHighestPriorityTask to ensure that this function is called only when scheduler started. * Fix kernel checker error
-rw-r--r--.github/workflows/kernel-checks.yml2
-rw-r--r--tasks.c62
2 files changed, 19 insertions, 45 deletions
diff --git a/.github/workflows/kernel-checks.yml b/.github/workflows/kernel-checks.yml
index b23b38f94..3fca2e0ec 100644
--- a/.github/workflows/kernel-checks.yml
+++ b/.github/workflows/kernel-checks.yml
@@ -11,7 +11,7 @@ jobs:
- name: Tool Setup
uses: actions/setup-python@v2
with:
- python-version: 3.7.10
+ python-version: 3.11.0
architecture: x64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/tasks.c b/tasks.c
index 842ef224e..fa01cba94 100644
--- a/tasks.c
+++ b/tasks.c
@@ -438,7 +438,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
/*
* Selects the highest priority available task
*/
-static BaseType_t prvSelectHighestPriorityTask( const BaseType_t xCoreID );
+static void prvSelectHighestPriorityTask( const BaseType_t xCoreID );
/**
* Utility task that simply returns pdTRUE if the task referenced by xTask is
@@ -819,7 +819,7 @@ static void prvYieldForTask( TCB_t * pxTCB,
#if ( configUSE_PORT_OPTIMISED_TASK_SELECTION == 0 )
- static BaseType_t prvSelectHighestPriorityTask( const BaseType_t xCoreID )
+ static void prvSelectHighestPriorityTask( const BaseType_t xCoreID )
{
UBaseType_t uxCurrentPriority = uxTopReadyPriority;
BaseType_t xTaskScheduled = pdFALSE;
@@ -832,6 +832,9 @@ static void prvYieldForTask( TCB_t * pxTCB,
BaseType_t xPriorityDropped = pdFALSE;
#endif
+ /* This function should be called when scheduler is running. */
+ configASSERT( xSchedulerRunning == pdTRUE );
+
while( xTaskScheduled == pdFALSE )
{
#if ( ( configRUN_MULTIPLE_PRIORITIES == 0 ) && ( configNUM_CORES > 1 ) )
@@ -947,14 +950,9 @@ static void prvYieldForTask( TCB_t * pxTCB,
}
}
- /* This function can get called by vTaskSuspend() before the scheduler is started.
- * In that case, since the idle tasks have not yet been created it is possible that we
- * won't find a new task to schedule. Return pdFALSE in this case. */
- if( ( xSchedulerRunning == pdFALSE ) && ( uxCurrentPriority == tskIDLE_PRIORITY ) && ( xTaskScheduled == pdFALSE ) )
- {
- return pdFALSE;
- }
-
+ /* Theare are configNUMBER_OF_CORES Idle tasks created when scheduler started.
+ * The scheduler should be able to select a task to run when uxCurrentPriority
+ * is tskIDLE_PRIORITY. */
configASSERT( ( uxCurrentPriority > tskIDLE_PRIORITY ) || ( xTaskScheduled == pdTRUE ) );
uxCurrentPriority--;
}
@@ -1034,8 +1032,6 @@ static void prvYieldForTask( TCB_t * pxTCB,
}
#endif /* if ( configUSE_CORE_AFFINITY == 1 ) */
#endif /* if ( configNUM_CORES > 1 ) */
-
- return pdTRUE;
}
#else /* configUSE_PORT_OPTIMISED_TASK_SELECTION */
@@ -2480,45 +2476,23 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
{
prvYieldCore( xTaskRunningOnCore );
}
-
- taskEXIT_CRITICAL();
}
else
{
- taskEXIT_CRITICAL();
-
- configASSERT( pxTCB == pxCurrentTCBs[ xTaskRunningOnCore ] );
-
- /* The scheduler is not running, but the task that was pointed
- * to by pxCurrentTCB has just been suspended and pxCurrentTCB
- * must be adjusted to point to a different task. */
- if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == uxCurrentNumberOfTasks ) /*lint !e931 Right has no side effect, just volatile. */
- {
- /* No other tasks are ready, so set the core's TCB back to
- * NULL so when the next task is created the core's TCB will
- * be able to be set to point to it no matter what its relative
- * priority is. */
- pxTCB->xTaskRunState = taskTASK_NOT_RUNNING;
- pxCurrentTCBs[ xTaskRunningOnCore ] = NULL;
- }
- else
- {
- /* Attempt to switch in a new task. This could fail since the idle tasks
- * haven't been created yet. If it does then set the core's TCB back to
- * NULL. */
- if( prvSelectHighestPriorityTask( xTaskRunningOnCore ) == pdFALSE )
- {
- pxTCB->xTaskRunState = taskTASK_NOT_RUNNING;
- pxCurrentTCBs[ xTaskRunningOnCore ] = NULL;
- }
- }
+ /* This code path is not possible because only Idle tasks are
+ * assigned a core before the scheduler is started ( i.e.
+ * taskTASK_IS_RUNNING is only true for idle tasks before
+ * the scheduler is started ) and idle tasks cannot be
+ * suspended. */
+ mtCOVERAGE_TEST_MARKER();
}
}
else
{
- taskEXIT_CRITICAL();
+ mtCOVERAGE_TEST_MARKER();
}
- } /* taskEXIT_CRITICAL() - already exited in one of three cases above */
+ }
+ taskEXIT_CRITICAL();
}
#endif /* INCLUDE_vTaskSuspend */
@@ -3940,7 +3914,7 @@ void vTaskSwitchContext( BaseType_t xCoreID )
/* Select a new task to run using either the generic C or port
* optimised asm code. */
- ( void ) prvSelectHighestPriorityTask( xCoreID );
+ prvSelectHighestPriorityTask( xCoreID );
traceTASK_SWITCHED_IN();
/* After the new task is switched in, update the global errno. */