sched/sched: change [FIRST|LAST]_ASSIGNED_STATE to [FIRST|LAST]_READY_TO_RUN_STATE in nxsched_set_affinity

reason:
In smp, It's possible that in a scenario where CONFIG_SMP_DEFAULT_CPUSET is set to 1,
when taskA is created with a relatively low priority,
it gets added to the g_readytorun queue with an affinity of 0x1.
Meanwhile, CPUs 1~n are in an idle state.
Subsequently, when we attempt to change the affinity property of taskA using nxsched_set_affinity,
the scheduling mechanism might not be triggered due to the lack of a proper condition check.
This can result in taskA remaining unscheduled and therefore unable to run.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2024-08-12 11:12:56 +08:00
committed by Xiang Xiao
parent a96a4de19a
commit 76d2a9443b
+2 -2
View File
@@ -126,8 +126,8 @@ int nxsched_set_affinity(pid_t pid, size_t cpusetsize,
* First... is the task in an assigned task list?
*/
if (tcb->task_state >= FIRST_ASSIGNED_STATE &&
tcb->task_state <= LAST_ASSIGNED_STATE)
if (tcb->task_state >= FIRST_READY_TO_RUN_STATE &&
tcb->task_state <= LAST_READY_TO_RUN_STATE)
{
/* Yes... is the CPU associated with the assigned task in the new
* affinity mask?