Sub topic 4
CPU basics: architectures, cores, threads, and cache
This chapter assumes you can identify the CPU on a motherboard and know what GHz and GB mean. It covers the working model of a CPU and the points the A+ Core 1 exam tests.
What the CPU does
The central processing unit (CPU) runs program instructions. It fetches an instruction from memory, decodes it, executes it, and writes back the result. The clock speed, measured in GHz, is how many cycles the CPU completes each second. A higher clock helps, but it is only one factor in performance.
Architectures
An architecture (also called an instruction set) defines which instructions a CPU understands. Software built for one architecture will not run on another without translation.
| Architecture | Used in | Notes |
|---|---|---|
| x86 (32-bit) | Older PCs | Addresses up to 4 GB of RAM |
| x64 (64-bit) | Most desktops and laptops | Intel and AMD CPUs. Runs 32-bit and 64-bit software |
| ARM | Phones, tablets, some laptops | Low power use, so it suits battery devices |
A 64-bit operating system needs a 64-bit CPU. A 32-bit operating system cannot use more than about 4 GB of RAM.
Cores and threads
A core is an independent processing unit inside the CPU package. A dual-core CPU has two, a quad-core has four, and so on. More cores let the CPU run several tasks at once, which helps with multitasking and with programs written to use many cores.
A thread is a sequence of instructions that the operating system schedules on a core. With simultaneous multithreading (SMT), one core can handle two threads. Intel calls this Hyper-Threading. A 4-core CPU with SMT shows 8 logical processors. Those extra threads are not a second core. They fill idle gaps in the core's work, so the gain is smaller than doubling.
Cache
RAM is much slower than the CPU. Cache is a small amount of very fast memory built into the CPU that holds recently used data and instructions, so the CPU waits less.
- L1 is the smallest and fastest. Each core has its own.
- L2 is larger and slightly slower. It is usually per core.
- L3 is the largest and slowest of the three. Cores typically share it.
When the CPU finds what it needs in cache, that is a cache hit. When it does not, that is a cache miss, and it must read from RAM.
Checking your CPU
Windows reports cores and logical processors with PowerShell:
Get-CimInstance Win32_Processor | Select-Object Name, NumberOfCores, NumberOfLogicalProcessorsOn Linux, lscpu shows the model, architecture, cores, threads, and cache sizes:
lscpuIf NumberOfLogicalProcessors is twice NumberOfCores, SMT is active.
Exercise
A technician runs a command on a CPU and sees 6 cores and 12 logical processors. What technology is active, and does the CPU have 12 cores?
Show answer
Simultaneous multithreading (Hyper-Threading on Intel) is active. The CPU has 6 physical cores. Each core runs two threads, which the operating system sees as 12 logical processors.
Exercise
Which cache level is smallest and fastest, and which is usually shared among cores?
Show answer
L1 is the smallest and fastest. L3 is usually shared among cores.