1
0
forked from Rativel/BurritOS

Implement Thread::start and join

This commit is contained in:
Quentin Legot
2023-03-01 16:55:17 +01:00
parent 77e6d74b3b
commit 68ee179e12
6 changed files with 264 additions and 163 deletions

View File

@@ -1,10 +1,12 @@
use std::sync::Arc;
use crate::utility::list::List;
use crate::kernel::thread::Thread;
use crate::utility::system::{G_CURRENT_THREAD, G_THREAD_TO_BE_DESTROYED};
struct Scheduler {
ready_list: List<Thread>
pub struct Scheduler {
ready_list: List<Arc<Thread>>
}
impl Scheduler {
@@ -25,8 +27,8 @@ impl Scheduler {
/// ## Pamameter
///
/// **thread** is the thread to be put on the read list
pub fn ready_to_run(&mut self, thread: Thread) {
self.ready_list.push_back(thread);
pub fn ready_to_run(&mut self, thread: Arc<Thread>) {
self.ready_list.push(thread);
}
/// Return the next thread to be scheduled onto the CPU.
@@ -35,8 +37,8 @@ impl Scheduler {
/// Thread is removed from the ready list.
///
/// **return** Thread thread to be scheduled
pub fn find_next_to_run(&mut self) -> Option<Thread> {
self.ready_list.pop_back()
pub fn find_next_to_run(&mut self) -> Option<Arc<Thread>> {
self.ready_list.pop()
}
/// Dispatch the CPU to next_thread. Save the state of the old thread