Re: [go-nuts] runtime.LockOSThread() question

2016-10-03 Thread 'Srimanth Gunturi' via golang-nuts
Now it is making more sense. So GOMAXPROCS has no connection with the actual number of OS threads created to run goroutines. But it does determine how many of them are active at any given time. Also, a single OS thread can multiplex multiple goroutines, unless #LockOSThread() is invoked in which ca

Re: [go-nuts] runtime.LockOSThread() question

2016-10-03 Thread Ian Lance Taylor
On Mon, Oct 3, 2016 at 12:48 PM, 'SrimanthG' via golang-nuts wrote: > I have another code snippet which hits the same problem and it does not use > sleep: https://play.golang.org/p/mUPCOFle4h > All 10 goroutines are going beyond "runtime.LockOSThread()" on a single OS > thread. No, they are not.

Re: [go-nuts] runtime.LockOSThread() question

2016-10-03 Thread Ian Lance Taylor
On Mon, Oct 3, 2016 at 12:24 PM, 'SrimanthG' via golang-nuts wrote: > > Do you mean to say that as long as the process is running instructions, it > will not let any other goroutine use that OS thread and execute? It's either somewhat simpler or much more complex than that. It is simpler in the

Re: [go-nuts] runtime.LockOSThread() question

2016-10-03 Thread 'SrimanthG' via golang-nuts
I have another code snippet which hits the same problem and it does not use sleep: https://play.golang.org/p/mUPCOFle4h All 10 goroutines are going beyond "runtime.LockOSThread()" on a single OS thread. Output: > main > locked 1 > locked 10 > locked 9 > locked 8 > locked 7 > locked 6 > locked 5

Re: [go-nuts] runtime.LockOSThread() question

2016-10-03 Thread 'SrimanthG' via golang-nuts
Thank you for pointing that out. Do you mean to say that as long as the process is running instructions, it will not let any other goroutine use that OS thread and execute? If so, can the documentation be updated to mention sleeping as cause for letting other goroutines in. Also, what other ca

Re: [go-nuts] runtime.LockOSThread() question

2016-10-03 Thread Ian Lance Taylor
On Mon, Oct 3, 2016 at 12:10 PM, 'SrimanthG' via golang-nuts wrote: > If you run the code snippet I pasted in https://play.golang.org/p/4R-WlCiKNT > you will see that it runs both in parallel - hence my confusion Sleeping in time.Sleep does not count as running. If you mean something else, can y

Re: [go-nuts] runtime.LockOSThread() question

2016-10-03 Thread 'SrimanthG' via golang-nuts
If you run the code snippet I pasted in https://play.golang.org/p/4R-WlCiKNT you will see that it runs both in parallel - hence my confusion On Monday, October 3, 2016 at 12:04:39 PM UTC-7, Ian Lance Taylor wrote: > > On Mon, Oct 3, 2016 at 11:31 AM, 'SrimanthG' via golang-nuts > > wrote: >

Re: [go-nuts] runtime.LockOSThread() question

2016-10-03 Thread Ian Lance Taylor
On Mon, Oct 3, 2016 at 11:31 AM, 'SrimanthG' via golang-nuts wrote: > > I ran a Go program with GOMAXPROCS=1 and two goroutines which both did > "runtime.LockOSThread()" and slept 10 seconds before exiting. > > Code: https://play.golang.org/p/4R-WlCiKNT > > Since I had 1 OS thread and 2 goroutines