Change var name to fit with rust conventions

This commit is contained in:
Quentin Legot 2023-03-01 11:16:21 +01:00
parent 4c8062905c
commit 792497b14c
3 changed files with 12 additions and 12 deletions

View File

@ -1,6 +1,6 @@
use crate::utility::list::List; use crate::utility::list::List;
use crate::kernel::thread::Thread; use crate::kernel::thread::Thread;
use crate::utility::system::{g_current_thread, g_thread_to_be_destroyed}; use crate::utility::system::{G_CURRENT_THREAD, G_THREAD_TO_BE_DESTROYED};
struct Scheduler<> { struct Scheduler<> {
@ -50,7 +50,7 @@ impl Scheduler {
/// ///
/// **next_thread** thread to dispatch to the CPU /// **next_thread** thread to dispatch to the CPU
pub fn switch_to(&self, next_thread: Thread) { pub fn switch_to(&self, next_thread: Thread) {
match g_current_thread.write() { match G_CURRENT_THREAD.write() {
Ok(mut current_thread) => { Ok(mut current_thread) => {
let old_thread = current_thread.as_mut().unwrap(); let old_thread = current_thread.as_mut().unwrap();
@ -63,7 +63,7 @@ impl Scheduler {
current_thread.replace(next_thread); current_thread.replace(next_thread);
} }
match g_thread_to_be_destroyed.write() { match G_THREAD_TO_BE_DESTROYED.write() {
Ok(mut thread_to_be_destroyed) => { Ok(mut thread_to_be_destroyed) => {
if thread_to_be_destroyed.is_some() { if thread_to_be_destroyed.is_some() {
drop(thread_to_be_destroyed.take()); drop(thread_to_be_destroyed.take());

View File

@ -37,7 +37,7 @@ impl Thread {
pc: 0 pc: 0
}, },
stack_pointer: 0, stack_pointer: 0,
object_type: ObjectType::THREAD_TYPE object_type: ObjectType::ThreadType
} }
} }

View File

@ -6,17 +6,17 @@ use crate::kernel::thread::Thread;
extern crate lazy_static; extern crate lazy_static;
lazy_static! { lazy_static! {
pub static ref g_current_thread: RwLock<Option<Thread>> = RwLock::new(Option::None); pub static ref G_CURRENT_THREAD: RwLock<Option<Thread>> = RwLock::new(Option::None);
pub static ref g_thread_to_be_destroyed: RwLock<Option<Thread>> = RwLock::new(Option::None); pub static ref G_THREAD_TO_BE_DESTROYED: RwLock<Option<Thread>> = RwLock::new(Option::None);
} }
#[derive(PartialEq)] #[derive(PartialEq)]
pub enum ObjectType { pub enum ObjectType {
SEMAPHORE_TYPE, SemaphoreType,
LOCK_TYPE, LockType,
CONDITION_TYPE, ConditionType,
FILE_TYPE, FileType,
THREAD_TYPE, ThreadType,
INVALID_TYPE InvalidType
} }