Implementation of goroutines
I have been reading up on concurrency in Go. In particular, I have been wondering about the statement from a presentation by Brad Fitzpatrick:
n, err := io.Copy(dst, src)
- copies n bytes from dst to src
- synchronous (blocks)
- Go runtime deals with making blocking efficient
Now in Go, if you make a call that blocks the current execution, you are (usually) only blocking the current goroutine, not a thread. The Go runtime multiplexes goroutines on fewer OS threads.
The question therefore is: What are the fundamental differences in the implementation of goroutines compared to OS threads that make goroutines so much more lightweight?
I have asked this question on the Go mailing list and the members of the Go team (notably Dmitry Vyukov and Ian Lance Taylor) have been incredibly helpful.
The summary is:
- stack that grows and shrinks on demand
- smaller context, easier to switch
- cooperative scheduling at known points is less work (can make assumptions about CPU state)
- scheduling in user space
Here is the discussion: enjoy!
Note: There are other languages (such as Haskell and Erlang) that also have the concept of lightweight "processes" that allow for blocking calls without blocking OS threads. The concept is sometimes referred to as green threads.
208 comments:
«Oldest ‹Older 201 – 208 of 208 Newer› Newest»
-
V Rise
said...
-
-
July 17, 2026 at 2:20 PM
-
anjani02
said...
-
-
August 3, 2026 at 4:51 PM
-
V Rise
said...
-
-
August 3, 2026 at 9:01 PM
-
Workday
said...
-
-
August 10, 2026 at 4:06 PM
-
Anonymous
said...
-
-
August 11, 2026 at 5:30 PM
-
Anonymous
said...
-
-
August 14, 2026 at 11:53 AM
-
sanjana
said...
-
-
August 21, 2026 at 10:51 AM
-
PMP Academy
said...
-
-
September 20, 2026 at 4:51 PM
«Oldest ‹Older 201 – 208 of 208 Newer› Newest»Excellent article! I really enjoyed your deep dive into the implementation of goroutines and what makes them so lightweight compared to traditional operating system threads. Explaining concepts such as dynamically growing stacks, user-space scheduling, efficient context switching, and the Go runtime's ability to multiplex many goroutines onto a smaller number of OS threads provides valuable insight into Go's concurrency model. Understanding these runtime internals helps developers write more scalable and efficient concurrent applications. As someone associated with Healthcare Digital Marketing Agency in Hyderabad, I appreciate technical content that makes advanced programming concepts easier to understand. Thanks for sharing this excellent resource!
Looking forward to your next informative article. Keep sharing such excellent content!online ba analyst course
Excellent post! I enjoyed your explanation of goroutine implementation in Go. Your breakdown of lightweight concurrency and the Go scheduler makes it easier to understand how goroutines efficiently handle concurrent tasks. Thanks for sharing this valuable resource!
As someone associated with Healthcare Digital Marketing Agency in Hyderabad, I appreciate technical content that simplifies modern programming concepts and promotes efficient software development.
MicroStrategy course content provides a structured curriculum for learning business intelligence and enterprise analytics. This microstrategy course content covers schema objects, metrics, reports, dashboards, data modeling, visualization, security, and administration. Students strengthen their knowledge through practical exercises and projects.
This is a helpful resource for Salesforce aspirants. Salesforce admin classes can provide practical knowledge of administration, configuration, reporting, and platform management, making them useful for career development.salesforce admin classes
Power BI Classes Online can provide flexible learning for students and professionals interested in data analytics and business intelligence. Classes that include real-world projects can help learners understand how to create reports, analyze data, and build interactive dashboards.power bi course online
Thanks for sharing this clear nd concise blog!
IATA Corse in Delhi
This is a useful introduction to the implementation of goroutines. The practical approach makes it easier to understand how concurrent tasks can be handled and why goroutines are useful for efficient programming. A helpful reference for developers learning Go and exploring concurrency concepts.
PMP Certification Course in Hyderabad
Post a Comment