Erlang - map each “erlang process” to new kernel thread

前提是你 提交于 2019-12-11 08:54:16

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/40709912/erlang-map-each-erlang-process-to-new-kernel-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!