This handout teaches Theme A1, Computer fundamentals, for the course first assessed in 2027: hardware, data representation, logic and operating systems.
Prerequisites: powers of 2 ($2^{10} = 1024$) and simple arithmetic.
IB Computer Science SL · Topic 1
8:35
Computer fundamentals
You tap a photo app. Within a second its code is copied from storage into memory, the processor runs millions of instructions, the graphics chip draws the…
English narration · English and 中文 subtitles you can switch
This handout teaches Theme A1, Computer fundamentals, for the course first assessed in 2027: hardware, data representation, logic and operating systems.
Prerequisites: powers of 2 ($2^{10} = 1024$) and simple arithmetic.
You tap a photo app. Within a second its code is copied from storage into memory, the processor runs millions of instructions, the graphics chip draws the picture, and the operating system shares the processor with the music still playing. This handout follows that path.

The central processing unit 中央处理器 (CPU) runs program instructions. Its main parts are:
| Part | Job |
|---|---|
| control unit 控制单元 (CU) | fetches and decodes instructions, and sends control signals to the other parts |
| arithmetic logic unit 算术逻辑单元 (ALU) | does arithmetic (add, subtract) and logic (AND, compare) |
| registers 寄存器 | tiny, very fast stores inside the CPU |

| Register | Holds |
|---|---|
| program counter (PC) | the address of the next instruction |
| memory address register (MAR) | the address being read or written |
| memory data register (MDR) | the data or instruction just read, or about to be written |
| current instruction register (CIR) | the instruction being decoded and executed |
| accumulator (ACC) | the result of the last ALU operation |
The CPU is joined to memory by buses 总线, sets of parallel wires: the address bus carries addresses from the CPU to memory, the data bus carries data both ways, and the control bus carries signals such as "read" and "write".

The clock speed 时钟频率 is the number of cycles per second: a 3 GHz CPU has $3 \times 10^9$ clock ticks per second. Performance also depends on the number of cores 核心 (each core runs its own instructions at the same time) and on the size of the cache.
A graphics processing unit 图形处理器 (GPU) has thousands of simple cores that do the same operation on many pieces of data at once.
| CPU | GPU | |
|---|---|---|
| cores | few, powerful | thousands, simple |
| good at | varied tasks with many decisions | the same calculation on lots of data |
| uses | running the OS and apps | graphics, video, machine-learning training |
The CPU and GPU work together: the CPU runs the program and hands the parallel work, such as drawing each pixel, to the GPU.
| Type | Volatile? | Use |
|---|---|---|
| RAM 随机存取存储器 | yes: loses its data without power | the programs and data in use now |
| ROM 只读存储器 | no | the start-up instructions (firmware) |
| cache 高速缓存 | yes | copies of the data the CPU uses most, inside or next to the CPU |

Cache works because programs reuse the same data and instructions again and again. Level 1 cache is the smallest and fastest; levels 2 and 3 are larger and slower, but all are faster than RAM. A cache hit finds the data in cache; a cache miss must fetch it from RAM.
Secondary storage 辅助存储器 keeps data without power:
| Type | How it stores bits | Strengths | Weaknesses |
|---|---|---|---|
| hard disk (HDD) | magnetised spots on spinning platters | cheap per gigabyte | moving parts, slower |
| solid state (SSD) | electric charge in flash memory | fast, silent, robust | dearer per gigabyte |
| optical (DVD) | pits read by a laser | cheap to distribute | small, slow |
Compression 压缩 makes files smaller, so they take less storage and transfer faster.
WWWWWBBBWW becomes 5W3B2W.Cloud computing 云计算 provides computing resources over the internet, paid for as they are used.
| Service | The provider supplies | Example |
|---|---|---|
| SaaS (software as a service) | a finished application | web e-mail, online office apps |
| PaaS (platform as a service) | a platform to build and run your own apps | a hosted database and web server |
| IaaS (infrastructure as a service) | virtual machines, storage and networks | renting servers by the hour |
Advantages: no hardware to buy, scales up and down, accessible anywhere. Disadvantages: needs a reliable connection, ongoing costs, and the data is held by another company.
| English |
|---|
| central processing unit/ˈsentrəl ˈprəʊsesɪŋ ˈjuːnɪt/ |
| control unit/kənˈtrəʊl ˈjuːnɪt/ |
| arithmetic logic unit/əˈrɪθmətɪk ˈlɒdʒɪk ˈjuːnɪt/ |
| register/ˈredʒɪstə/ |
| bus/bʌs/ |
| clock speed/klɒk spiːd/ |
| core/kɔː/ |
| graphics processing unit/ˈɡræfɪks ˈprəʊsesɪŋ ˈjuːnɪt/ |
| RAM/ræm/ |
| ROM/rɒm/ |
| cache/kæʃ/ |
| secondary storage/ˈsekəndəri ˈstɔːrɪdʒ/ |
| compression/kəmˈpreʃn/ |
| lossless/ˈlɒsləs/ |
| lossy/ˈlɒsi/ |
| cloud computing/klaʊd kəmˈpjuːtɪŋ/ |
Computers store everything as binary 二进制 digits, bits 位, each 0 or 1. Eight bits make a byte 字节.


| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| bits of 182 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 |
$128 + 32 + 16 + 4 + 2 = 182$. With $n$ bits there are $2^n$ different values: 8 bits store 0 to 255.
Hexadecimal 十六进制 (base 16) uses the digits 0–9 and A–F (10–15). Each hex digit stands for exactly 4 bits, so hex is a short, readable way to write binary: 1011 0110 is B6, and $11 \times 16 + 6 = 182$. Hex is used for colour codes (#FF8800) and memory addresses.
| Unit | Size |
|---|---|
| kibibyte (KiB) | $2^{10} = 1024$ bytes |
| kilobyte (kB) | 1000 bytes |
| megabyte (MB) | $10^6$ bytes |
| gigabyte (GB) | $10^9$ bytes |
Two's complement 补码 stores negative integers: the leftmost bit has a negative place value ($-128$ in 8 bits). To write $-42$: write 42 as 00101010, flip every bit to 11010101, then add 1: 11010110. Check: $-128 + 64 + 16 + 4 + 2 = -42$. Eight bits store $-128$ to $127$.

Worked examples:
A higher sample rate, bit depth or colour depth gives better quality and a bigger file.
| English |
|---|
| binary/ˈbaɪnəri/ |
| bit/bɪt/ |
| byte/baɪt/ |
| hexadecimal/ˌheksəˈdesɪml/ |
| two's complement/tuːz ˈkɒmplɪmənt/ |
| Unicode/ˈjuːnɪkəʊd/ |
| pixel/ˈpɪksl/ |
| colour depth/ˈkʌlə depθ/ |
| sample rate/ˈsæmpl reɪt/ |
A logic gate 逻辑门 takes one or two binary inputs and gives one output. A truth table 真值表 lists the output for every combination of inputs.


| $A$ | $B$ | AND | OR | XOR | NAND | NOR |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
NOT has one input and flips it: NOT 0 = 1. XOR is 1 when the inputs differ; XNOR is 1 when they are the same.
Gates are joined into circuits. Work out a circuit's truth table by labelling each gate's output and filling in one column per label.

| $A$ | $B$ | $C$ | $P = A$ AND $B$ | $Q =$ NOT $C$ | $X = P$ OR $Q$ |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 1 |
Three inputs give $2^3 = 8$ rows; list them counting up in binary so none is missed.
| English |
|---|
| logic gate/ˈlɒdʒɪk ɡeɪt/ |
| truth table/truːθ ˈteɪbl/ |
An operating system 操作系统 (OS) manages the hardware and provides services to programs and users.

| Function | What it does |
|---|---|
| process management 进程管理 | starts and stops programs and shares the CPU between them |
| memory management 内存管理 | gives each program its own area of RAM and protects it from others |
| file management | organises files in folders and controls who may read or write them |
| device management | controls hardware through drivers 驱动程序 |
| security | checks users' identity and their permissions |
| user interface | a graphical or command-line interface |
One CPU core runs one process at a time; the OS scheduler 调度程序 switches between processes so fast that they seem to run together.

| Method | Rule | Weakness |
|---|---|---|
| first come, first served | run each process to the end, in arrival order | a long job makes short ones wait |
| round robin | each process gets a fixed time slice 时间片 in turn | many switches if the slice is small |
| priority | the highest-priority ready process runs | low-priority processes may never run |
Round robin, time slice 2 ms, processes P1 (5 ms), P2 (3 ms), P3 (1 ms) arriving together:
| Time (ms) | 0–2 | 2–4 | 4–5 | 5–7 | 7–8 | 8–9 |
|---|---|---|---|---|---|---|
| runs | P1 | P2 | P3 (ends) | P1 | P2 (ends) | P1 (ends) |
P3 finishes at 5 ms, P2 at 8 ms, P1 at 9 ms.
The CPU must know when a device needs attention.
| English |
|---|
| operating system/ˈɒpəreɪtɪŋ ˈsɪstəm/ |
| process management/ˈprəʊses ˈmænɪdʒmənt/ |
| memory management/ˈmeməri ˈmænɪdʒmənt/ |
| driver/ˈdraɪvə/ |
| scheduler/ˈʃedjʊlə/ |
| time slice/taɪm slaɪs/ |
| polling/ˈpəʊlɪŋ/ |
| interrupt/ˈɪntərʌpt/ |
Answers.
11001000; (c) $2 \times 16 + 15 = 47$.00010011; flip: 11101100; add 1: 11101101.Loading subjects…