Reputation: 91
I have a simple go program -
main.go -
package main
import (
"log"
"runtime"
"time"
)
func main() {
runtime.GOMAXPROCS(1)
log.Println("running")
time.Sleep(10 * time.Minute)
}
I build binary like this -
GOOS=linux go build
and run it in a centos machine -
# ./test
2017/10/27 14:20:15 running
I wonder why 2 different cores (1 & 6) are used for this simple program even if GOMAXPROCS
is set to 1.
Sometimes 3-4 cores are also used.
Any idea about this?
Thank you.
Upvotes: -2
Views: 995
Reputation: 31751
You are running four processes. The kernel schedules those onto cores. GOMAXPROCS has nothing to do with this; it only affects the number of threads for a single process, and only user-level code.
Upvotes: 1