Replace Mutex with Spinlock in tty to avoid deadlock

This commit is contained in:
Jianfeng Jiang
2023-05-31 16:45:44 +08:00
committed by Tate, Hongliang Tian
parent 2b59a406a6
commit 2985cdced6
8 changed files with 76 additions and 69 deletions

View File

@ -12,8 +12,10 @@ use core::{
ops::{Index, IndexMut},
};
use font8x8::UnicodeFonts;
use jinux_frame::{config::PAGE_SIZE, mmio::Mmio, vm::VmIo, LimineFramebufferRequest};
use spin::{Mutex, Once};
use jinux_frame::{
config::PAGE_SIZE, mmio::Mmio, sync::SpinLock, vm::VmIo, LimineFramebufferRequest,
};
use spin::Once;
#[init_component]
fn framebuffer_init() -> Result<(), ComponentInitError> {
@ -21,7 +23,7 @@ fn framebuffer_init() -> Result<(), ComponentInitError> {
Ok(())
}
pub(crate) static WRITER: Once<Mutex<Writer>> = Once::new();
pub(crate) static WRITER: Once<SpinLock<Writer>> = Once::new();
static FRAMEBUFFER_REUEST: LimineFramebufferRequest = LimineFramebufferRequest::new(0);
pub(crate) fn init() {
@ -64,7 +66,7 @@ pub(crate) fn init() {
};
writer.clear();
WRITER.call_once(|| Mutex::new(writer));
WRITER.call_once(|| SpinLock::new(writer));
}
pub(crate) struct Writer {