tosc-rs / mnemos

An Operating System for Building Small Computers
https://mnemos.dev
Apache License 2.0
253 stars 18 forks source link

forth `builtins` command fails with a `FormattingErr` #301

Open hawkw opened 8 months ago

hawkw commented 8 months ago

Running melpomene and attempting to run the forth builtins builtin word fails with a FormattingErr:

   0.001392241s  INFO Melpo:Kernel:graphical_shell_mono:Forth{id=0}: kernel::forth: VM running
   5.854253484s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Pressed, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('b') }
   6.005660478s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Released, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('b') }
   6.056674765s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Pressed, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('u') }
   6.107281906s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Released, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('u') }
   6.209261808s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Pressed, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('i') }
   6.260906664s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Released, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('i') }
   6.412639993s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Pressed, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('l') }
   6.463231576s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Pressed, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('t') }
   6.463254458s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Released, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('l') }
   6.564696482s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Released, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('t') }
   6.615590315s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Pressed, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('i') }
   6.667202512s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Released, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('i') }
   6.770222767s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Pressed, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('n') }
   6.821137410s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Pressed, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('s') }
   6.821164250s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Released, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('n') }
   6.922382170s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Released, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Char('s') }
   7.024214692s  INFO Melpo:Kernel:graphical_shell_mono: kernel::daemons::shells: event=KeyEvent { kind: Pressed, modifiers: Modifiers { SHIFT: false, CTRL: false, ALT: false, META: false, CAPSLOCK: false, NUMLOCK: false }, code: Enter }
   7.024262480s ERROR Melpo:Kernel:graphical_shell_mono:Forth{id=0}: kernel::forth: error=Output(FormattingErr)

my guess is that this occurs because the output buffer is too small, and the current way that the forth VM handles i/o just fails if it can't write all the output immediately?

hawkw commented 8 months ago

Yeah, after doing some digging it looks like we emit that error because the output buffer fills up. I think we need to change the way forth VM I/O works so that we yield when the output buffer is full and wait until it's cleared out...

hawkw commented 8 months ago

This probably means we need to make every write operation async, which...sucks...