What are the differences between concurrency computational models and concurrency patterns?

116 Views Asked by At

Concurrent computational models includes actor model, CSP, Petri nets, etc.

Concurrency patterns includes active objects, barrier, reactor, monitor, scheduler, etc

  1. What are the differences (and also maybe relations) between concurrency computational models and concurrency patterns? It is interesting to notice that wikipedia's Design Patterns patterns template lists "Actor model" under concurrency patterns. That makes me even more unsure about the question I asked above.

  2. I don't have much exposure to them, but concurrency models seem to be mentioned more often than concurrency patterns. Do concurrency patterns fall out of favor?

  3. Can different concurrency patterns and different concurrency models be used in a mix and match way, or are some concurrency patterns only used with some concurrency models?

If possible, could you give some references that back up your reply or comment?

1

There are 1 best solutions below

0
Sam Furlong On

So, concurrency computational models are way of modeling and thinking concurrent systems mathematically . For example, the actor model in a very theory heavy research paper wouldn't really say anything about how an actor can be implemented, but merely the requirements of an actor, its just a way of reasoning mathematically about concurrent systems. Patterns are just ways to structure your code, which are the same as a design pattern only for concurrency. The distinction is (imo) blurred a little bit with something like actors where, if you use something like akka, then the pattern of your code is just "make everything an actor."

A concurrency pattern is just a design pattern that uses certain system primitives/language features to produce a correct concurrent implementation.

A computational model is a way of mathematically reasoning about some computation.

All concurrency patterns are based on an underlying computational model. In computer science, you should be able to mathematically/logically prove the correctness of your program, so you could say that all concurrency patterns can be proved or were based on some abstract mathematical model before they were implemented.

Maybe an imperfect example, but lambdas and closures in many languages are based off of lambda calculus. So if I tell you to use lambda as a callback to a network request I am talking about a pattern that relies on a computational model of lambda calculus.

Edit

You can mix an match computational models, and patterns as much as you want in your code, and it is likely that you will do so. That being said some patterns like the actor pattern are pretty much a silver bullet if you are using them. For example, Actors make locking redundant. If you were writing a research paper, you probably wouldn't mix computational models, although I am not an academic so I don't really know :)