Computer Science

Computer Architecture and Operating System

Contemporay computing machine foundations.
This data is up to date on Jan 2026

Central Processing Unit (CPU)

Central Processing Unit (CPU) is the brain of a computer to execute instructions and perform arithmetic operations on Instruction Set Architecture (ISA) like ARM (Mobile), x86 (Traditional Desktop), RISC-V (Open Source). Each ISA has its own assembly language.

CPU Performance

Single-Core Performance = Clock Speed x IPC (Instruction Per Cycle)

Most everyday applications rely heavily on one or two fast cores. Multiple cores helps for multitask and parallel computation. It depends on the software whether it is coded scalable or not. Some language have auto-parallelizing feature but it's rare for complex desktop app. The OS will schedule threads to the cores.

Amdahl's Law, Speedup = 1(1P)+PN\frac{1}{(1 - P) + \frac{P}{N}} where P is the fraction of time spent on parallelizable code and N is the number of cores.

Windows Task Manager Metric

FeatureCPU 100%GPU 100%
WorkloadAll logical processors are fully occupied with tasks.At least one specific engine (usually 3D or Video) is fully occupied.
FrequencyNot necessarily max.Not necessarily max. The clock speed varies based on the type of load.
Power UseUsually high, but "stalling" (waiting for RAM) can keep power lower than a stress test.Varies wildly depending on which engine is hit (3D vs. Encoding).

Types of Chips

chip

TypeDescriptionExample
MicroprocessorCPU on chip. Does not include memory, storage, IODesktop CPU
MicrocontrollerSingle-chip computer that integrates a CPU, memory and peripheralsArduino
SoC (System on a Chip)Integrates one or more CPU, RAM, microcontrollers into one systemRaspberry Pi, Smartphone, tablet, laptop

Bus

cs

Internal Bus by Motherboard

CPU will have dedicated wires to GPU, RAM and chipset (peripherals) which looks like a star-topology where CPU is the center. Inside of the CPU, it has a ring or mesh topology to connect all the cores and cache.

Protocols

GenerationBandwidth per Lane (x1)Full Slot Bandwidth (x16)Standard in 2026
PCIe 4.0~2 GB/s~32 GB/sBudget PCs / Older Macs
PCIe 5.0~4 GB/s~64 GB/sHigh-end Desktops / Servers
PCIe 6.0~8 GB/s~128 GB/sCutting-edge AI Servers
  • PCIe (Peripheral Component Interconnect Express) is the interface standard for connecting internal computer components. Usually connect to GPU and primary SSD.
  • DDR (Double Data Rate) tick on both edges of the clock. Used on RAM.
  • DMI (Direct Media Interface) is the interface standard for connecting chipset and secondary storage (SATA / HDD / Extra SSD) all connected to this highway.
  • NVMe (Non-Volatile Memory Express) is a type of flash memory and can handle parallel commands. THis fix the SATA problem. It lies on M.2 slot on the motherboard that is direct to CPU.
  • SATA protocol, which was designed for slow, spinning mechanical hard drives which is sequential access.

Bandwidth

ComponentTypeBandwidthTypical WidthDescription
CPU DesktopInternal~500 GB/s256-bitData moves between cores and cache (L2/L3)
CPU ServerInternal~1792 GB/s512-bitCPU Internal Fabric (Mesh/Ring)
CPU DesktopExternal~50–100 GB/s128-bitTypically uses Dual-Channel DDR5
CPU ServerExternal~300–460 GB/s512-768 bitXeon or EPYC (8–12 channels)
GPUExternal~64 GB/sx16 lanesPCIe 5.0 x16. Bidirectional aggregate of 128 GB/s
GPUInternal~1700–1800 GB/s512-bitGDDR7 RTX 5090 VRAM Bus
GPU HBMExternal~4800 GB/s6144-bitH200 (6 stacks on-package)
NVMe SSDExternal~8 GB/sx4 lanesPCIe 4.0 x4 dedicated to one M.2 SSD
ChipsetExternal~16 GB/sx8 lanesConnects via DMI 4.0 (Intel) or PCIe (AMD)

External Bus by Motherboard

Protocols

ProtocolSpeedUse Case
USB3~1 GB/sUniversal Peripherals
Thunderbolt 5 / USB4 v2~10 GB/sPC
GbE~10 Gb/sOne of the protocol on RJ-45 copper cable. May only travel < 100 meters

Embedded System Buses

