ボム君.com

Masa's blog

今まで学んできたITスキルを主に。

Programming: Parallel VS Concurrency

In functional programming, such as Erlang and Haskell could be better suited for answering question of what are the differences between Parallel and Concurrency programming.

According to "Parallel and Concurrent Programming in Haskell",

In many fields, the words parallel and concurrent are synonyms; not so in programming, where they are used to describe fundamentally different concepts.

A parallel program is one that uses a multiplicity of computational hardware (e.g. multiple processor cores) in order to perform computation more quickly. Different parts of the computation are delegated to different processors that execute at the same time (in parallel), so that results may be delivered earlier than if the computation had been performed sequentially.

In contrast, concurrency is a program-structuring technique in which there are multiple threads of control. Notionally the threads of control execute "at the same time"; that is, the user sees their effects interleaved. Whether they actually execute at the same time or not is an implementation detail; a concurrent program can execute on a single processor through interleaved execution, or on multiple physical processors.

Concurrency:

  • It only has one CPU
  • It shared both memory and processing time
  • It has multiple threads programming to handle each task by single CPU

Parallelism:

  • It is truly parallel
  • It has multiple CPUs
  • It does not share memory and processing time

Benefits of Parallelism compared with Concurrency:

  • Better performance
  • Scalability
  • Fault Tolerance
  • Clarity