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
votes
"Processes" in Erlang are spawned with roughly the same regularity as objects are instantiated in sequential OOP languages. Not a perfect parallel, but its better to think of them like that. I wrote a thing about this a while back here on SO. The difference in paradigms requires leaving a lot of normal programming lore and knowledge behind.
– zxq9
1 Answers
5
votes
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.