On Sun, Jan 22, 2023 at 11:48 PM TheDiveO <harald.albre...@gmx.net> wrote: > > > On Sunday, January 22, 2023 at 12:18:34 AM UTC+1 Ian Lance Taylor wrote: > > Using runtime.LockOSThread does not exempt the goroutine from GOMAXPROCS. > > I was asking to elaborate more on this previous answer of yours, as I > don'tunderstand yet how GOMAXPROCS relates to (preemptive?) go routine > scheduling.
I see. GOMAXPROCS is the number of goroutines that may run simultaneously. See https://pkg.go.dev/runtime#GOMAXPROCS . So if GOMAXPROCS is set to 4, then up to 4 goroutines may be running at one time. If there are more goroutines ready to run, they will block until one of those 4 goroutines pauses for some reason. If the 4 goroutines keep running for long enough without pausing, the runtime will interrupt one of them to give other goroutines a chance to run. All of this is true whether or not any goroutines have called runtime.LockOSThread. The LockOSThread function affects which thread is used to run a goroutine. It does not otherwise affect the scheduler. 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVebTR%2B8sMj_q6Kbnt09a%3D45ZXr5KBp3%3DtrPY%2BJnM4_bA%40mail.gmail.com.