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 计算机科学 SL · 知识点 1
8:35
计算机基础
你轻触一个照片应用。在一秒钟内,其代码从存储被复制到内存,处理器运行数百万条指令,图形芯片绘制出……
英文讲解 · 可切换中英文字幕
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/ | 中央处理器 | zhōng yāng chǔ lǐ qì |
| control unit/kənˈtrəʊl ˈjuːnɪt/ | 控制单元 | kòng zhì dān yuán |
| arithmetic logic unit/əˈrɪθmətɪk ˈlɒdʒɪk ˈjuːnɪt/ | 算术逻辑单元 | suàn shù luó jí dān yuán |
| register/ˈredʒɪstə/ | 寄存器 | jì cún qì |
| bus/bʌs/ | 总线 | zǒng xiàn |
| clock speed/klɒk spiːd/ | 时钟频率 | shí zhōng pín lǜ |
| core/kɔː/ | 核心 | hé xīn |
| graphics processing unit/ˈɡræfɪks ˈprəʊsesɪŋ ˈjuːnɪt/ | 图形处理器 | tú xíng chǔ lǐ qì |
| RAM/ræm/ | 随机存取存储器 | suí jī cún qǔ cún chǔ qì |
| ROM/rɒm/ | 只读存储器 | zhǐ dú cún chǔ qì |
| cache/kæʃ/ | 高速缓存 | gāo sù huǎn cún |
| secondary storage/ˈsekəndəri ˈstɔːrɪdʒ/ | 辅助存储器 | fǔ zhù cún chǔ qì |
| compression/kəmˈpreʃn/ | 压缩 | yā suō |
| lossless/ˈlɒsləs/ | 无损 | wú sǔn |
| lossy/ˈlɒsi/ | 有损 | yǒu sǔn |
| cloud computing/klaʊd kəmˈpjuːtɪŋ/ | 云计算 | yún jì suàn |
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/ | 二进制 | èr jìn zhì |
| bit/bɪt/ | 位 | wèi |
| byte/baɪt/ | 字节 | zì jié |
| hexadecimal/ˌheksəˈdesɪml/ | 十六进制 | shí liù jìn zhì |
| two's complement/tuːz ˈkɒmplɪmənt/ | 补码 | bǔ mǎ |
| Unicode/ˈjuːnɪkəʊd/ | 统一码 | tǒng yī mǎ |
| pixel/ˈpɪksl/ | 像素 | xiàng sù |
| colour depth/ˈkʌlə depθ/ | 色深 | sè shēn |
| sample rate/ˈsæmpl reɪt/ | 采样率 | cǎi yàng lǜ |
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/ | 逻辑门 | luó jí mén |
| truth table/truːθ ˈteɪbl/ | 真值表 | zhēn zhí biǎo |
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/ | 操作系统 | cāo zuò xì tǒng |
| process management/ˈprəʊses ˈmænɪdʒmənt/ | 进程管理 | jìn chéng guǎn lǐ |
| memory management/ˈmeməri ˈmænɪdʒmənt/ | 内存管理 | nèi cún guǎn lǐ |
| driver/ˈdraɪvə/ | 驱动程序 | qū dòng chéng xù |
| scheduler/ˈʃedjʊlə/ | 调度程序 | diào dù chéng xù |
| time slice/taɪm slaɪs/ | 时间片 | shí jiān piàn |
| polling/ˈpəʊlɪŋ/ | 轮询 | lún xún |
| interrupt/ˈɪntərʌpt/ | 中断 | zhòng duàn |
Answers.
11001000; (c) $2 \times 16 + 15 = 47$.00010011; flip: 11101100; add 1: 11101101.出了什么问题?只有网站团队能看到这些信息。