| Candidates should be able to: | Notes and guidance |
|---|---|
| Explain why a computer system requires an Operating System (OS) | |
| Explain the key management tasks carried out by the Operating System | Including memory management, file management, security management, hardware management (input/output/peripherals), process management |
| Show understanding of the need for typical utility software provided with an Operating System | Including disk formatter, virus checker, defragmentation software, disk contents analysis / disk repair software, file compression, back-up software |
| Show understanding of program libraries | Including: • software under development is often constructed using existing code from program libraries • the benefits to the developer of software constructed using library files, including Dynamic Link Library (DLL) files |
系统软件
A-Level 计算机科学 · 第 5 主题
5.1
操作系统
大纲
来源:剑桥国际大纲
为什么一台计算机需要一个操作系统
硬件本身只能取指令并运行它们——它对文件、程序、网络或用户一无所知。操作系统(operating system,OS)是这样一个软件层,它:
- 为运行中的程序管理硬件(处理器(processor)、内存、I/O、存储)。
- 通过一个清晰的接口提供服务(文件系统、网络、用户账户),所以程序不必直接与硬件对话。
- 提供一个用户界面(命令行、GUI、触控)。
- 让几个程序安全地共享硬件——每个获得公平的 CPU 时间并被挡在其他程序的内存之外。
没有操作系统,每个程序都需要它自己的驱动,而且一次只能安全地运行一个程序。


关键的管理任务
- 进程管理(process management)——加载程序、在 CPU 上调度它们、在它们之间切换,并杀死行为不当的。(一个运行中的程序是一个进程(process)。)
- 内存管理(memory management)——把内存给进程、使它们分开,并使用虚拟内存(virtual memory)/ 分页(paging)使工作集能超过物理 RAM(随机存取存储器)。
- 文件管理——在辅助存储器(secondary storage)上组织文件和文件夹、控制权限、防止写入损坏。
- 设备管理(硬件管理)——通过设备驱动(device drivers)处理 I/O 和外围设备、缓冲数据、管理中断,并给出一个统一的接口。
- 安全管理——账户、权限、防火墙、加密。
- 用户界面和联网。


实用软件
大多数操作系统包含实用程序(utility programs)来维护系统:

- 磁盘格式化程序——一个文件 / 磁盘管理工具,它准备一个磁盘(建立它的文件系统);相关工具复制、移动和删除文件。
- 碎片整理软件(磁盘碎片整理(disk defragmenter))——在一个硬盘上把碎片文件的各部分移到一起以减少寻道时间(对 SSD 无用)。
- 磁盘内容分析 / 磁盘修复软件——检查磁盘完整性并修复文件系统错误和坏扇区。
- 备份软件(备份(backup))——把用户数据复制到别处,以便能恢复。
- 病毒检查器(杀毒软件(antivirus))——扫描恶意软件并隔离威胁。
- 防火墙(firewall)——按规则过滤网络流量。
- 文件压缩(压缩(compression))/ 归档;系统监视器;更新。
把这些与操作系统捆绑,省去用户安装每一个。
Where the operating system sits
Tap each layer. The OS is the middle layer — it sits between your applications and the hardware, sharing the machine safely so programs never touch the hardware directly.
| 英文 | 中文 | 拼音 |
|---|---|---|
| operating system | 操作系统 | cāo zuò xì tǒng |
| processor | 处理器 | chǔ lǐ qì |
| process management | 进程管理 | jìn chéng guǎn lǐ |
| process | 进程 | jìn chéng |
| memory management | 内存管理 | nèi cún guǎn lǐ |
| virtual memory | 虚拟内存 | xū nǐ nèi cún |
| paging | 分页 | fēn yè |
| RAM | 随机存取存储器 | suí jī cún qǔ cún chǔ qì |
| secondary storage | 辅助存储器 | fǔ zhù cún chǔ qì |
| device driver | 设备驱动 | shè bèi qū dòng |
| utility program | 实用程序 | shí yòng chéng xù |
| disk defragmenter | 碎片整理 | suì piàn zhěng lǐ |
| backup | 备份 | bèi fèn |
| antivirus | 杀毒软件 | shā dú ruǎn jiàn |
| firewall | 防火墙 | fáng huǒ qiáng |
| compression | 压缩 | yā suō |
5.1
程序库
一个程序库(program library)是预先写好的代码(子程序(subroutines)、类、模块),程序重用它而不是自己写——例如一个数学库、一个网络库、一个图形库。

好处:节省时间(现成的代码)、可靠(经过充分测试、广泛使用),以及标准化(一致的行为)。
- 一个静态库(static library)在编译时被复制到可执行文件中(独立,但更大且需要重建来更新)。
- 一个动态库(dynamic library,DLL,动态链接库;
.so)在运行时被加载(可执行文件更小、被许多程序共享、一次更新惠及所有)。

