How does an Erlang process bind to a specific sche

2019-08-04 14:55发布

How does an Erlang process bind to a specific scheduler?

标签: erlang
2条回答
小情绪 Triste *
2楼-- · 2019-08-04 15:56

Reading from an old mail from Kenneth Lundin:

The Erlang VM without SMP support has 1 scheduler which runs in the main process thread. The scheduler picks runnable Erlang processes and IO-jobs from the run-queue and there is no need to lock data structures since there is only one thread accessing them.

The Erlang VM with SMP support can have 1 to many schedulers which are run in 1 thread each. The schedulers pick runnable Erlang processes and IO-jobs from one common run-queue. In the SMP VM all shared data structures are protected with locks, the run-queue is one example of a data structure protected with locks.

From OTP R12B the SMP version of the VM is automatically started as default if the OS reports more than 1 CPU (or Core) and with the same number of schedulers as CPU's or Cores.

Not sure if this answer your question. Could you expand a bit more?

查看更多
爷的心禁止访问
3楼-- · 2019-08-04 15:59

Currently processes does not get bound to specific schedulers (though you can force it via undocumentet functions, not recommended). Scheduler threads may be bound to logical processors using cpu topology and binding types. The vm does use some of this information to enhance performance in its normal scheduling scheme.

查看更多
登录 后发表回答