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
- 🤔 Logic. Some problems are naturally concurrent so it makes sense to handle them this way. Think web servers, graphics, AI.
- 🏎️ Speed. Concurrency lets us fully use multiple processors or cores to maximize computational speed.
- 📡 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:
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):
- 🦐 Instruction-Level. Multiple instructions executing at once. Mostly hardware. Focus of research for 40+ years, but physical limits have been reached.
- 🪓 Vector-Level. Split up large datasets. Big usage in GPUs. Only benefits certain types of programs.
- 🐫 Thread-Level. Current focus. Needed for multiple cores. Requires programs to be specially written to take advantage.
Top comments (0)