3 ms·
In the future, I think thats what I'll say. Thanks.
by dekhn 3y ago
In the future, I think thats what I'll say. Thanks.
- pcwalton 3y agoI usually just say that Go implements "userspace threading", since that's really what it is. Some early, pre-pthreads, implementations of Linux threads worked the same way as Go does and they usually called such implementations "M:N", to indicate M userspace threads mapped onto N kernel threads, so "M:N" is a good descriptor too.
- dekhn 3y agobut that's not really accurate. It uses system threads. Userspace threading doesn't make a transition to kernel (IIUC).
- pcwalton 3y agoGo doesn't need to transition to the kernel to switch threads, does it? It just saves and loads the register state in userland.
- dekhn 3y agoIIUC it can, sometimes, avoid a kernel transition when it knows it can schedule the recipient of a message, but I believe that golang creates a threadpool for running goroutines on platforms that use thread primitives. From https://github.com/golang/go/blob/c7d6c6000a84b61ac8bb2e38e855ad120914658a/src/runtime/proc.go#L19 https://github.com/golang/go/blob/c7d6c6000a84b61ac8bb2e38e8... I believe "worker threads" are OS threads.