BusTypeUse CaseUse Today
SPI (Serial Peripheral Interface)Synchronous serialDirect, point-to-point communication between two devices without a shared clockHighly used today to debug with UART-to-USB as serial monitor. Located at COM port
I2C (Inter-Integrated Circuit)Synchronous serialConnecting many low-speed sensors to a single controller using only two wiresUsed in IoT Sensors, smartphones
UART (Universal Async Receiver Transmitter)Asynchronous serialWhen you need to move a lot of data very fast over short distances with simple 2-wire (TX/RX)Used in SD cards, displays, audios
CAN (Controller Area Network)Message-basedExtremely robust, noise-resistant communication for "noisy" environments like engines or factoriesAutomotive, industrial automation
Debouncing is a technique to remove noise from signal (hardware and software method available)

Memory

Memory is a volatile, temporary quick storage managed by memory management. Usually it's called RAM(Random Access Memory). A paging/virtual memory maps shorter virtual memory address to physical memory address.

  • GPU Overflow: Share some RAM with GPU
  • RAM Overflow: Swap(borrow) to disk
  • RAM as Buffer: Cache files from storage. When RAM is full, the kernel can clean the cache files to free up memory

RAM Types

RAM TypeActual Bandwidth (GB/s)Latency (ns)Description
DDR417 – 25.610-12Standard PC RAM (Per channel)
DDR538 – 51.210-14Modern PC RAM (Per channel). Low latency
LPDDR5X51 – 8515-30Low power, high density for mobile devices
GDDR7128 – 192 (per chip)30-50Ultra-high performance graphics memory. Have the highest frequency.
UMA (Apple Silicon)68 (M1) – 120 (M4)15-20Unified Memory (M4 Max / M1 Ultra example), CPU and GPU looks on the same memory
Server RAM (RDIMM)200 – 40015-20Multi-channel (8-12) data center RAM. Registered DIMMs is stable and less error. Can have terrabytes of RAM
High Bandwidth Memory (HBM3)100 – 102410-20High-end Servers, GPUs
  • DRAM (Dynamic Random Access Memory): have its own chip to map physical address to RAM's actual logic gate address to deal broken circuit and evenly distribute the use of gates to increate durability
  • PMIC (Power Management Integrated Circuit): Modern RAM manage power supply by its own by demand
  • Peak speed of the RAM can increase 20~50% of its typical speed
  • Frequency of RAM is measured in MT/s (Megatransfer per second)

Storage

SSD, HDD is a storage. Read Only Memory (ROM) is used for storing instructions. It was slow but non-volatile. Mask ROM can't be overwritten while flash ROM can.

Cache

Cache TypeRole
CPU cache (L1/L2/L3)Stores recently used memory
Disk cacheStores recently accessed disk blocks
Filesystem cacheBuffers file reads/writes
Web/app cacheHigh-level user-space caching
  • L1: Closest to core, fastest, smallest (~32KB)
  • L2: Shared per core or pair (~256KB-1MB)
  • L3: Shared across all cores (~2MB-64MB)

Firmware & Boot Process

Firmware is the permanent software programmed into a hardware device's read-only memory. It is usually written in C/C++ or assembly language and compiled to binary machine code based on the chip specification. It provides the necessary instructions for how the device communicates with other hardware. Bootloader is a tiny program responsible for loading the main firmware/OS. GRUB, U-Boot, Windows Boot Manager are examples.

The PC Boot Sequence

Hardware Initialization (Firmware)

  1. Reset Vector: The CPU wakes up in a "dumb" state and jumps to a hardcoded address in the BIOS/UEFI chip.
  2. POST (Power-On Self-Test): The firmware checks if the CPU, RAM, and GPU are functional. If you hear "beeps," it's usually a POST failure.
  3. Hardware Config: UEFI sets up memory speeds, PCIe lanes, and internal power management.

Boot Manager

  1. Partition Search: UEFI scans storage devices for an EFI System Partition (ESP).
  2. Execution: It runs the .efi boot manager (e.g., GRUB). Secure Boot may verify the file's digital signature here.

Kernel Initialization (The OS Takes Over)

  1. Loading the Kernel: The bootloader loads the OS Kernel (e.g., vmlinuz) and an Initial RAM Disk (initrd) into RAM.
  2. Hardware Discovery: The Kernel uses ACPI tables (provided by UEFI) to find every piece of hardware on the motherboard. Unlike embedded systems, PCs are "Plug and Play" because of this discovery phase.
  3. Mounting Root: Once it finds the disk drivers, it mounts the main storage and starts the first user process (systemd on Linux).
  4. Background services start. User space is ready.

