NOTE
2.13 concurrent
Execution order within a goroutine differs from visibility across goroutines. These notes organize Go concurrency constraints through synchronization events.
This is a historical learning note and may contain outdated or incomplete understanding.
1. Concurrency Facilities
1.1. goroutine + channel
1.2. sync Package
2. Synchronization
2.1. Sequential Consistency Model
Within the same Goroutine thread, the sequentially consistent memory model is guaranteed.
2.2. happens-before
Sequential consistency is not guaranteed across goroutines. Synchronization must rely on explicitly defined synchronization events.
2.2.1. channel
- buffered channel:
ch <- v≤v <- ch- Explanation: sending data to a buffered channel happens before receiving the data from the buffered channel
- That is, the writer needs to produce data first and put it into the channel; then the reader can consume the data from the channel
- unbuffered channel:
v <- ch≤ch <- v- Explanation: receiving data from an unbuffered channel happens before sending data to the unbuffered channel
- That is, when the reader reads data from the channel, it blocks until the writer sends data to the channel
3. Concurrency Patterns
4. Multi-core CPU
Go Multi-core Parallelization PythonWise: CPU Affinity in Go tsingson/cpuaffinity: pin goroutine to cpu core as thread
5. References
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub