Shared State and Messages in Parallel Programs
Parallel work can coordinate through shared objects or by sending explicit messages. Each choice needs rules about ownership and when values are visible.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a local calculation
A worker may update a shared totals record under synchronization, or send a partial total to a combining worker. Local counters and reduction illustrates the latter strategy.
Check result lifetimes
When passing a message containing mutable data, define whether it is copied or transferred. Input ownership provides the common contract.[1]
Decide who owns the mutable resource
Several calculation workers can update one shared object under a lock. Another design gives one worker ownership and sends it update messages. The second design centralizes changes but requires a message lifecycle and ordering contract. See processes and threads.
Shared model: workers enter a protected update region
Message model: workers send operations, owner applies them
Both need a way to report completion
Compare contention and failure possibilities
Message buffering can expand under load. Shared locks can keep workers waiting. Test the same functional behavior under concurrent requests and inspect where work waits.