perf(userland): replace sys_yield with sleep for WAY better idle efficiency

This commit is contained in:
boreddevnl 2026-05-11 19:52:43 +02:00
parent 78a9afebf4
commit a3a4494265
7 changed files with 9 additions and 8 deletions

View file

@ -1438,7 +1438,7 @@ static int read_line(char *out, int max_len, const char *prompt_tmpl) {
int got = sys_tty_read_in(&ch, 1);
if (got <= 0) {
// Throttle idle input polling to avoid pegging the CPU at 100%
sleep(1);
sleep(50);
continue;
}

View file

@ -496,7 +496,7 @@ int main(int argc, char **argv) {
ui_mark_dirty(win, 0, 0, WINDOW_W, WINDOW_H);
}
} else {
sys_yield();
sys_system(SYSTEM_CMD_SLEEP, 10, 0, 0, 0);
}
}

View file

@ -1988,7 +1988,7 @@ int main(int argc, char **argv) {
ui_mark_dirty(win, 0, 0, win_w, win_h);
needs_repaint = 0;
} else {
sys_yield();
sys_system(SYSTEM_CMD_SLEEP, 16, 0, 0, 0);
}
}
return 0;

View file

@ -54,7 +54,7 @@ int main(void) {
draw(win);
ui_mark_dirty(win, 0, 0, WINDOW_W, WINDOW_H);
} else {
sys_yield();
sys_system(SYSTEM_CMD_SLEEP, 10, 0, 0, 0);
}
}

View file

@ -158,7 +158,7 @@ static int _b_pipe_read(fd_handle_t *h, void *buf, size_t count) {
}
break;
}
sys_yield();
sleep(1);
continue;
}
@ -193,7 +193,7 @@ static int _b_pipe_write(fd_handle_t *h, const void *buf, size_t count) {
}
break;
}
sys_yield();
sleep(1);
continue;
}

View file

@ -3,6 +3,7 @@
#include "errno.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "sys/types.h"
#include "sys/wait.h"
@ -219,6 +220,6 @@ __attribute__((weak)) pid_t waitpid(pid_t pid, int *status, int options) {
errno = ECHILD;
return -1;
}
sys_yield();
sleep(1);
}
}

View file

@ -363,7 +363,7 @@ int main(int argc, char **argv) {
connected = 0;
break;
}
sys_yield();
sys_system(SYSTEM_CMD_SLEEP, 10, 0, 0, 0);
continue;
}