Avoid deadlocks in println/serial_println

This commit is contained in:
Philipp Oppermann
2018-10-20 16:44:40 +02:00
parent 68ffc3cd59
commit 66d940559f
4 changed files with 118 additions and 7 deletions

View File

@@ -11,10 +11,14 @@ lazy_static! {
pub fn print(args: ::core::fmt::Arguments) {
use core::fmt::Write;
SERIAL1
.lock()
.write_fmt(args)
.expect("Printing to serial failed");
use x86_64::instructions::interrupts;
interrupts::without_interrupts(|| {
SERIAL1
.lock()
.write_fmt(args)
.expect("Printing to serial failed");
});
}
/// Prints to the host through the serial interface.

View File

@@ -164,7 +164,11 @@ macro_rules! println {
/// Prints the given formatted string to the VGA text buffer through the global `WRITER` instance.
pub fn print(args: fmt::Arguments) {
use core::fmt::Write;
WRITER.lock().write_fmt(args).unwrap();
use x86_64::instructions::interrupts;
interrupts::without_interrupts(|| {
WRITER.lock().write_fmt(args).unwrap();
});
}
#[cfg(test)]