takahirox / riscv-rust

RISC-V processor emulator written in Rust+WASM
https://takahirox.github.io/riscv-rust/wasm/web/index.html
MIT License
623 stars 47 forks source link

Run peripheral devices in another thread #29

Open takahirox opened 4 years ago

takahirox commented 4 years ago

It'd be good to run peripheral devices in another thread for the performance. For example currently terminal emulator handling input (and output) runs in the same thread so that main thread needs to periodically check input event but it seems to have an impact to the performance. If it runs in another thread it can improve the performance.

This is also important for Web. For not only catching input but also rendering the output the main thread periodically needs to sleep with setTimeout(). It can have a big performance impact. Maybe we can load off riscv emulator to workers thread and share UART registers between main and worker threads.

takahirox commented 4 years ago

I wish all major browsers supports SharedArrayBuffer by default... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer

takahirox commented 4 years ago

SharedArrayBuffer is re-enabled on FireFox.

https://hacks.mozilla.org/2020/07/firefox-79/

We can start to try to resolve this issue with it.