Embedded System Boot

Unlike PCs, embedded systems are often "static"—the hardware doesn't change, so the kernel doesn't need to "discover" it.

  • The Device Tree (.dtb): Instead of ACPI, embedded systems use a Device Tree. This is a file that tells the kernel: "The GPIO controller is exactly at address 0x3F200000."
  • Example (Raspberry Pi):
    1. GPU Boots First: On the Pi, the GPU actually wakes up before the ARM CPU!
    2. Firmware Loading: The GPU loads bootcode.bin from ROM and start.elf from the SD card, which then wakes up the CPU.
    3. Kernel Execution: CPU starts the Linux kernel with the provided Device Tree.

Low-Level Development

Development Tools

ToolUse
Compiler: gcc, clangConvert .c/.cpp to .o
AssemblerConvert .asm to .o
LinkerLink .o files into final binary using linker script
Debugger: gdbGNU Debugger for C/C++
OpenOCDOpen On-Chip Debugger
FlasherWrite binary into the chip
Build System: make, cmake, npmAutomate above steps
QEMUEmulator
JLink DebuggerA very eficient piece of hardware, connects to your PC and the chip for debugging

Analysis Tools

ToolUse
OscilloscopeView voltage and current to check a GPIO pin
Logic AnalyzerView digital signal over time — usually across multiple lines. Great for reverse engineering, debugging SPI, I2C, ...

Some CPU have a trace unit that records every instruction executed. Debugger use symbol + memory maps to remember the address of a memory location. CPU execution is abstract using symbol tables and IDE/GDB integration.

Real Time Operating System (RTOS)

An OS kernel designed for embedded systems that need predictable timing and task scheduling.

RTOS kernelWho Made ItNotes
FreeRTOSAmazonMost popular RTOS ever. Open-source, tiny (<10KB), easy to port.
ZephyrLinux FoundationModular, modern, built for IoT. More complex, includes full drivers, POSIX-ish API.
CMSIS-RTOS RTXArmIntegrated in ARM ecosystem.
TI-RTOSTexas InstrumentsTI-specific, optimized for their chips. Not as portable.

Operating System

The manager of computer resources and processes.

ComponentDescriptionProperties
ProgramA static set of instructions (an application)File-based, stored in disk
ProcessA running instance of a programOwn independent memory space, isolated, can have multiple instances
ThreadA lightweight execution unit within a processShared memory with all other threads in the same process, concurrent, low overhead. Failing thread can cause the process to crash
TaskGeneral unit of work (Process or Thread)Scheduled by OS scheduler, priority based. Moves out (context switching) of CPU when it's terminated or need to wait for something
SchedulerDecides which task runs nextThe algorithm is usually hybrid of round-robin and priority

OS Mechanism

  • IPC (Inter-Process Communication): message queues, shared memory, socket, signal, semaphore, event flags.
  • Race Conditions: If two threads try to change the same piece of data at the same exact time, the data can become corrupted.
  • Deadlocks: Thread A is waiting for Thread B to finish, but Thread B is waiting for Thread A. They both get stuck forever.
  • Starvation: A thread is never given a chance to run.
  • Mutex: a lock so only one thread can own it. Used to protect shared resources. A thread can spinlock to acquire lock repeateadly.
  • Semaphore: a counter that allow N threads to pass or wait.
  • ISR(Interrupt Service Routine): Signal kernel to run an interrupt. Interrupt vector table maps an interrupt trigger to a handler function which tells what to do.

POSIX (Portable Operating System Interface)

A standard kenel call API for UNIX-like OS. It's implemented on UNIX, Linux, macOS but not Windows. Nowdays, developers use standard C/C++ libraries to implement POSIX for cross-platform. In POSIX, everything is a file; In windows everything is an object handle.

File System

FSNotes
ext4Default in Linux, simple, reliable and efficient
FAT32Universal, low-overhead, compatiblity, used for flash drives and SD cards
exFATLess universal, solve more than 4GB files that FAT32 has
NTFSWindows default, complex and advanced
APFS/HFS+Apple systems
LittleFS / SPIFFSFor embedded systems (flash memory)
XFSEffective on large files, teribble with tiny files. Once created, can never shrink
F2FSFor flash drives (like SD cards)
s

Copyright © 2026 Nut17. All rights reserved.