mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
chore: objects: tcb: unify names about time to time_tick
This commit is contained in:
parent
32e21b3468
commit
b37fef3e26
@ -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) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user