From 0ad151d7fcf195d5f1c5e0e2e74f66ee31122d50 Mon Sep 17 00:00:00 2001 From: boreddevnl Date: Fri, 17 Apr 2026 09:42:27 +0200 Subject: [PATCH] OPTIMIZATION: Throttle terminal/Bsh idle polling --- src/userland/cli/bsh.c | 3 ++- src/userland/gui/terminal.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/userland/cli/bsh.c b/src/userland/cli/bsh.c index d8e999b..2c07eb8 100644 --- a/src/userland/cli/bsh.c +++ b/src/userland/cli/bsh.c @@ -1248,7 +1248,8 @@ static int read_line(char *out, int max_len, const char *prompt) { char ch = 0; int got = sys_tty_read_in(&ch, 1); if (got <= 0) { - sys_yield(); + // Throttle idle input polling to avoid pegging the CPU at 100% + sleep(1); continue; } diff --git a/src/userland/gui/terminal.c b/src/userland/gui/terminal.c index 928565c..0b0f6cb 100644 --- a/src/userland/gui/terminal.c +++ b/src/userland/gui/terminal.c @@ -885,7 +885,8 @@ int main(void) { draw_tabs(); draw_session(&g_tabs[g_active_tab]); } else { - sys_yield(); + // Avoid a tight poll loop when idle; sleep yields to the scheduler. + sleep(1); } }