cleanup: replace magic TimeSlice::new(100) and Priority::new(16) with DEFAULT

TimeSlice::DEFAULT and Priority::DEFAULT already exist with the
same values. Using them makes the intent clear and centralizes
the default values.

TimeSlice::new(2) in tick test is intentional — tests preemption
after 2 ticks specifically.
This commit is contained in:
2026-10-18 22:41:29 +02:00
parent 06863c84fa
commit 73eed4e5b7
4 changed files with 7 additions and 7 deletions

View File

@@ -15,7 +15,7 @@ impl<P: Platform> Kernel<P> {
use domain::thread::SavedContext;
let priority = types::bounded::Priority::DEFAULT;
let time_slice = types::time::TimeSlice::new(100);
let time_slice = types::time::TimeSlice::DEFAULT;
let context = SavedContext::with_entry_and_stack(entry, stack);
let tid = match self.threads.spawn_with_context(pid, priority, time_slice, None, context) {
@@ -99,7 +99,7 @@ impl<P: Platform> Kernel<P> {
};
let priority = types::bounded::Priority::DEFAULT;
let time_slice = types::time::TimeSlice::new(100);
let time_slice = types::time::TimeSlice::DEFAULT;
let context = SavedContext::with_entry_and_stack(entry, stack);
let tid = match self.threads.spawn_with_context(target_pid, priority, time_slice, None, context) {

View File

@@ -23,7 +23,7 @@ pub fn test_kernel() -> Kernel<MockPlatform> {
pub fn kernel_with_process() -> (Kernel<MockPlatform>, ProcessId) {
let mut kernel = test_kernel();
let (pid, _tid) = kernel
.boot(Priority::new(16).unwrap(), TimeSlice::new(100))
.boot(Priority::DEFAULT, TimeSlice::DEFAULT)
.unwrap();
(kernel, pid)
}

View File

@@ -29,8 +29,8 @@ fn setup_ipc_kernel() -> (
let pid_b = ProcessId::from_raw(1);
let tid_b = k.spawn_thread_for_test(
pid_b,
Priority::new(16).unwrap(),
TimeSlice::new(100),
Priority::DEFAULT,
TimeSlice::DEFAULT,
);
// Create an endpoint

View File

@@ -18,10 +18,10 @@ fn tick_preempts_when_time_expired_and_other_thread_ready() {
let mut k = Kernel::new(mock, pool);
// Boot with quantum=2 so it expires after 2 ticks
let (pid, tid1) = k.boot(Priority::new(16).unwrap(), TimeSlice::new(2)).unwrap();
let (pid, tid1) = k.boot(Priority::DEFAULT, TimeSlice::new(2)).unwrap();
// Spawn a second thread so scheduler has someone to switch to
let tid2 = k.spawn_thread_for_test(pid, Priority::new(16).unwrap(), TimeSlice::new(100));
let tid2 = k.spawn_thread_for_test(pid, Priority::DEFAULT, TimeSlice::DEFAULT);
// First tick: time remaining
let d1 = k.handle_tick(CoreId::from_raw(0));