commit 55305eea8dad0f85994d149df7624fdeb95dacca
parent c7450d49bd99efd802a2c7303555182722b9f6b3
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Tue, 10 Jan 2023 16:19:22 -0500
posix: play nice with host CPU cycles
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/posix/init.fs b/posix/init.fs
@@ -5,3 +5,8 @@
' _:emit ByteWriter :new dup to ConsoleOut to StdOut
f<< /sys/kbd.fs
' (key?) ' key? realias
+
+f<< /sys/loop.fs
+\ prevent Dusk from using 100% of the CPU and make the fans go crazy.
+: posixidle 1000 _usleep ;
+current loopadd
diff --git a/posix/vm.c b/posix/vm.c
@@ -997,6 +997,11 @@ static void FSEEK() { // op: 66
}
sd(hdl+FILEPOSOFF, res);
}
+
+static void USLEEP() { // op: 67
+ usleep(ppop());
+}
+
// ( imgname -- )
static void MOUNTDRV() { // op: 68
char buf[64] = {0};
@@ -1055,7 +1060,7 @@ static void (*ops[OPCNT])() = {
RSHIFT, LITN, EXECUTEWR, EXITWR, MOVE, MOVEWR, NULL, WNF,
STACKCHK, MAYBEWORD, WORD, PARSE, REQ, FIND, APOS, COMPILING,
ALIASWR, STARTCOMP, STOPCOMP, COMPWORD, RUNWORD, NULL, NULL, NULL,
- FCHILD, FOPEN, FREADBUF, FCLOSE, FINFO, FITER, FSEEK, NULL,
+ FCHILD, FOPEN, FREADBUF, FCLOSE, FINFO, FITER, FSEEK, USLEEP,
MOUNTDRV, UNMOUNTDRV, DRVRD, DRVWR};
static char *opnames[OPCNT] = {
@@ -1071,7 +1076,7 @@ static char *opnames[OPCNT] = {
"rshift", "litn", "execute,", "exit,", "move", "move,", NULL, "(wnf)",
"stack?", "maybeword", "word", "parse", "[]=", "find", "'", "compiling",
"alias,", "]", "[", "compword", "runword", NULL, NULL, NULL,
- "_fchild", "_fopen", "_freadbuf", "_fclose", "_finfo", "_fiter", "_fseek", NULL,
+ "_fchild", "_fopen", "_freadbuf", "_fclose", "_finfo", "_fiter", "_fseek", "_usleep",
"_mountdrv", "_unmountdrv", "_drv@", "_drv!"};
static void oprun1() { // run next op