Computing concept lab
Classify concrete examples by the computing idea they demonstrate.
| 英文 | 中文 | 拼音 |
|---|---|---|
| program library | 程序库 | chéng xù kù |
| subroutines | 子程序 | zi chéng xù |
| static library | 静态库 | jìng tài kù |
| dynamic library | 动态库 | dòng tài kù |
5.2
语言翻译程序
大纲
| Candidates should be able to: | Notes and guidance |
|---|---|
| Show understanding of the need for: • assembler software for the translation of an assembly language program • a compiler for the translation of a high-level language program • an interpreter for translation and execution of a high-level language program | |
| Explain the benefits and drawbacks of using either a compiler or interpreter and justify the use of each | |
| Show awareness that high-level language programs may be partially compiled and partially interpreted, such as Java (console mode) | |
| Describe features found in a typical Integrated Development Environment (IDE) | Including: • for coding, including context-sensitive prompts • for initial error detection, including dynamic syntax checks • for presentation, including prettyprint, expand and collapse code blocks • for debugging, including single stepping, breakpoints, i.e. variables, expressions, report window |
来源:剑桥国际大纲
你写源代码;计算机运行机器码(machine code)。一个翻译器(translator)在它们之间转换。
汇编器
一个汇编器(assembler)把汇编语言(assembly language)翻译成机器码,每条指令一条指令。用于底层代码(嵌入式系统、驱动)。
编译器
一个编译器(compiler)在运行之前一次性把一个高级程序翻译成机器码。
- 它在编译时报告所有错误;一旦干净,它产生一个独立的可执行文件(executable),它在没有安装编译器的情况下运行,并能运行许多次。
- 通常运行时更快(运行时没有翻译),但绑定到一个 CPU/OS——为每个平台重新编译。
解释器
一个解释器(interpreter)一次一行地翻译并运行一个高级程序,不产生可执行文件。
- 它在到达那一行时报告一个错误,然后停止;你可以修正它并继续——对开发很好。
- 必须安装解释器才能运行程序;通常更慢(每次运行都重新翻译),但容易跨平台移植(port)。

在它们之间选择
| 用编译器当: | 用解释器当: |
|---|---|
| 运行时速度重要 | 你想要快速的编辑-运行循环 |
| 分发给没有开发工具的用户 | 编写跨平台脚本 |
| 程序运行许多次 | 程序小或只运行一次 |
| 教初学者 |
混合:Java
Java 被编译成字节码(bytecode,一种平台无关的中间形式),一个虚拟机(virtual machine,JVM)随即解释它——或使用即时编译(just-in-time compilation)把热点部分变成本地代码。所以错误被及早捕获、字节码在任何有 JVM 的地方运行("一次编写,到处运行"),并且长时间运行的程序达到接近本地的速度。C# 和 Python 用类似的设计。

例题。 Java 源代码被编译成字节码,再由 JVM 解释执行。为什么两者都用,而不直接编译成机器码?编译器生成的是针对某一种处理器和操作系统的机器码,所以在一台机器上编译的程序无法在另一台上运行。而 Java 的编译器面向的是一台虚拟机器,所以它产生的字节码在哪里都完全相同;各个平台再各自提供自己的 JVM,把这些字节码解释成本平台的原生指令。因此一个编译好的文件可以在任何有 JVM 的地方运行 - "一次编写,到处运行"。代价是速度:解释字节码比运行原生代码慢,这正是真实的 JVM 还会用 JIT 编译在运行时把频繁执行的字节码转成原生代码的原因。要把两面都说出来 - 得分点是用速度换来的可移植性。
The compiler route: source to running program
Step through how a compiler works — translating the whole program once, before it runs. Contrast it with an interpreter, which translates and runs one line at a time.
| 英文 | 中文 | 拼音 |
|---|---|---|
| machine code | 机器码 | jī qì mǎ |
| translator | 翻译器 | fān yì qì |
| assembler | 汇编器 | huì biān qì |
| assembly language | 汇编语言 | huì biān yǔ yán |
| compiler | 编译器 | biān yì qì |
| executable | 可执行文件 | kě zhí xíng wén jiàn |
| interpreter | 解释器 | jiě shì qì |
| bytecode | 字节码 | zì jié mǎ |
| virtual machine | 虚拟机 | xū nǐ jī |
| just-in-time compilation | 即时编译 | jí shí biān yì |
5.2
集成开发环境(IDE)
一个集成开发环境(integrated development environment,IDE)把写、测试和调试代码的工具带进一个应用程序:

- 带语法高亮(syntax highlighting,关键字、字符串、注释用不同的颜色)、自动缩进和括号匹配的源代码编辑器。
- 自动补全(auto-complete)——在你输入时建议名称并显示函数参数。
- 翻译器集成——用一次击键编译/运行;错误内联显示。
- 调试器(debugger)——设置断点(breakpoints)来暂停、逐行单步执行(step through),并检查变量。
- 版本控制(version control)集成(git)、项目管理、一个帮助系统、重构(refactoring)工具(安全重命名),以及单元测试(unit test)集成。
一个 IDE 通过把写 → 运行 → 调试 → 修正放在一个接口后面来加速开发。常见的 IDE:Visual Studio、PyCharm、Eclipse、VS Code。

| 英文 | 中文 | 拼音 |
|---|---|---|
| integrated development environment | 集成开发环境 | jí chéng kāi fā huán jìng |
| syntax highlighting | 语法高亮 | yǔ fǎ gāo liàng |
| auto-complete | 自动补全 | zì dòng bǔ quán |
| debugger | 调试器 | tiáo shì qì |
| breakpoints | 断点 | duàn diǎn |
| version control | 版本控制 | bǎn běn kòng zhì |
| refactoring | 重构 | zhòng gòu |
| unit test | 单元测试 | dān yuán cè shì |
5.2
考试技巧
- 列出操作系统的工作(内存、进程、文件、设备和安全管理)——单说"管理资源"太含糊。
- 比较编译器对解释器对汇编器:每个翻译什么,以及何时报告错误。
- 解释一个 IDE 提供什么(编辑器、调试器、错误诊断、自动补全)。
本主题的互动课程
逐步学习,并即时检测练习。