3 ms·
If you're implementing a VM, it's straightforward to do this by counting the number of virtual instructions executed for a given "process" and switching to the
by yellowapple 7y ago
If you're implementing a VM, it's straightforward to do this by counting the number of virtual instructions executed for a given "process" and switching to the next one after so many executions. This is, in fact, how Erlang's VM works, and how it's able to achieve preemptive multitasking entirely in userspace (and therefore avoiding the userspace<>kernelspace context switches).