On this page
Concurrency vs. Parallelism
Prev: concurrency | Up: concurrency | Next: Synchronization & Coordination
Rel: Python Concurrency & Parallelism, JS Event Loop
Ref: Wikipedia โ Concurrency (Computer Science)
Tags: #public #prog #programming #concurrency
Contents
Structure vs. Execution
- Concurrency is about dealing with multiple tasks at once (interleaving progress on 1 or more cores โ ideal for I/O-bound work waiting on networks or disks).
- Parallelism is about doing multiple computations at the exact same instant across multiple CPU cores (required to speed up CPU-bound work).
Processes, OS Threads & Coroutines
| Unit | Memory Space | Scheduler | Creation / Switch Cost |
|---|---|---|---|
| OS Process | Isolated virtual memory | OS kernel (preemptive) | High (MBs, IPC needed) |
| OS Thread | Shared heap, own stack | OS kernel (preemptive) | Medium (1โ8 MiB stack, syscall switch) |
| Coroutine / Green Thread | Shared heap, tiny frame | Language runtime / event loop | Very low (KBs, scales to 100k+ tasks) |
Linked from
Related notes
- tuts/programming/concurrency Linked here; links to this page; shared tags: #concurrency, #prog, #programming
- tuts/programming/concurrency/synchronization_and_coordination Linked here; links to this page; shared tags: #concurrency, #prog, #programming
- tuts/c/stdlib/threads links to this page; shared tags: #prog
- tuts/c/stdlib/threads/mtx_lock links to this page; shared tags: #prog
- tuts/c/stdlib/threads/thrd_create links to this page; shared tags: #prog
- tuts/python3/tutorials/advanced_python_internals/concurrency_and_parallelism Linked here; shared tags: #concurrency
- tuts/javascript/tutorials/event_loop_and_async_programming Linked here
- tuts/cpp/stdlib/concurrency shared tags: #concurrency, #prog
- tuts/cpp/stdlib/concurrency/atomic shared tags: #concurrency, #prog
- tuts/cpp/stdlib/concurrency/jthread shared tags: #concurrency, #prog