chore: objects: tcb: unify names about time to time_tick

This commit is contained in:
Paul Pan 2024-05-20 16:27:04 +08:00
parent 32e21b3468
commit b37fef3e26
3 changed files with 19 additions and 19 deletions

View File

@ -32,7 +32,7 @@ pub struct TcbObject {
// TODO: add reply, buffer, fault, caller ... priority, dom
state: ThreadState,
time_slice: usize,
time_tick: usize,
pub link: Link<Self>,
}
@ -45,7 +45,7 @@ impl TcbObject {
cspace: CapEntry::new(NullCap::mint()),
vspace: CapEntry::new(NullCap::mint()),
state: ThreadState::Inactive,
time_slice: 0,
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) {

View File

@ -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