2 ms·
The generalized form of this concept is that there are advantages in having a non-preemptive execution model. You can implicitly do all sorts of crazy things wi
by derefr 10y ago
The generalized form of this concept is that there are advantages in having a non-preemptive execution model. You can implicitly do all sorts of crazy things without synchronization primitives in a non-preemptive system, because nobody will try to mess with any of the resources you're messing with until you yield execution—which you don't have to do until you're done.
The degenerate case of this is cooperative scheduling, which is painful in about the same way that manual memory management is painful. But the hybrid case, reduction scheduling ala Erlang, gets a lot of the same advantages (nothing pre-empting a function in the middle of a loop body) without the ability to forget to add yields (they happen at tail-call sites—which, for a language where tail-recursion is the only loop primitive, means your code will always have an O(1) runtime before a yield.)