[erlang-questions] Subtle behaviour of Erlang scheduler
KatolaZ
me@REDACTED
Thu May 24 15:16:41 CEST 2007
On Thu, May 24, 2007 at 07:57:16AM -0500, Jordan Wilberding wrote:
> I am definitely not a guru, but I will take my best guess at it.
>
> My guess that it has something to do with using both
> process_flag(priority, high) and having a timeout of zero in the count
> receive loop. If you comment out process_flag(priority, high) in proc2/0
> or you change after 0 to after 1 in count/1 the program will work.
>
> If you look at top in linux or task manager in windows, the program runs
> at nearly 100%. My guess is the proc2 is running with such a high
> priority that it is hitting that after 0 every time and not giving a
> chance for the proc2 ! x and proc3 ! x to be executed.
>
> Again, I am not a guru, but this is my best guess based on the
> obvservations I saw.
The first problem is that also proc1 has priority set to "high", and
it should be eventually scheduled. That code snipped perfectly works
if priority is set to "normal" for all processes, as it should be. If
you assign all processes a "high" priority, only proc2 will be
executed, hanging-up the shell and all other processes.
But the real mess is that the behaviour changes depending on WHEN you
excecute that code. In fact, as reported in our previous mail, if you
launch the original test:test() (that without timer:sleep() in proc2)
as the first function after starting erl, it hangs up and never
returns. On the other hand, if you first try to execute the
test:test() with timer:sleep() and then you remove the timer:sleep()
and recompile, it WORKS. And if you start again erl to run it, it
DOES NOT WORK.
HND
Enzo and Corrado
--
[ Enzo Nicosia aka KatolaZ --- GLUG Catania -- Freaknet Medialab ]
[ me [at] katolaz.homeunix.net -- http://katolaz.homeunix.net -- ]
[ GNU/Linux User:#325780/ICQ UIN: #258332181/GPG key ID 0B5F062F ]
[ Fingerprint: 8E59 D6AA 445E FDB4 A153 3D5A 5F20 B3AE 0B5F 062F ]
More information about the erlang-questions
mailing list