mirror of
https://github.com/BoredDevNL/BoredOS.git
synced 2026-05-15 10:48:38 +00:00
OPTIMIZATION: Throttle terminal/Bsh idle polling
This commit is contained in:
parent
79eeaa73d9
commit
0ad151d7fc
2 changed files with 4 additions and 2 deletions
|
|
@ -1248,7 +1248,8 @@ static int read_line(char *out, int max_len, const char *prompt) {
|
||||||
char ch = 0;
|
char ch = 0;
|
||||||
int got = sys_tty_read_in(&ch, 1);
|
int got = sys_tty_read_in(&ch, 1);
|
||||||
if (got <= 0) {
|
if (got <= 0) {
|
||||||
sys_yield();
|
// Throttle idle input polling to avoid pegging the CPU at 100%
|
||||||
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -885,7 +885,8 @@ int main(void) {
|
||||||
draw_tabs();
|
draw_tabs();
|
||||||
draw_session(&g_tabs[g_active_tab]);
|
draw_session(&g_tabs[g_active_tab]);
|
||||||
} else {
|
} else {
|
||||||
sys_yield();
|
// Avoid a tight poll loop when idle; sleep yields to the scheduler.
|
||||||
|
sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue