DEV Community

Cover image for On Concurrency
Odai Athamneh
Odai Athamneh

Posted on

On Concurrency

Photo by Jørgen Håland on Unsplash


This is a high-level overview of concurrency in programming languages. I'm writing it for my own review purposes, but maybe you'll find it useful too.

Motivations

  1. 🤔 Logic. Some problems are naturally concurrent so it makes sense to handle them this way. Think web servers, graphics, AI.
  2. 🏎️ Speed. Concurrency lets us fully use multiple processors or cores to maximize computational speed.
  3. 📡 Distribution. Machines that work across the internet are inherently concurrent. Writing concurrent software helps to address their unique needs.

Types of Concurrency

There are a few different types of concurrency to be aware of:

venn diagram of concurrency types

Note that coroutines are off to the side. Since they switch between tasks at defined points (not arbitrarily), they aren't truly considered concurrent.

Levels of Concurrency

Going from most atomic (smallest divisions) to least atomic (biggest divisions):

  1. 🦐 Instruction-Level. Multiple instructions executing at once. Mostly hardware. Focus of research for 40+ years, but physical limits have been reached.
  2. 🪓 Vector-Level. Split up large datasets. Big usage in GPUs. Only benefits certain types of programs.
  3. 🐫 Thread-Level. Current focus. Needed for multiple cores. Requires programs to be specially written to take advantage.

Top comments (0)