Thanks for the answers. I'll play around with C.gettid.

Greets,

On Mon, Feb 13, 2017 at 7:06 AM, Ian Lance Taylor <i...@golang.org> wrote:
On Sun, Feb 12, 2017 at 9:57 PM, Luka Napotnik <l...@zeta.si> wrote:
Thanks for the reply. I've created a test program with function F1 that
 calls a C function F2. The function F2 then calls a Go function F3.

I've started the test once with GOMAXPROCS set to 1, and the second time without an env. (using Go 1.7). There are short pauses between calls and I've measured the number of system threads used by the process with ps -o
 nlwp.

I found that when running the test with GOMAXPROCS=1, a new thread is always spawned when the C function F2 calls a Go function, but not if the env. is not set. Why is that? I know GOMAXPROCS can be ignored in some cases, so I assumed the GO runtime needed an extra thread for executing function F3,
 after it was called from C.

I would guess that the new thread is being spawned to run the system
monitor or to run the garbage collector.  But without seeing your
program I don't actually know.

You can check for yourself whether you are running in the same thread
easily enough by calling C.gettid.

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