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
@ -13,7 +13,7 @@ pub struct RawCap {
|
|||||||
/// args: in vanilla seL4 implementation, a cap use two 64-bit words to store all information,
|
/// 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
|
/// but we'll waste some space rather than using bitfield to simplify the implementation
|
||||||
// TODO: use u64 rather than usize
|
// 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,
|
/// 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.
|
/// which limits the address space. Use an independent field to store the pointer.
|
||||||
/// Kernel will not manage memory, userspace should pass PhysAddr to kernel
|
/// Kernel will not manage memory, userspace should pass PhysAddr to kernel
|
||||||
|
@ -31,9 +31,9 @@ pub struct TcbObject {
|
|||||||
vspace: CapEntry,
|
vspace: CapEntry,
|
||||||
|
|
||||||
// TODO: add reply, buffer, fault, caller ... priority, dom
|
// TODO: add reply, buffer, fault, caller ... priority, dom
|
||||||
state: ThreadState,
|
state: ThreadState,
|
||||||
time_slice: usize,
|
time_tick: usize,
|
||||||
pub link: Link<Self>,
|
pub link: Link<Self>,
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkHelperImpl!(TcbObject:link);
|
LinkHelperImpl!(TcbObject:link);
|
||||||
@ -41,12 +41,12 @@ LinkHelperImpl!(TcbObject:link);
|
|||||||
impl TcbObject {
|
impl TcbObject {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
trapframe: TrapContext::default(),
|
trapframe: TrapContext::default(),
|
||||||
cspace: CapEntry::new(NullCap::mint()),
|
cspace: CapEntry::new(NullCap::mint()),
|
||||||
vspace: CapEntry::new(NullCap::mint()),
|
vspace: CapEntry::new(NullCap::mint()),
|
||||||
state: ThreadState::Inactive,
|
state: ThreadState::Inactive,
|
||||||
time_slice: 0,
|
time_tick: 0,
|
||||||
link: Link::default(),
|
link: Link::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,16 +55,16 @@ impl TcbObject {
|
|||||||
self.state = ThreadState::Idle;
|
self.state = ThreadState::Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn timeslice(&self) -> usize {
|
pub fn timetick(&self) -> usize {
|
||||||
self.time_slice
|
self.time_tick
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_timeslice(&mut self, timeslice: usize) {
|
pub fn set_timetick(&mut self, timeslice: usize) {
|
||||||
self.time_slice = timeslice;
|
self.time_tick = timeslice;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn timer_tick(&mut self) {
|
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) {
|
pub fn install_vspace(&self) {
|
||||||
|
@ -41,12 +41,12 @@ impl Scheduler {
|
|||||||
pub fn schedule(&self) {
|
pub fn schedule(&self) {
|
||||||
while let Some(next) = self.head.next_mut() {
|
while let Some(next) = self.head.next_mut() {
|
||||||
// TODO: also need to check whether it is schedulable
|
// TODO: also need to check whether it is schedulable
|
||||||
if next.timeslice() > 0 {
|
if next.timetick() > 0 {
|
||||||
// Available to run, activate it
|
// Available to run, activate it
|
||||||
next.activate();
|
next.activate();
|
||||||
} else if next.timeslice() == 0 {
|
} else if next.timetick() == 0 {
|
||||||
// No time left, refill timeslice and move to the end of the queue
|
// No time left, refill time tick and move to the end of the queue
|
||||||
next.set_timeslice(TIME_SLICE);
|
next.set_timetick(TIME_SLICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// put to the end of the queue
|
// put to the end of the queue
|
||||||
|
Loading…
Reference in New Issue
Block a user