From 2f4cf666c0c7bd224932fa48973e7334360c1de3 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 21 Aug 2026 20:13:59 +0200 Subject: input: total keyboard routing + per-terminal discipline (ADR 0006 ph1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wm: FOCUSED is now a plain window id — window 0 (home terminal) is an ordinary focusable window in the z-order. The CONSOLE sentinel (usize::MAX) and the focused()==0 special cases are gone; focus_console() is an alias for focus(0). Desktop clicks focus window 0. The WM input pump routes every key unconditionally: IRQ ring -> pump -> focused window's owner; nothing polls the scancode rings directly any more. tty: read_line() reads from the calling task's message queue (the old global-ring read_line and the duplicate read_line_from_queue are merged); raw mode (read_byte/try_read_byte) consumes the same queue; interrupt_pressed drains the queue instead of the ring. shell: task 0 owns home terminal window 0 and blocks on its queue like a windowed shell; cat/hexdump stdin paths pass the home terminal handle. sched: watchdog comments updated (shell parks on recv_blocking). Verified in QEMU: F1 spawns terminals, F2 cycles focus home->term1-> term2, keystrokes land only in the focused window, ^C cancels a line, edit runs raw over the queue and exits to a working prompt; test-disk regression PASS. --- rsnix/src/sched.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'rsnix/src/sched.rs') diff --git a/rsnix/src/sched.rs b/rsnix/src/sched.rs index 39ecb65..0c4938e 100644 --- a/rsnix/src/sched.rs +++ b/rsnix/src/sched.rs @@ -201,7 +201,7 @@ const WATCHDOG_SPIN_TICKS: u32 = 1500; const WATCHDOG_BOOT_SPIN_TICKS: u32 = 750; /// True once the shell REPL is live (set by main.rs before shell::run()). -/// The shell legitimately parks in poll_key with a fixed frame when it is; +/// The shell legitimately blocks on its message queue once live; /// before that, task 0 running boot code must not sit in a fixed frame. static SHELL_RUNNING: AtomicBool = AtomicBool::new(false); @@ -264,16 +264,17 @@ pub fn on_tick(cur: usize) -> usize { TASKS[CURRENT].ticks += 1; // Spin detection: a task whose interrupted frame never moves // (identical RSP on every tick) is stuck in a hot loop — no yield, - // no sleep, no block. The shell (id 0) legitimately parks in - // poll_key with a fixed frame, and idle (id 1) hlt's; both exempt. + // no sleep, no block. The shell (id 0) legitimately blocks on + // recv_blocking with a fixed frame, and idle (id 1) hlt's; both + // exempt. let id = CURRENT; let w = &mut SPIN_WATCH[id]; if w.last_rsp == cur { w.same += 1; // Background tasks (id >= 2): spinning is never legitimate. - // Task 0 (shell): exempt once the REPL is live (poll_key parks - // with a fixed frame); during the boot phase a fixed frame - // means usb/ehci init is wedged on real hardware. + // Task 0 (shell): exempt once the REPL is live (recv_blocking + // parks with a fixed frame); during the boot phase a fixed + // frame means usb/ehci init is wedged on real hardware. let threshold = if id == SHELL_TID && !SHELL_RUNNING.load(Ordering::Relaxed) { WATCHDOG_BOOT_SPIN_TICKS } else if id >= 2 { -- cgit v1.2.3