3 ms·
The message passing queues following CSP semantics regarding synchronization is the big deal. If you only ever use buffered queues then you're missing half of t
by fidotron 3y ago
The message passing queues following CSP semantics regarding synchronization is the big deal. If you only ever use buffered queues then you're missing half of the story.
Occam is probably the most important totally forgotten thread of programming language development.
- dboreham 3y agoNot really forgotten because Phil Winterbottom was familiar with it and went on to work on Go.
- packetlost 3y agoCan you elaborate or provide sources on what you mean by "CSP semantics" here?
- Jtsummers 3y agoThey mean communicating sequential processes. Here's a book on the topic by C.A.R. Hoare: http://www.usingcsp.com/ http://www.usingcsp.com/
- dekhn 3y agoThe message passing queues in CSP aren't any different from buffered queues, right? I've been asking people this for some time and never have heard a convincing "no, and here's why they are different". There are CSP implementations in C++ and Python and their implementations seem to be buffered queues that block if there are no readers.
- fidotron 3y agoCSP doesn’t have queues, only blocking channels. Some implementations may provide them on top, as go does. I would suggest reviewing the Hoare book on CSP, it’s very readable.
- dekhn 3y agoI have read it (along with lots Russ Cox wrote about CSP and Go, such as https://swtch.com/~rsc/thread/ https://swtch.com/~rsc/thread/) and McIlroy (https://www.cs.dartmouth.edu/~doug/sieve/sieve.pdf https://www.cs.dartmouth.edu/~doug/sieve/sieve.pdf) . From what I can tell, CSP channels are semantically equivalent to a particular subtype of queues and use the same OS primitives. I'm not an OS expert but I've worked with distributed systems and threads for decades, and nobody I've asked has disagreed that Go's implementation of CSP is an M:N thread model with (blocking) queues.
- deleted 3y ago[deleted]
- Jtsummers 3y agoCSP doesn't need queues (buffered channels) as a primitive because you can create them. Here's a Queue in CSP from the CSP book I linked elsewhere: BUFFER = P⟨⟩ where P⟨⟩ = left?x → P⟨x⟩ P⟨x⟩⌢s = (left?y → P⟨x⟩⌢s⌢⟨y⟩ | right!x → Ps ) If data can be read from left it is and it's enqueued, if data can be written to right (because a reader is available) it dequeues it. But neither the read nor the write block the entire process. Go's buffered channels act in the same way so end up offering a shortcut versus pure CSP. There are other ways that Go deviates from CSP (shared memory, among others) but with channels it's not deviating, just optimizing an existing behavior.