Golangs goroutines present an interface of blocking I/O to the goroutine (-programmer). Behind the scenes the runtime naturally uses some kind of non-blocking I/O to prevent the OS from suspending the OS-thread, so that the runtime can run another goroutine on top of the OS thread while the I/O is performed.
When does the runtime consider the I/O performed so that it can reschedule the goroutine?
To make it clear, assuming I have a net.TCPConn
that I call Write
on, when can I expect the goroutine to be rescheduled?
conn, err := net.Dial("tcp", serverAddr)
conn.Write(buffer)
timestamp = time.Now()
That is when can I expect the timestamp to be taken?
- When the buffer has been copied to the golang runtime?
- When the buffer has been copied to the runtime and to the OS's kernel space?
- When the buffer has been copied to the runtime, kernel space and additionally to the NIC's send buffer?
- When the buffer has been sent over the network/from the NIC?
- When the buffer has been acknowledged by the recieve ends TCP stack?