mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
feat: kernel/objects/tcb: rewrite schedulable and add schedule_next
This commit is contained in:
parent
60d9b10300
commit
66386aa00b
@ -1,4 +1,5 @@
|
||||
use crate::arch::{layout::mmap_phys_to_virt, trap::TrapContext, vspace::*};
|
||||
use crate::scheduler::SCHEDULER;
|
||||
use crate::syscall::handle_syscall;
|
||||
use crate::{objects::*, plat::trap::TrapContextOps, vspace::*};
|
||||
use core::fmt::Debug;
|
||||
@ -98,7 +99,15 @@ impl TcbObject {
|
||||
}
|
||||
|
||||
pub fn schedulable(&self) -> bool {
|
||||
self.state != ThreadState::Blocked && self.state != ThreadState::Inactive
|
||||
match self.state {
|
||||
ThreadState::Idle | ThreadState::Running => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn schedule_next(&self) {
|
||||
self.sched_queue.detach();
|
||||
SCHEDULER.add_next(self);
|
||||
}
|
||||
|
||||
pub fn set_state(&mut self, state: ThreadState) {
|
||||
|
Loading…
Reference in New Issue
Block a user