Parallelism vs. Concurrency

There are many texts about this thing already but they all seem, though factually correct, kind of incomplete or too technical, to me. Furthermore I can never immediately remember which one is which, so I need to frame the understanding in some kind of mnemonic or connection.

From the existing ones I quite like the haskell one for its clarity and succinctness, quora one for it's historical view and Joe Armstrong's one for it's funny, yet completely correct picture.

Anyway, here's my take.

Semantics

Let's stay away from computers for a while.

Paralelism we are concerned with is in the sense of beside one another 2 (specifically in time in our case), an opposite of sequential or serial. That is when two actions are happening at the exact same time. It looks like this:

  ^ Action
  |
1 +    +---------------+
  |
2 +    +-----------------------+
  |
  +--------------------------------------->
                                       Time

Action 1 and Action 2 start at the same time and end in different times but nevertheless, they exist in parallel. They both exist in the exact same time instants.

While Concurrency we are concerned with is in the sense of to collide in hostility 3, in state of competition - the state of two actors[1]_ fighting for exclusive access to a resource. This looks like this:

  ^ Actor
  |
1 +         +----*          +----*
  |
2 +   +----*      +----*
  |
  +--------------------------------------->
                                       Time

Where + means an acquistion of exclusive access to the resource and * means releasing it. In this model, there is only a single actor doing its thing in any single point of time and others have to wait until the resource is released. Similarly to how companies are in competition for market share.

Back to computers

Computers used to have only a single processing unit (resource) which allows programs (actors) to run (do their thing) and so only a single program could run at any time.

However, since the computers can operate at much faster speeds than human can perceive through their senses, computer concurrency became a thing in the form of multitasking operating systems - systems where multiple programs can run concurrently but to human user it appears as if the programs run in parallel.

That's why you can listen to Taylor Swift and browse Facebook on your phone at the same time. On the other hand, you can play Counter Strike thanks to parallelism in your graphic card.

Nowadays computers usually have multiple processing units so programs can run truly in parallel but concurrency is still largerly in play with regard to user experience and perception of parallelism.

The connection

This leads me to conclude that in general we need to distinguish two kinds of parallelism to make the connection between these two. A true parallelism as defined above and a perceived parallelism.

Now concurrency is not automatically perceived parallelism but a special case of it is - the case where actors acquire and release the resource so fast, it is imperceptible to any human being.

Pre-emptive multitasking is perceived parallelism but co-operative multitasking is concurrency.

Into Darkness

asyncio is a form of concurrency that achieves perceived parallelism with the right conditions.

threaing and multi-processing is form of concurrency. It might be a form of perceived parallelism depending on what kind of multitasking implements the host operating system.

1

noun: a participant in an action or process. Also UML Actor

2

http://www.etymonline.com/index.php?term=parallel&allowed_in_frame=0

3

http://www.etymonline.com/index.php?term=concur&allowed_in_frame=0

According to my completely layman etymological enquiry through google and wiktionary, it appears the word concur, latin ancestor of concurrency, used to denote "competition" but this meaning disappeared from english language while it remained in others like french or my native czech.