mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-18 15:27:50 +00:00
Rename multitasking module to threads
This commit is contained in:
@@ -77,7 +77,7 @@ extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: &mut InterruptSt
|
|||||||
PICS.lock()
|
PICS.lock()
|
||||||
.notify_end_of_interrupt(InterruptIndex::Timer.as_u8());
|
.notify_end_of_interrupt(InterruptIndex::Timer.as_u8());
|
||||||
}
|
}
|
||||||
crate::multitasking::scheduler();
|
crate::threads::scheduler();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: &mut InterruptStackFrame) {
|
extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: &mut InterruptStackFrame) {
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ pub mod allocator;
|
|||||||
pub mod gdt;
|
pub mod gdt;
|
||||||
pub mod interrupts;
|
pub mod interrupts;
|
||||||
pub mod memory;
|
pub mod memory;
|
||||||
pub mod multitasking;
|
|
||||||
pub mod serial;
|
pub mod serial;
|
||||||
|
pub mod threads;
|
||||||
pub mod vga_buffer;
|
pub mod vga_buffer;
|
||||||
|
|
||||||
pub fn init() {
|
pub fn init() {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
test_main();
|
test_main();
|
||||||
|
|
||||||
use blog_os::multitasking::{create_thread, create_thread_from_closure};
|
use blog_os::threads::{create_thread, create_thread_from_closure};
|
||||||
|
|
||||||
create_thread(thread_1, 1, &mut mapper, &mut frame_allocator);
|
create_thread(thread_1, 1, &mut mapper, &mut frame_allocator);
|
||||||
create_thread(thread_2, 1, &mut mapper, &mut frame_allocator);
|
create_thread(thread_2, 1, &mut mapper, &mut frame_allocator);
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ pub unsafe fn context_switch(stack_pointer: VirtAddr) {
|
|||||||
|
|
||||||
pub fn scheduler() {
|
pub fn scheduler() {
|
||||||
let next = PAUSED_THREADS.try_lock().and_then(|mut paused_threads| {
|
let next = PAUSED_THREADS.try_lock().and_then(|mut paused_threads| {
|
||||||
paused_threads.as_mut().and_then(|threads| threads.pop_front())
|
paused_threads
|
||||||
|
.as_mut()
|
||||||
|
.and_then(|threads| threads.pop_front())
|
||||||
});
|
});
|
||||||
if let Some(next) = next {
|
if let Some(next) = next {
|
||||||
unsafe { context_switch(next) };
|
unsafe { context_switch(next) };
|
||||||
@@ -32,7 +34,10 @@ fn add_paused_thread(stack_pointer: VirtAddr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_thread(stack_pointer: VirtAddr) {
|
fn add_thread(stack_pointer: VirtAddr) {
|
||||||
PAUSED_THREADS.lock().get_or_insert_with(VecDeque::new).push_back(stack_pointer);
|
PAUSED_THREADS
|
||||||
|
.lock()
|
||||||
|
.get_or_insert_with(VecDeque::new)
|
||||||
|
.push_back(stack_pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_thread(
|
pub fn create_thread(
|
||||||
Reference in New Issue
Block a user