Tuesday, 9 April 2013

Communicating Sequencial Processes

CSP for short. It's a language for describing processes. For example:

   Blog = idea -> writeup -> post -> Blog

is a process that describes how one writes posts. Notice that this says nothing about how things happen. All this shows is the sequence of events. An important feature of CSP is the ability to compose processes. Imagine that we do your thinking with tea:

 Thinking = tea -> writeup -> Thinking

After you had some tea, you do your idea write up and then go back to drinking tea. To show that you drink tea while writing blogs the two processes can be combined:

 Blogging = Thinking [| writeup |] Blog

This becomes a new process where events idea, tea and  post happen in a defined sequence but independent of the other process. However, writeup must be done in synchronization. This means that once an idea happens Blog process will effectively block and wait until process Thinking arrives at event writeup.

Being able to compose processes is a very powerful concept. Visually each of the processes can be represented in a state transition diagram. Obviously, things get a lot more complex once you try to put them together even for something as simple as Blogging.

There are some advanced tool that help with writing CSP, one is FDR (Failures, Divergences and Refinements) and Probe. Also, Using CSP is a great but dense book that covers just about everything a beginner user will need.

No comments:

Post a Comment