forked from Rativel/BurritOS
Implement Thread::start and join
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user