Re:Erlang Scheduler Details and Why They Matter
by hamidreza-s on Wednesday February 10, 2016 @05:34AM
(#11071768)
That's a good pint! I also can say that it is a matter of perspective. From an Erlang developer point of view, the processes are executing in a preemptive manner without telling them when to yield. The important factor is the reduction limit of the actors as well as being reentrant. It guarantees that each actor will sure yield even if it is still running and have something to do, and will be selected whenever scheduler select them again for execution.
Re:Erlang Scheduler Details and Why They Matter
by hyperpape on Tuesday February 09, 2016 @10:16PM
(#11070534)
I was also confused by this phrasing. The only thing I could think of was that from the programmer's perspective, it's not cooperative (you don't have to call yield), but that's also true of threads.
I see people down thread repeating this claim. Can anyone explain how the scheduler is preemptive?
Re:Erlang Scheduler Details and Why They Matter
by sbalea on Tuesday February 09, 2016 @11:11PM
(#11070718)
You are absolutely correct, the schedulers never preempt a process in the classical sense, but from an Erlang code perspective, the system behaves as if it would be preemptive. The schedulers are actually running a byte code interpreter and the interpreter will switch processes once a certain number of reductions is reached (or the code yields). This breaks down when running native code in the form of NIFs - it is entirely possible to block a scheduler indefinitely while running native code.
Re:Erlang Scheduler Details and Why They Matter
by sasa555 on Wednesday February 10, 2016 @10:47AM
(#11073470)
I like to think of it as preemptive because (putting NIFs aside) it's not possible for a single process to completely block the entire scheduler, even if it ends up in an infinite CPU bound loop.
So in other words, a task (i.e. process) doesn't have to cooperate with others. It can do whatever it wants, be it I/O or CPU bound, and doesn't have to yield explicitly. Due to aggressive "preemption" it won't block other pending tasks significantly.
In contrast, if this is not guaranteed (which is not in most other Erlang "alternatives" I've looked at), then a task might accidentally paralyse large portion of the system.
Great article though!