Hi All,
I am learning golang and want to know more on concurrent execution of go routines. When a go routine performs an I/O then whether that routine is suspended until the I/O is completed? Or the scheduler just takes turns moving to other routines and back and frequently check for I/O completion? In other languages (runtimes), they use thread pool and do I/O in async way so that single thread is not blocked while I/O is happening and instead that thread serve other requests/tasks.
In golang “go routine” is light weight and we can have thousands of them so async I/O may not be significant. Although we can have several routines executed by single or multiple threads when performing I/O if runtime refrains not visiting that routine unless I/O is completed then it would be doubly efficient. Want to know what happens under the hood?
Thanks,
Abhijit
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/Luje-okL4jI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
> Also how the database sql driver communicates? Does it block thread unless
> we get database response or uses net package non blocking IO?
It depends on driver implementation.
If the driver uses net package to communicate with DB process (which
is quite likely), then it uses this feature automatically.
If/when file/pipe IO is make non-blocking as well, all drivers that
use files/pipes will use this feature automatically as well.
Also a driver could use a single thread for IO and park/unpark user
goroutines on channels. That would have the same effect.
On Mon, Jan 6, 2014 at 6:02 PM, Bienlein <jet...@web.de> wrote:
>
...
Also a driver could use a single thread for IO and park/unpark user
goroutines on channels. That would have the same effect.