Skip to content

refactor(scheduler): remove the execution_ensured parameter of Scheduler::get_next() and get_next_task() - #816

Open
ytakano wants to merge 1 commit into
tier4:mainfrom
ytakano:refactor/remove-execution-ensured
Open

ytakano wants to merge 1 commit into
tier4:mainfrom
ytakano:refactor/remove-execution-ensured

Conversation

@ytakano

@ytakano ytakano commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Remove the execution_ensured parameter of Scheduler::get_next() and get_next_task().

After #809, get_next_task() is always called with execution_ensured == true, so the parameter and the false branches of the schedulers are dead code. The behavior does not change.

All paths are under awkernel_async_lib/src/.

  • scheduler.rs
    • Scheduler::get_next() and scheduler::get_next_task(): remove the parameter.
    • The doc of Scheduler::get_next_if() said "Unlike get_next(true)". It now says "Unlike get_next()".
    • The doc of Scheduler::get_next() now says that the dequeued task is marked as running on the calling CPU.
  • scheduler/prioritized_fifo.rs, scheduler/prioritized_rr.rs, scheduler/clustered.rs, scheduler/panicked.rs
    • get_next(): remove the parameter and the if execution_ensured { ... } condition, and keep its body.
  • task.rs
    • get_next_task(): remove the parameter and the if execution_ensured condition around set_current_task().
    • run_main(): call get_next_task() without the argument.

Related links

How was this PR tested?

  • scripts/ci.sh passes on my machine.

scripts/ci.sh was not run. The following were run instead.

  • make clippy: no warnings or errors on all targets.
  • cargo +nightly-2026-11-09 check_x86, check_std, check_rv32 and check_rv64 pass.
  • cargo +nightly-2026-11-09 test_awkernel_lib, test_awkernel_async_lib and test_awkernel_drivers pass. test_smoltcp and test_rd_gen_to_dags were not run.
  • make x86_64 RELEASE=1 builds.
  • QEMU x86_64 (16 CPUs, release build), no panic:
    • test_multi_prioritized_scheduler: all 15 low-priority tasks and all 15 high-priority tasks started and finished.
    • test_prioritized_rr: in about 57 seconds, each of the 24 high-priority tasks ran 505 to 518 times. The low-priority tasks did not run after the first second, as the test intends.

Notes for reviewers

…xt() (tier4#814)

After tier4#809, `get_next_task()` is always called with
`execution_ensured == true`, so the parameter and the `false` branches
of the schedulers are dead code.

Remove the parameter from `Scheduler::get_next()`,
`scheduler::get_next_task()`, and `task::get_next_task()`. The dequeued
task is now unconditionally marked as running. The behavior does not
change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@ytakano ytakano changed the title refactor(scheduler): remove the execution_ensured parameter of get_ne… refactor(scheduler): remove the execution_ensured parameter of Scheduler::get_next() and get_next_task() Nov 25, 2026
@ytakano
ytakano marked this pull request as ready for review November 25, 2026 09:39
set_current_task(awkernel_lib::cpu::cpu_id(), task.id);
}
task_info.state = State::Running;
set_current_task(awkernel_lib::cpu::cpu_id(), task.id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_next() binds cpu_id at the top, but this line calls awkernel_lib::cpu::cpu_id() again while three locks are held. On x86_64 that call runs CPUID and a linear search. Use set_current_task(cpu_id, task.id); instead.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the execution_ensured parameter of Scheduler::get_next() and `get_next_task()

2 participants