3 ms·
I really like this. Thank you for your comment and sharing. I have a lightweight 1:M:N runtime (1 scheduler thread, M kernel threads, N lightweight threads) w
by samsquire 3y ago
I really like this.
Thank you for your comment and sharing.
I have a lightweight 1:M:N runtime (1 scheduler thread, M kernel threads, N lightweight threads) which preempts by setting hot loops to the limit.
https://github.com/samsquire/preemptible-thread https://github.com/samsquire/preemptible-thread (Rust, Java and C)
How do you preempt code that is running?
Would you like to talk more about your idea?
- bluetomcat 3y ago> How do you preempt code that is running? It runs in its own VM with custom instructions. The "wait" statement corresponds to a special instruction that is able to switch to a separate execution context and restore the parent context when necessary. To implement this in native code, some kind of runtime support would be needed. Perhaps a dedicated thread that is able to stop/resume the main thread, changing the contents of the stack and the registers.