[erlang-questions] Erlang internal scheduler implementation

Ulf Wiger ulf.wiger@REDACTED
Wed Jul 21 14:53:09 CEST 2010


It is true that some things have changed, but only
a few. :)

http://www.erlang.org/cgi-bin/ezmlm-cgi/4/26802

explains how each scheduler thread in an SMP system
works essentially like the old non-SMP scheduler, but
as the scheduler threads themselves are preemptively
scheduled, the strict priorities high and max are not
blocking in quite the same way as before.

A few additional comments, perhaps...

- Rickard wrote in the above post that the 'max'
   priority level is undocumented. This is not true (anymore).
   Scheduling is documented to some degree in the erlang
   man page under process_flag(priority, Level).

- The latest versions of OTP implement process migration
   between schedulers to prevent schedulers from running
   out of work (if they do, they will busy-loop for a while
   in order to avoid having to suspend and wake up the OS
   thread unnecessarily). The AFAICT wholly undocumented
   process_flag(scheduler, No) binds a process to a specific
   scheduler so that it cannot be migrated, presumably to
   allow for process affinity.
   ...or at least that's what I imagine that it ought to be
   doing. The value cannot be inspected, and at first sight,
   I couldn't find a way to 'unbind' a process again, so
   perhaps we should just ignore this facility for now? :)

- A process is punished with extra reductions if it sends
   a message to a process with a very long message queue.
   This is possibly undesirable in a manycore system, since
   it is tricky to implement without risking contention.

BR,
Ulf W

Michal Ptaszek wrote:
> Hi All,
> 
> is there any kind of detailed documentation
> (except the comments in the source code) on 
> behaviour/conception/strategy for Erlang 
> process scheduler?
> 
> How the processes are given CPU time, when they
> are pre-empted, can we and why do we migrate 
> processes between different scheduler queues? 
> 
> I've already found Ulf Wiger's explanation 
> in the mailing list archive:
> http://www.erlang.org/pipermail/erlang-questions/2001-April/003131.html
> Nevertheless, this email is 9 years old so probably
> a lot of things changed (e.g. better SMP 
> support). 
> 
> Best regards,
> Michal Ptaszek
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 


-- 
Ulf Wiger
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
http://www.erlang-solutions.com


More information about the erlang-questions mailing list