Skip to main content
Be Bitwise

Putting It All Together

How It All Connects · Assembly & OS track

5 min read

In this module

The Complete Stack

You've travelled from the very bottom of the computing stack to the top. Time to step back and look at the whole landscape — every layer you've met, and how each one rests on the one beneath.

Layer by Layer

Transistors are tiny switches etched into silicon. They flip on and off in response to electrical signals, standing in for the binary values 0 and 1.

Logic gates are built from transistors. AND, OR, NOT, and their combinations carry out the boolean operations that every other piece of computation rests on.

The ALU is built from logic gates. It performs arithmetic and logic on binary numbers: addition, subtraction, comparison, bitwise operations.

The CPU wraps the ALU with a control unit, registers, and a clock. The control unit orchestrates the fetch-decode-execute cycle, ferrying instructions and data into the ALU and parking results in registers.

Memory provides storage beyond the CPU's tiny pool of registers. The cache hierarchy (L1, L2, L3) keeps the hot data close to hand. RAM holds the working set of running programs. Storage devices keep data around when the power goes out.

The operating system rides herd on all those hardware resources. The kernel schedules processes, manages memory, handles device I/O, and presents the syscall interface that every user program leans on.

Programs are what the user actually cares about. They're written in high-level languages, compiled into machine code, loaded into memory by the OS, and executed instruction by instruction by the CPU.

Here's the same stack read from the bottom up, with one concrete thing you met at each layer:

Abstraction Is the Key

Each layer hides the complexity of the one below and offers a simpler interface to the one above. Programmers don't think about transistors. The OS doesn't think about logic gates. The CPU doesn't think about what the program is trying to accomplish. That layered abstraction is what keeps modern computing tractable. Without it, the complexity would crush you.

One Line, Every Layer

Here's the whole stack in action for one line of C, printf("Hello\n");, running on x86-64 Linux in a terminal. Follow it from the top down.

  1. Program. The compiler turned the line into a few instructions: load the address of the string into rdi, then call printf. (GCC quietly swaps a printf of a plain string ending in a newline for the cheaper puts, but the path below is the same either way.) The linker recorded that printf lives in libc.so.6, and when you ran the program the dynamic linker mapped libc in and filled in the address.
  2. Library. printf copies the 6 bytes 48 65 6c 6c 6f 0a (Hello and a newline) into its output buffer. Standard output is a terminal, so the newline tells libc to flush.
  3. System call. libc sets rax = 1 (write), rdi = 1, rsi = the buffer's address and rdx = 6, then executes syscall. The CPU switches from ring 3 to ring 0.
  4. Kernel. The kernel looks up descriptor 1, finds it's a pseudo-terminal, checks that the 6 bytes belong to the process and copies them into the terminal's buffer. Your terminal program, itself just another process, reads them out and draws the glyphs.
  5. Memory. Every one of those steps fetches instructions and data through the caches. Touching the buffer might miss in L1 and pull a 64-byte line in from L2 or RAM; on a first touch of the page, it might even take a page fault while the kernel maps it.
  6. CPU and ALU. Each instruction goes through fetch, decode and execute. The loop that copies bytes uses the ALU to add 1 to a pointer six times and compare it against the end.
  7. Gates and transistors. That add is an adder circuit of logic gates, and each gate is a handful of transistors switching on and off within a single clock cycle.
Predict: change the line to printf("%s\n", (char *)8); so printf reads from address 8. The program prints nothing and the shell says Segmentation fault. Which layers took part in producing that message?

Nearly all of them. printf (library) loads a byte from address 8. The CPU looks that address up in the page tables (memory), finds no mapping and raises a page fault, switching to ring 0. The kernel's page-fault handler sees a user-mode access to an address the process never mapped, so it sends SIGSEGV. The process has no handler and dies. The shell, waiting in wait() for its child, learns the child was killed by signal 11 and prints Segmentation fault. The words on your screen started as a missing page-table entry and were relayed up through the kernel and two processes before you read them.

What You Have Gained

You now understand a computer's architecture from bottom to top. When a program drags, you can reason about whether you're CPU-bound, memory-bound, or I/O-bound. When a system crashes, you can tell the difference between a user-space bug and a kernel-level failure. When someone says "context switch," "page fault," or "cache miss," those terms now name concrete mechanisms you can poke at.

Where to Go Next

This course covered the foundations. Each of these picks up a layer you've just met and goes deeper:

Every one of those topics builds on the ground you've just covered. The layers don't disappear; they just gain more detail.