From b37fef3e260488e079aeae6168e101f3c39d6372 Mon Sep 17 00:00:00 2001 From: Paul Pan Date: Mon, 20 May 2024 16:27:04 +0800 Subject: [PATCH] chore: objects: tcb: unify names about time to `time_tick` --- kernel/src/objects/cap.rs | 2 +- kernel/src/objects/tcb.rs | 28 ++++++++++++++-------------- kernel/src/scheduler.rs | 8 ++++---- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/kernel/src/objects/cap.rs b/kernel/src/objects/cap.rs index ce859e3..246c446 100644 --- a/kernel/src/objects/cap.rs +++ b/kernel/src/objects/cap.rs @@ -13,7 +13,7 @@ pub struct RawCap { /// args: in vanilla seL4 implementation, a cap use two 64-bit words to store all information, /// but we'll waste some space rather than using bitfield to simplify the implementation // TODO: use u64 rather than usize - pub args: [usize; 2], + pub args: [usize; 2], /// ptr: vanilla seL4 stores the pointer with either higher bits or lower bits cut off, /// which limits the address space. Use an independent field to store the pointer. /// Kernel will not manage memory, userspace should pass PhysAddr to kernel diff --git a/kernel/src/objects/tcb.rs b/kernel/src/objects/tcb.rs index bad0c05..771910a 100644 --- a/kernel/src/objects/tcb.rs +++ b/kernel/src/objects/tcb.rs @@ -31,9 +31,9 @@ pub struct TcbObject { vspace: CapEntry, // TODO: add reply, buffer, fault, caller ... priority, dom - state: ThreadState, - time_slice: usize, - pub link: Link, + state: ThreadState, + time_tick: usize, + pub link: Link, } LinkHelperImpl!(TcbObject:link); @@ -41,12 +41,12 @@ LinkHelperImpl!(TcbObject:link); impl TcbObject { pub fn new() -> Self { Self { - trapframe: TrapContext::default(), - cspace: CapEntry::new(NullCap::mint()), - vspace: CapEntry::new(NullCap::mint()), - state: ThreadState::Inactive, - time_slice: 0, - link: Link::default(), + trapframe: TrapContext::default(), + cspace: CapEntry::new(NullCap::mint()), + vspace: CapEntry::new(NullCap::mint()), + state: ThreadState::Inactive, + time_tick: 0, + link: Link::default(), } } @@ -55,16 +55,16 @@ impl TcbObject { self.state = ThreadState::Idle; } - pub fn timeslice(&self) -> usize { - self.time_slice + pub fn timetick(&self) -> usize { + self.time_tick } - pub fn set_timeslice(&mut self, timeslice: usize) { - self.time_slice = timeslice; + pub fn set_timetick(&mut self, timeslice: usize) { + self.time_tick = timeslice; } pub fn timer_tick(&mut self) { - self.time_slice = self.time_slice.saturating_sub(1); + self.time_tick = self.time_tick.saturating_sub(1); } pub fn install_vspace(&self) { diff --git a/kernel/src/scheduler.rs b/kernel/src/scheduler.rs index 52aa23e..9570ffc 100644 --- a/kernel/src/scheduler.rs +++ b/kernel/src/scheduler.rs @@ -41,12 +41,12 @@ impl Scheduler { pub fn schedule(&self) { while let Some(next) = self.head.next_mut() { // TODO: also need to check whether it is schedulable - if next.timeslice() > 0 { + if next.timetick() > 0 { // Available to run, activate it next.activate(); - } else if next.timeslice() == 0 { - // No time left, refill timeslice and move to the end of the queue - next.set_timeslice(TIME_SLICE); + } else if next.timetick() == 0 { + // No time left, refill time tick and move to the end of the queue + next.set_timetick(TIME_SLICE); } // put to the end of the queue