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

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

View File

@ -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<Self>,
state: ThreadState,
time_tick: usize,
pub link: Link<Self>,
}
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) {

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