[erlang-questions] How to avoid long_schedule issue ?

Alex Feng <>
Tue Dec 27 10:45:06 CET 2016


Hi,

I was reading some documents about scheduler, to my understanding there
will be no long_schedule issue since BIF has trap mechanism. Then I found
this, I couldn't understand, the reduction is keeping increasing, why the
BIF(lists:seq) is not interrupted for more than 10ms ?

Could someone please explain this ?

1> erlang:system_monitor(self(),[{long_schedule, 10}]).
undefined
2>  Pid = spawn(fun()->lists:seq(1,2000000000) end).
<0.65.0>
3>flush().

Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,21},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,38},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,17},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,21},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,23},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,31},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,30},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,43},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,53},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,56},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,51},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,81},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,17},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,18},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,110},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,74},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,24},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,76},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,112},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,43},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,130},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,205},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
Shell got {monitor,<0.65.0>,long_schedule,
                   [{timeout,77},
                    {in,{lists,seq_loop,3}},
                    {out,{lists,seq_loop,3}}]}
20>  process_info(Pid, reductions).
{reductions,4166000}
21>  process_info(Pid, reductions).
{reductions,7150000}
22>  process_info(Pid, reductions).
{reductions,8328000}
23>  process_info(Pid, reductions).
{reductions,12330000}
24>  process_info(Pid, reductions).
{reductions,14354000}
25>  process_info(Pid, reductions).
{reductions,24774000}



Br,
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161227/23af3ed1/attachment.html>


More information about the erlang-questions mailing list