Skip to content
BIASED

What a computer system is

Block 1 of 6~3 min

What happens when a program runs

A program is a text file. When we run it, characters appear on a screen a few milliseconds later, and between the two stand a compiler, a linker, an operating system, a processor executing billions of instructions per second, memory chips, a display driver and transistors switching on and off. Each of them is a layer built so that the layer above does not have to think about it. This course opens those layers one at a time, from the bits of a single number to a process talking to another over the network.

Notation. For the performance equation, II is the dynamic instruction count, CPI\mathrm{CPI} the average cycles per instruction, TcT_c the clock period and f=1/Tcf = 1/T_c the clock rate. Numbers written 0x… are hexadecimal; the next topic explains them.

Take the smallest C program that does something visible:

#include <stdio.h>
int main(void) { printf("hello, world\n"); return 0; }

Six steps stand between the source and the pixels:

  1. Source. hello.c is bytes on disk. The string "hello, world\n" alone is 13 bytes.
  2. Build. Preprocessor, compiler, assembler and linker turn C into an executable with the code of printf.
  3. Load. The shell asks the OS to create a process; the kernel maps the file and starts at the entry point.
  4. Execute. The processor fetches the instructions of main. printf ends in write(1, buffer, 13).
  5. System call. write switches into the kernel, which hands the 13 bytes to the terminal driver.
  6. Output. Glyphs become pixels on the display.

One function call involves every later section of the course: data representation, the instruction set, memory, the processor, system calls, processes, files and the toolchain.

Answers are saved on the server and tied to this browser until you sign in.