Erlang-映射每个"erlang进程";到新的内核线程 [英] Erlang - map each "erlang process" to new kernel thread

查看:110
本文介绍了Erlang-映射每个"erlang进程";到新的内核线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究基于erlang的系统,并试图分析系统中发生的事件的顺序.有没有一种方法可以强制erlang运行时或elang vm每次调用"spawn"时创建一个新的内核线程.这会使系统变慢,但会使研究容易得多​​. 我已经尝试过+ S标志,并且已经启用了smp,但是我怀疑系统仍将多个进程映射到一个内核线程或erlang调度程序.我缺少任何输入/配置参数吗?

I am studying an erlang based system, and trying to analyze the sequence of events that take place in the system. Is there a way to force erlang run-time or the elang vm to create a new kernel thread, each time "spawn" is called. This would make the system slower, but it would make the study a lot easier. I have tried the +S flag, and enabled smp already, but I suspect the system is still mapping multiple processes to one kernel thread, or erlang scheduler. Are there any inputs/configuration parameters I am missing?

推荐答案

不,这不是Erlang VM的工作方式. BEAM为每个核心生成线程并在其中运行调度程序.每个Erlang进程都可以在任何调度程序上运行,甚至可以从调度程序迁移到调度程序,从而使它们从一个线程迁移到另一个线程.默认情况下,这些调度程序甚至都没有绑定到CPU内核,因此它们可以在内核之间迁移.您可以使用-sbt开关绑定它们.您还可以将Erlang进程绑定到特定的调度程序,该调度程序没有文档说明,强烈建议不要这样做.您不能从Erlang而是从NIF或端口生成线程,但是无论如何您都不能在此线程上运行Erlang进程.

No, it is not how Erlang VM works. BEAM spawns threads for each core and runs scheduler there. Each Erlang process can run on any scheduler or even migrate from a scheduler to a scheduler which makes them migrate from one thread to another. By default, those schedulers are not even bound to the CPU core so they could migrate from core to core. You can bind them using -sbt switch. You can also bind Erlang process to the specific scheduler which is undocumented and highly not recommended. You can't spawn a thread from Erlang but from NIF or port but then you can't run Erlang process at this thread anyway.

这篇关于Erlang-映射每个"erlang进程";到新的内核线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