mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 21:34:07 +08:00
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:
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user