4 ms·
IIRC: one of the issues with the original Rust stdlib greenthread implementation was that it's extremely difficult to preempt execution in a systems language. I
by 15155 7y ago
IIRC: one of the issues with the original Rust stdlib greenthread implementation was that it's extremely difficult to preempt execution in a systems language. It's also quite difficult to add userland execution preemption without incurring significant performance penalties.
How do you preempt syscalls or FFI calls? (Go will almost certainly also have this issue with cgo modules)
I would be very surprised if preemptible Futures are something Tokio can or would implement.
- wbl 7y agoWhat does systems mean here? There is a dirty trick with a NOP and self rewriting code that's quite cheap when not triggered. I think java does it that way.
- sansnomme 7y agoElaborate?
- wbl 7y agoSo you put in a NOP before each backward jump. To preempt you overwrite it with a jump to a handler that saves the state of the thread.
- jedisct1 7y agoHow multitasking used to work on Atari :) But this requires code pages to be writable. Which, from a security perspective is awful.
- heavenlyblue 7y agoHow does that resolve syscall question?
- wbl 7y agoSyscall you have to do with a signal
- nine_k 7y agoThis presumes writable code segments, which many OSes shun.
- hyperman1 7y agoIt's java. Dynamic code generated by a jit.
- adwn 7y agoWhich NOP do you overwrite? Do you have to do this for all backward-jump-NOPs in all loaded executable code, or do you have to determine, which loop the thread in question is executing right now?