rustubs/
kthread.rs

1//! kernel threads
2pub mod meeseeks;
3pub use meeseeks::Meeseeks;
4
5pub mod echo;
6pub use echo::Echo;
7
8pub mod lazy;
9pub use lazy::Lazy;
10
11pub mod kshell;
12pub use kshell::Kshell;
13
14use crate::proc::sync::LEAVE_L2;
15
16pub trait KThread {
17	fn entry() -> !;
18	/// the actual entry, where we also explicitly release L2
19	extern "C" fn _entry() {
20		LEAVE_L2();
21		Self::entry();
22	}
23	fn get_entry() -> u64 { Self::_entry as u64 }
24}
25
26pub struct Idle {}
27impl KThread for Idle {
28	fn entry() -> ! {
29		use core::arch::asm;
30		loop {
31			unsafe { asm!("sti; hlt") };
32		}
33	}
34}