aboutsummaryrefslogtreecommitdiff
path: root/src/proc/sched.rs
diff options
context:
space:
mode:
authorTianhao Wang <shrik3@mailbox.org>2024-06-06 02:08:21 +0200
committerTianhao Wang <shrik3@mailbox.org>2024-06-11 15:17:14 +0200
commitd495a1745c83a8186bf1c6c531177887dd245436 (patch)
tree5ea93adceea22d7aa12eb0165fce80e458dd3864 /src/proc/sched.rs
parenta86f59b32eb86a1ccb94bf1e627c1115c3b6b217 (diff)
proc: basic infra for multithreading
including task and scheduler wrapper, context swap assembly, and some notes... The lifetime of task is tricky, I'll fix it later Signed-off-by: Tianhao Wang <shrik3@mailbox.org>
Diffstat (limited to 'src/proc/sched.rs')
-rw-r--r--src/proc/sched.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/proc/sched.rs b/src/proc/sched.rs
new file mode 100644
index 0000000..8e86c7f
--- /dev/null
+++ b/src/proc/sched.rs
@@ -0,0 +1,17 @@
+use crate::proc::task::*;
+use alloc::collections::linked_list::LinkedList;
+// TODO the lifetime here is pretty much broken. Fix this later
+pub struct Scheduler<'a> {
+ run_list: LinkedList<&'a Task>,
+}
+
+impl<'a> Scheduler<'a> {
+ #[inline]
+ pub fn pop_front(&mut self) -> Option<&Task> {
+ self.run_list.pop_front()
+ }
+ #[inline]
+ pub fn push_back(&mut self, t: &'a Task) {
+ self.run_list.push_back(t);
+ }
+}