Communicating Sequential Processes is a processing paradigm. The concept of CSP were first introduced and described by Tony Hoare in 1978 in his paper Communicating Sequential Processes. The basic of it is a formal language to describe patterns of interactions in concurrent systems.
The formal language in mathematics are defined typically as the alphabet or information rules. You would in propositional calculus have comprised of Latin and Roman letters and optional specials symbols. The formal rules are all Latin letters with an index and symbols. Patterns of interactions are different ways to describe interactions.
Communicating Sequential Processes is being used in the Golangs channels.
- Sequential programming is easy
- Lambdas are easy for concurrency due to the lack of dependencies
- Message parsing allows us to split a program into a set of processes which can communicates at certain junctions
- Parsing a message involves blocking on both the sending and receiving side
- The receiving side can alternate between multiple channels, the equivalent of select
Concurrent programming is not parallel programming. As a result, a concurrent programming is a model of interaction of processes concurrently. Which could be multiple clients accessing a server avoiding deadlock, but would be able to happen simultaneously or at different times.
Communicating Sequential Processes has two main concepts
The concept of synchronization is having multiple concurrent processes allowing to synchronize with each other having their input and output (I/O) synchronized. Firstly, the first process could state that is is ready to output to the second process specifically. Secondly, the second process states that is is also ready to have input from the first process specifically. However, if you have one of these happens without the other being true the process in question will be put on a wait queue until the other process is ready.
The guarded command is a normal command like an if statement. In todays programming language you’ll called them pre-conditions. It is widely used in many programming languages. Let’s look at an example of guarded commands syntax
x > 0 → y := 2*x
Now x>0 is the guard and y:=2*x is the command.
Something to take into consideration are the explicit naming of communication processes. By passing values types that do not correspond to each other would lead to both processes crashing. CSP does not assume any permanent storage buffer, this highly complicate the process of transmitting data. Finally it fails to suggest any proof method to assist in the development and verification of correct programs. But it has made a big impact and breakthrough for functional programming and Computer Science in general.