Re: [go-nuts] net.ListenUDP, ListenTCP & new go routine creation
On Mon, Jun 20, 2016 at 8:09 PM, Matt Hardenwrote: > OK, wait. You mentioned namespaces. It is definitely not supported in any > way to have different threads or goroutines running in different namespaces > within a single Go process. The Go scheduler can move a goroutine from one > thread to another at any time and it is not aware of namespaces. In fact, > anything that causes different threads to run in different contexts is not > supported and cannot work reliably in Go. Yes. I want to add that you are asking about goroutines but it seems that what you actually care about are threads. The Go scheduler will automatically create a new thread when an existing thread blocks in a system call. The Go program has no control over when or how new threads are created, or which existing thread is used to create a new thread. 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.
Re: [go-nuts] net.ListenUDP, ListenTCP & new go routine creation
Nothing about using the network requires new goroutine creation. I wouldn't expect Dial to create new goroutines, except perhaps temporarily during DNS lookup or something. On Mon, Jun 20, 2016 at 6:38 PM Manohar Kumarwrote: > > > On Monday, June 20, 2016 at 9:31:08 AM UTC-7, Ian Lance Taylor wrote: > >> On Sat, Jun 18, 2016 at 10:17 PM, Manohar Kumar >> wrote: >> > >> > Is it possible that a net.ListenTCP or ListenUDP call can result in >> new go >> > routine/OS thread creation ? I guess not all system calls result in a >> new go >> > routine (and OS thread if necessary) creation. But ListenTCP & UDP does >> many >> > things underneath and its not clear if it can lead to new go routine >> > creation. >> >> ListenTCP and ListenUDP will not create new goroutines or threads. >> But those calls just create new listeners; you probably meant to ask >> about the AcceptTCP and ReadFrom/WriteTo methods. Those methods will >> not normally create new goroutines. However, they may block, and that >> may cause the Go runtime to create a new thread. >> > > Thanks. How about Dial() ? Since Dial to a TCP destination requires a > connection to be established I think it can lead to new go routine > creation. Can that happen for Dial to an UDP destination as well (which > shouldn't trigger any network transaction)? > > This code runs on a root network namespace and some other child network > namespaces. Its not a desirable behavior to have new OS created while its > executing in the child namespaces. > > -Manohar. > > >> > I am mainly interested in Linux and have to make these calls in a part >> of >> > the code where new OS thread creation isn't desirable. Please note that >> > changing that aspect of the design itself is not an option for me. >> >> The Go runtime is free to create new OS threads at any time. You can >> not reasonably use Go under the restrictions you describe. >> >> 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. > -- 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.
Re: [go-nuts] net.ListenUDP, ListenTCP & new go routine creation
On Monday, June 20, 2016 at 9:31:08 AM UTC-7, Ian Lance Taylor wrote: > > On Sat, Jun 18, 2016 at 10:17 PM, Manohar Kumar> wrote: > > > > Is it possible that a net.ListenTCP or ListenUDP call can result in new > go > > routine/OS thread creation ? I guess not all system calls result in a > new go > > routine (and OS thread if necessary) creation. But ListenTCP & UDP does > many > > things underneath and its not clear if it can lead to new go routine > > creation. > > ListenTCP and ListenUDP will not create new goroutines or threads. > But those calls just create new listeners; you probably meant to ask > about the AcceptTCP and ReadFrom/WriteTo methods. Those methods will > not normally create new goroutines. However, they may block, and that > may cause the Go runtime to create a new thread. > Thanks. How about Dial() ? Since Dial to a TCP destination requires a connection to be established I think it can lead to new go routine creation. Can that happen for Dial to an UDP destination as well (which shouldn't trigger any network transaction)? This code runs on a root network namespace and some other child network namespaces. Its not a desirable behavior to have new OS created while its executing in the child namespaces. -Manohar. > > I am mainly interested in Linux and have to make these calls in a part > of > > the code where new OS thread creation isn't desirable. Please note that > > changing that aspect of the design itself is not an option for me. > > The Go runtime is free to create new OS threads at any time. You can > not reasonably use Go under the restrictions you describe. > > 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.
Re: [go-nuts] net.ListenUDP, ListenTCP & new go routine creation
On Sat, Jun 18, 2016 at 10:17 PM, Manohar Kumarwrote: > > Is it possible that a net.ListenTCP or ListenUDP call can result in new go > routine/OS thread creation ? I guess not all system calls result in a new go > routine (and OS thread if necessary) creation. But ListenTCP & UDP does many > things underneath and its not clear if it can lead to new go routine > creation. ListenTCP and ListenUDP will not create new goroutines or threads. But those calls just create new listeners; you probably meant to ask about the AcceptTCP and ReadFrom/WriteTo methods. Those methods will not normally create new goroutines. However, they may block, and that may cause the Go runtime to create a new thread. > I am mainly interested in Linux and have to make these calls in a part of > the code where new OS thread creation isn't desirable. Please note that > changing that aspect of the design itself is not an option for me. The Go runtime is free to create new OS threads at any time. You can not reasonably use Go under the restrictions you describe. 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.
Re: [go-nuts] net.ListenUDP, ListenTCP & new go routine creation
On 21 Jun 2016 12:42 a.m., "Manohar Kumar"wrote: > > I am mainly interested in Linux and have to make these calls in a part of the code where new OS thread creation isn't desirable. Please note that changing that aspect of the design itself is not an option for me. If you have a requirement that you need tight control over when threads are created then Go isn't the language for you. The net package makes a number of threads while it wait s on various syscalls. Can I ask why you need to avoid thread creation? -- 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.
[go-nuts] net.ListenUDP, ListenTCP & new go routine creation
Hello, Is it possible that a net.ListenTCP or ListenUDP call can result in new go routine/OS thread creation ? I guess not all system calls result in a new go routine (and OS thread if necessary) creation. But ListenTCP & UDP does many things underneath and its not clear if it can lead to new go routine creation. I am mainly interested in Linux and have to make these calls in a part of the code where new OS thread creation isn't desirable. Please note that changing that aspect of the design itself is not an option for me. Manohar. -- 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.