mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 09:53:24 +00:00
Fix dead lock in canonical mode
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
bc3b849613
commit
288374ee09
@ -2,10 +2,11 @@ use core::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use alloc::{collections::VecDeque, sync::Arc};
|
||||
use bitflags::bitflags;
|
||||
use spin::mutex::Mutex;
|
||||
|
||||
use crate::task::schedule;
|
||||
|
||||
use super::SpinLock;
|
||||
|
||||
/// A wait queue.
|
||||
///
|
||||
/// One may wait on a wait queue to put its executing thread to sleep.
|
||||
@ -13,14 +14,14 @@ use crate::task::schedule;
|
||||
/// Other threads may invoke the `wake`-family methods of a wait queue to
|
||||
/// wake up one or many waiter threads.
|
||||
pub struct WaitQueue {
|
||||
waiters: Mutex<VecDeque<Arc<Waiter>>>,
|
||||
waiters: SpinLock<VecDeque<Arc<Waiter>>>,
|
||||
}
|
||||
|
||||
impl WaitQueue {
|
||||
/// Creates a new instance.
|
||||
pub fn new() -> Self {
|
||||
WaitQueue {
|
||||
waiters: Mutex::new(VecDeque::new()),
|
||||
waiters: SpinLock::new(VecDeque::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ impl LineDiscipline {
|
||||
if !current_line.is_empty() {
|
||||
current_line.backspace();
|
||||
}
|
||||
} else if meet_new_line(item, &self.termios()) {
|
||||
} else if meet_new_line(item, &termios) {
|
||||
// a new line was met. We currently add the item to buffer.
|
||||
// when we read content, the item should be skipped if it's EOF.
|
||||
let mut current_line = self.current_line.lock();
|
||||
@ -129,7 +129,7 @@ impl LineDiscipline {
|
||||
}
|
||||
|
||||
if termios.contain_echo() {
|
||||
self.output_char(item);
|
||||
self.output_char(item, &termios);
|
||||
}
|
||||
|
||||
if self.is_readable() {
|
||||
@ -143,12 +143,11 @@ impl LineDiscipline {
|
||||
}
|
||||
|
||||
// TODO: respect output flags
|
||||
fn output_char(&self, item: u8) {
|
||||
fn output_char(&self, item: u8, termios: &KernelTermios) {
|
||||
if 0x20 <= item && item < 0x7f {
|
||||
let ch = char::from(item);
|
||||
print!("{}", ch);
|
||||
}
|
||||
let termios = self.termios.lock();
|
||||
if item == *termios.get_special_char(CC_C_CHAR::VERASE) {
|
||||
// write a space to overwrite current character
|
||||
let bytes: [u8; 3] = [b'\x08', b' ', b'\x08'];
|
||||
|
Reference in New Issue
Block a user