Concurrency & Parallelism

...and why you should care

So what are this terms?

Concurrency

When you do different things at the same time.

 

Think boiling water and checking Facebook.

Parallelism

When you span a job over multiple workers.

 

Think a lot of people washing dishes.

For visual people

When to use what?

Concurrency

Communication-heavy tasks

Par example Network, Disk I/O

Threads

We also have:

Coroutines aka Green Threads aka Fibers

Tasks & Promises (JavaScript)

Actors (Erlang & Co.)

Guilds (Ruby 3)

...and besides this:

A hell lot of issues

(which apply to parallel programs too)

Main source of headache:

  • Resource Sharing

  • Zombie... Threads

  • Race Conditions

  • Dead Locks

Before we move on...

Asynchronous Execution

What the fuck is it?

Parallelism

Computation-heavy tasks

Par example Simulations, Linear Algebra

Processes

Instruction Lvl

P1 is washing dishes

P2 is cooking meth

P3 has a break

Data Lvl

P1, P2 and P3 are washing dishes... or cooking meth, whatever

The mighty DAG

Directed Acyclic Graph

No NDA - No Problems

No NDA - No Problems

The not-that-mighty-but-still-important MapReduce

Making  a salad

Making a salad #2

Thank you!

Thank you!

Thank you!

T0

T1

T2

goo.gl/SQZWBz

FAF Lecture #4: Concurrency & Parallelism

By Alexandru Burlacu

FAF Lecture #4: Concurrency & Parallelism

  • 194