On Tue, May 22, 2018 at 9:26 AM, Ming Hu <humi...@gmail.com> wrote:
>
> I am reading the design of go scheduler, and don't quite understand this in
> "Scalable Go Scheduler Design Doc"
>
> https://docs.google.com/document/d/1TTj4T2JO42uD5ID9e89oa0sLKhJYD0Y_kqxDv3I3XMw/edit#
>
>> Spinning is mostly passive (yield to OS, sched_yield()), but may include a
>> little bit of active spinning (loop burnging CPU) (requires investigation
>> and tuning).
>
>
>
>
> My question is:
>
> When M is spinning, what's the actual work it is doing?

No actual work.  That's why it is spinning.


> I looked into the doc and code, it seems that when M is spinning it just
> looks for available work to do (look for G, look for P);
>
> but why the design doc said "Spinning is mostly passive (yield to OS,
> sched_yield()"?

I don't think the implementation works that way any more.


> If the spinning thread mostly just do sched_yield(), it just let other
> thread doing its job, then what's is the "spinning"

A spinning thread is one that is looking for work.  This is used to
limit the number of threads that are doing that, while ensuring that
not all the threads go to sleep.  See the comment at the top of
runtime/proc.go for more information.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to