Skip to content

Commit

Permalink
sched/sched: simplify the scheduling logic
Browse files Browse the repository at this point in the history
test:
We can use qemu for testing.
compiling
make distclean -j20; ./tools/configure.sh -l qemu-armv8a:nsh_smp ;make -j20 running
qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic -machine virt,virtualization=on,gic-version=3 -net none -chardev stdio,id=con,mux=on -serial chardev:con -mon chardev=con,mode=readline -kernel ./nuttx

We have also tested this patch on other ARM hardware platforms.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
  • Loading branch information
hujun260 committed May 4, 2024
1 parent 8ef7238 commit 7529be2
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions sched/sched/sched_addreadytorun.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
{
/* Yes.. that is the CPU we must use */

task_state = TSTATE_TASK_ASSIGNED;
cpu = btcb->cpu;
}
else
Expand All @@ -173,6 +174,7 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
* (possibly its IDLE task).
*/

task_state = TSTATE_TASK_READYTORUN;
cpu = nxsched_select_cpu(btcb->affinity);
}

Expand All @@ -191,24 +193,6 @@ bool nxsched_add_readytorun(FAR struct tcb_s *btcb)
task_state = TSTATE_TASK_RUNNING;
}

/* If it will not be running, but is locked to a CPU, then it will be in
* the assigned state.
*/

else if ((btcb->flags & TCB_FLAG_CPU_LOCKED) != 0)
{
task_state = TSTATE_TASK_ASSIGNED;
cpu = btcb->cpu;
}

/* Otherwise, it will be ready-to-run, but not not yet running */

else
{
task_state = TSTATE_TASK_READYTORUN;
cpu = 0; /* CPU does not matter */
}

/* If the selected state is TSTATE_TASK_RUNNING, then we would like to
* start running the task. Be we cannot do that if pre-emption is
* disabled. If the selected state is TSTATE_TASK_READYTORUN, then it
Expand Down

0 comments on commit 7529be2

Please sign in to comment.