On Wed, Apr 19, 2017 at 7:42 PM, 代君 <sydna...@gmail.com> wrote:
>
> i have a test code like this:
> func main() {
>         tcpAddress, err := net.ResolveTCPAddr("tcp", ":9999")
> if err != nil {
> fmt.Println(err)
> }
> listener, err := net.ListenTCP("tcp", tcpAddress)
>
> c, e := listener.AcceptTCP()
> if e != nil {
> fmt.Println(e)
> }
>
> t := make([]byte, 0, 1000)
> c.Read(t)
> }
> when the main function blocked on AcceptTCP(),  the runtime.sysmon()
> function will enter sleep soon which is because npidle equal to gomaxprocs.
>
> and then a tcp connect coming, how acceptTCP been waked? I couldn't find a
> runtime.netpoll() been call anymore.

In the findrunnable function, when a P tries to find a G to run, if
there is nothing to run, but there are some goroutines waiting for
network activity, then the P will block in a call to netpoll until
something is ready.

> could some give some advise, effective tools, design document or debug
> method to read golang's source code? I always want to debug some code in
> runtime, but i
> conn't find a effective way to do this now; I read these code so hard
> without clearly understand the detail design .

For the scheduler you can read
https://docs.google.com/document/d/1TTj4T2JO42uD5ID9e89oa0sLKhJYD0Y_kqxDv3I3XMw/view
, although it is somewhat out of date.

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