﻿---
title: Concurrency & Parallelism etc.
date: 2024-03-10
excerpt: Notes on concurrency, parallelism, CPU cores, hardware threads, processes, and threads in operating systems.
tags:
  - OS
  - Concurrency
  - Parallelism
  - Thread
  - Process
cover: https://assets.vluv.space/cover/OS/ConcurrencyvsParallelism.webp
updated: 2026-07-08 07:37:21
lang: en
i18n:
  cn: /concurrency_and_parallelism
  translation: 2
---

## CPU Related Concepts

| Item                       | Concept                                                                                                | Related Concepts                                                                          |
| -------------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------- |
| Number of CPUs             | The number of CPUs installed in a computer                                                             | [Multiprocessor system](https://en.wikipedia.org/wiki/Multiprocessor_system_architecture) |
| Number of CPU cores<br>(physical cores) | A CPU can contain multiple dies, and each die can contain multiple cores. The number of cores is the CPU core count | Wafer, die,<br>core, CPU |
| Number of CPU threads<br>(logical cores) | Intel's Hyper-Threading technology allows one core to execute multiple threads at the same time.<br>8 cores and 16 threads means one core can run two threads, for a total of 16 threads | Hyper-Threading |

> [Understanding the relationship between wafer, die, and CPU - Juejin](https://juejin.cn/post/7316783747491332131)
> [A Simple Understanding of CPU physical count, cores, threads, processes, threads, coroutines, concurrency, and parallelism - Zhihu](https://zhuanlan.zhihu.com/p/490318618)

## OS Related Concepts

- [[ProcessvsThread#Process|Process]]: the basic unit by which the operating system allocates and manages resources. The OS can allocate resources such as CPU time and memory according to each process's needs and priority.
- [[ProcessvsThread#Thread|Thread]]: the basic unit of CPU scheduling and resource allocation. In a multithreaded OS, a thread is the basic unit that runs independently, so it is also the basic unit scheduled and allocated independently.

## Concurrency & Parallelism

|                     | Definition                             | Diagram                                                                                 |
| ------------------- | -------------------------------------- | --------------------------------------------------------------------------------------- |
| Parallelism         | Multiple computational tasks execute at **the same physical moment** | ![image](https://assets.vluv.space/piclist-clipboard-images-20250804194722582.webp)<br> |
| Concurrency         | Multiple computational tasks make progress within **the same time period** | ![image](https://assets.vluv.space/piclist-clipboard-images-20250804194728912.webp)<br> |

The diagram below shows how single-core and multi-core CPUs support concurrency and parallelism. Parallelism requires hardware support; a single-core CPU can only provide concurrency.

<img src="https://assets.vluv.space/piclist-clipboard-images-20250804201457788.webp" alt="concurrency_vs_parallelism" width=50%>

The two are not opposites. For I/O-intensive tasks, when a process or thread is blocked on I/O, the CPU can be assigned to a ready process or thread to avoid sitting idle. Multi-core CPUs also need this strategy to improve CPU utilization.
