📚 Operating Systems: Core Concepts for Edexcel A-Level Programming | 操作系统:Edexcel A-Level 编程核心概念
Operating systems form the foundation of every computing device. In Edexcel A-Level Computer Science, you need to explain how an OS manages hardware resources, schedules processes, allocates memory, and provides a platform for application programs. This article covers the key concepts likely to appear in exam questions, with bilingual explanations, worked examples and concise revision tables.
操作系统是每台计算设备的基础。在 Edexcel A-Level 计算机科学中,你需要解释操作系统如何管理硬件资源、调度进程、分配内存,并为应用程序提供运行平台。本文涵盖考试中常见的关键概念,并配有双语解释、例题和简明复习表格。
1. What is an Operating System? | 什么是操作系统?
An operating system (OS) is system software that acts as an intermediary between hardware and application software. It provides a virtual machine that hides the complexity of hardware, manages resources, and offers a consistent user interface.
操作系统(OS)是系统软件,充当硬件与应用软件之间的中介。它提供一个虚拟机来隐藏硬件复杂性,管理资源,并提供一致的用户界面。
The main functions of an OS can be grouped into five areas, and examiners expect you to name them and give a short example of each.
操作系统的功能可以分为五个方面,考官希望你能列出来,并为每项给出一个简短例子。
- Process management - deciding which process runs on the CPU and for how long. 进程管理——决定哪个进程在 CPU 上运行以及运行多久。
- Memory management - allocating RAM, protecting one process from another, and using virtual memory. 内存管理——分配内存、隔离各进程,并使用虚拟内存。
- File management - creating, naming, storing, retrieving and deleting files and folders. 文件管理——创建、命名、存储、读取和删除文件与文件夹。
- Device management - controlling input, output and storage devices through drivers. 设备管理——通过驱动程序控制输入、输出和存储设备。
- Security and accounting - user accounts, passwords, access rights and logging. 安全与记账——用户账户、密码、访问权限与日志记录。
In Edexcel exams, you may be asked to distinguish between system software and application software, and to describe the role of the OS in resource allocation. The key idea is that the OS is a resource manager: it decides which of several competing programs gets the CPU, how much memory, and which device.
在 Edexcel 考试中,你可能需要区分系统软件和应用软件,并描述操作系统在资源分配中的作用。核心观点是:操作系统是资源管理者——它决定多个竞争程序中的哪一个获得 CPU、多少内存以及哪台设备。
| Feature 特征 | System software 系统软件 | Application software 应用软件 |
| Purpose 用途 | Runs the computer itself 运行计算机本身 | Performs a task for the user 为用户完成特定任务 |
| Examples 例子 | OS, utilities, device drivers 操作系统、工具软件、驱动 | Word processor, browser, game 文字处理、浏览器、游戏 |
| Needed to boot? 是否必需 | Yes 是 | No 否 |
2. OS Structure and Kernel | 操作系统结构与内核
The kernel is the core part of the OS. It runs in privileged mode (also called kernel mode or supervisor mode) and has direct access to hardware such as the CPU, memory and interrupt controller.
内核是操作系统的核心部分。它运行在特权模式(也称内核模式或管理程序模式),并可直接访问 CPU、内存和中断控制器等硬件。
User programs run in user mode and must request kernel services through system calls. A system call is a controlled entry point into the kernel, for example open(), read(), write() or fork(). If a user program tried to touch hardware directly, the CPU would raise a trap and the OS would terminate the process.
用户程序运行在用户模式,必须通过系统调用请求内核服务。系统调用是进入内核的受控入口,例如 open()、read()、write() 或 fork()。如果用户程序试图直接访问硬件,CPU 会产生陷阱,操作系统将终止该进程。
A monolithic kernel places process management, memory management and device drivers in one kernel space; a microkernel keeps only essential functions in kernel space and moves drivers, file systems and network stacks to user space. A hybrid kernel, used by Windows and macOS, combines both approaches.
宏内核将进程管理、内存管理和设备驱动置于同一内核空间;微内核仅保留最基本功能在内核空间,把驱动、文件系统和网络协议栈移到用户空间。Windows 和 macOS 使用的混合内核则结合了两种方式。
- Monolithic: fast communication, but one faulty driver can crash the whole system. 宏内核:通信快,但一个出错驱动可能导致整机崩溃。
- Microkernel: more reliable and easier to port, but slower due to extra message passing. 微内核:更可靠、更易移植,但因额外消息传递而较慢。
- Layered design: each layer only talks to the layer below, which simplifies testing. 分层设计:每层只与下一层交互,便于测试。
When you answer a question on kernel design, always link the structure to a trade-off: performance against reliability and security.
回答内核设计题时,一定要把结构选择与权衡联系起来:性能、可靠性与安全之间的取舍。
3. Process Management and the PCB | 进程管理与进程控制块
A process is a program in execution. It needs a program counter, registers, a stack, a heap and a set of resources. The OS tracks each process using a process control block (PCB), which stores all the information needed to pause and later resume it.
进程是正在执行的程序,需要程序计数器、寄存器、栈、堆以及一组资源。操作系统用进程控制块(PCB)跟踪每个进程,其中保存暂停后重新恢复所需的全部信息。
Typical PCB fields include: process ID, process state, program counter, CPU registers, memory limits, list of open files, priority, and accounting information such as CPU time used.
PCB 的典型字段包括:进程 ID、进程状态、程序计数器、CPU 寄存器、内存界限、打开文件列表、优先级,以及已用 CPU 时间等记账信息。
A process moves through a set of states. The five-state model is the one most often asked for.
进程会在一组状态之间转换,最常考的是五状态模型。
- New - the process is being created. 新建——进程正在被创建。
- Ready - it could run but is waiting for the CPU. 就绪——可以运行,但正在等待 CPU。
- Running - instructions are being executed. 运行——指令正在被执行。
- Blocked or waiting - it is waiting for I/O or an event. 阻塞/等待——正在等待 I/O 或某个事件。
- Terminated - execution has finished. 终止——执行结束。
A context switch happens when the OS saves the state of one process into its PCB and loads the state of another. Context switches do not do useful user work, so they are pure overhead; this is the main reason very small time slices reduce efficiency.
上下文切换指操作系统把一个进程的状态保存到其 PCB 中,并装入另一个进程的状态。上下文切换不完成有用的用户工作,因此纯属额外开销;这也是时间片过小会降低效率的主要原因。
Do not confuse three similar terms: multiprogramming keeps several jobs in memory to keep the CPU busy; multitasking switches rapidly between tasks so users perceive them as simultaneous; multithreading runs several threads inside one process, sharing its memory.
不要混淆三个相似术语:多道程序设计让多个作业驻留内存以保持 CPU 忙碌;多任务处理快速切换任务,使用户感觉同时进行;多线程在同一进程内运行多个线程,共享其内存。
4. CPU Scheduling Algorithms | CPU 调度算法
Scheduling aims to maximise CPU utilisation and throughput while minimising waiting time, response time and turnaround time. A good answer names the algorithm, explains its rule, and then evaluates it.
调度的目标是最大化 CPU 利用率和吞吐量,同时最小化等待时间、响应时间和周转时间。好的答案会写出算法名称、说明规则,再进行评价。
Turnaround Time = Completion Time − Arrival Time
Waiting Time = Turnaround Time − Burst Time
First Come First Served (FCFS) runs jobs in arrival order. It is simple and fair in a queue sense, but a long job at the front causes the convoy effect, giving very poor average waiting time.
先来先服务(FCFS)按到达顺序运行作业。它简单且符合排队公平,但队首的长作业会造成护航效应,导致平均等待时间很差。
Shortest Job First (SJF) picks the process with the smallest burst time. It gives the minimum average waiting time if all jobs are available at once, but burst times must be estimated and long jobs can starve.
最短作业优先(SJF)选择运行时间最短的进程。若所有作业同时到达,它可获得最小平均等待时间,但需要预估运行时间,且长作业可能饥饿。
Round Robin (RR) gives each process a fixed time slice, called a quantum, in turn. It is preemptive, so it is good for interactive systems, but performance depends heavily on the quantum size.
轮转调度(RR)按顺序给每个进程固定的时间片(称为量子)。它是抢占式的,适合交互式系统,但性能在很大程度上取决于时间片大小。
Priority scheduling always runs the highest-priority ready process; ageing gradually increases the priority of waiting processes to prevent starvation.
优先级调度总是运行就绪队列中优先级最高的进程;老化机制逐步提高等待进程的优先级,以防止饥饿。
| Algorithm 算法 | Preemptive? 抢占? | Main weakness 主要缺点 |
| FCFS 先来先服务 | No 否 | Convoy effect 护航效应 |
| SJF 最短作业优先 | No (SRT is) 否(SRT 是) | Starvation, needs estimates 饥饿、需预估 |
| Round Robin 轮转 | Yes 是 | Context switch overhead 上下文切换开销 |
| Priority 优先级 | Both 两者皆可 | Starvation of low priority 低优先级饥饿 |
5. Memory Management | 内存管理
Memory management has three jobs: allocate memory to processes, keep processes from overwriting each other, and make the best use of limited physical RAM. Two classic techniques are paging and segmentation.
内存管理有三项任务:为进程分配内存,防止进程互相覆盖,并最有效地利用有限的物理内存。两种经典技术是分页和分段。
In paging, memory is divided into fixed-size frames and logical memory into pages of the same size. Any page can be placed in any free frame, so external fragmentation is eliminated; the page table maps page numbers to frame numbers.
在分页中,物理内存被划分为固定大小的帧,逻辑内存被划分为同样大小的页。任意页都可放入任意空闲帧,因此消除了外部碎片;页表负责把页号映射到帧号。
In segmentation, memory is divided into variable-length logical segments such as code, data and stack. It matches how programmers think and supports sharing and protection, but variable sizes can create external fragmentation.
在分段中,内存被划分为长度可变的逻辑段,如代码段、数据段和栈段。它符合程序员的思维方式,便于共享和保护,但可变长度会产生外部碎片。
Virtual memory lets a process run when only part of it is in RAM. Pages not in use are held on disk in the swap file or page file. When a page is needed and is not present, a page fault occurs and the OS loads it, possibly evicting another page.
虚拟内存让进程在只有一部分位于内存时也能运行,未使用的页保存在磁盘的交换文件或页面文件中。需要某页而它不在内存时会产生缺页,操作系统将其调入,并可能置换出另一页。
Physical Address = Frame Number × Frame Size + Offset
EAT = (1 − p) × Memory Access Time + p × Page Fault Service Time
If the working set of active processes exceeds physical memory, the system spends more time swapping than executing. This is thrashing, and typical cures are reducing the degree of multiprogramming or using a better page replacement policy such as LRU instead of FIFO.
如果活动进程的工作集超过物理内存,系统花在交换上的时间会多于执行时间,这就是抖动(thrashing)。常见对策是降低多道程序度,或采用 LRU 等更优的页面置换策略代替 FIFO。
6. File Management | 文件管理与目录结构
A file is a named collection of related data stored on secondary storage. The OS records attributes for each file: name, type, location, size, owner, permissions, and timestamps for creation and modification.
文件是存储在辅助存储器上的、有名称的相关数据集合。操作系统为每个文件记录属性:名称、类型、位置、大小、所有者、权限,以及创建和修改时间戳。
Directories organise files. A single-level directory is simple but names must be unique and files cannot be grouped. A hierarchical (tree) directory allows folders inside folders, and a path such as /users/hao/coursework.txt identifies one file uniquely.
目录用于组织文件。单级目录简单,但文件名必须唯一且无法分组。层次(树形)目录允许文件夹嵌套,路径如 /users/hao/coursework.txt 可唯一标识一个文件。
File allocation describes how blocks are stored on disk. Contiguous allocation gives fast sequential access but suffers fragmentation; linked allocation uses pointers and is flexible but slow for random access; indexed allocation uses an index block and supports both sequential and direct access.
文件分配方式描述块在磁盘上的存放方式。连续分配顺序访问快,但会产生碎片;链接分配使用指针,灵活但随机访问慢;索引分配使用索引块,既支持顺序访问也支持直接访问。
- Access rights: read, write, execute, delete, and sharing rules set by the owner. 访问权限:由所有者设定的读、写、执行、删除与共享规则。
- Metadata structures: FAT for simple systems, inodes for UNIX-style file systems, bitmaps or free lists for free space. 元数据结构:简单系统用 FAT,类 UNIX 文件系统用索引节点(inode),空闲空间用位图或空闲链表。
- Journalling: writes changes to a log first so the file system can recover after a power failure. 日志:先写入日志,使文件系统在断电后可以恢复。
For full marks in an Edexcel answer, connect file management back to the user: the OS hides disk sectors and block addresses behind a simple open-save-delete interface.
要在 Edexcel 答题中拿到满分,需要把文件管理与用户联系起来:操作系统把磁盘扇区和块地址隐藏在简单的打开—保存—删除接口之后。
7. Device Management, Drivers and Interrupts | 设备管理、驱动与中断
Device management means controlling all peripherals through device drivers. A driver is software that translates general OS commands into the specific signals a particular device understands, which is why a new printer needs its own driver.
设备管理指通过设备驱动程序控制所有外设。驱动程序把通用的操作系统命令翻译成特定设备能理解的具体信号,这就是新打印机需要专属驱动的原因。
There are two basic ways to notice that a device has finished: polling and interrupts. Polling repeatedly checks a status register, which wastes CPU time; an interrupt signal tells the CPU to pause, run an interrupt service routine (ISR), and then resume.
发现设备已完成工作有两种基本方式:轮询和中断。轮询反复检查状态寄存器,浪费 CPU 时间;中断信号让 CPU 暂停、执行中断服务程序(ISR),然后恢复原来的工作。
- Buffering: data is held temporarily in memory to smooth out speed differences between CPU and peripherals. 缓冲:数据暂存于内存,以缓解 CPU 与外设之间的速度差异。
- Spooling: jobs such as print jobs are queued on disk so several processes can share one slow device. 假脱机:打印等作业先排入磁盘队列,使多个进程共享一台慢速设备。
- DMA: direct memory access lets a device transfer data to memory without the CPU copying every byte. DMA:直接内存访问让设备直接向内存传输数据,无需 CPU 逐字节搬运。
Interrupt priorities matter: a power failure signal must be handled before a keyboard press. A maskable interrupt can be temporarily ignored; a non-maskable interrupt cannot.
中断优先级很重要:电源故障信号必须先于键盘按键被处理。可屏蔽中断可以被暂时忽略,不可屏蔽中断则不能。
8. Security and Protection | 安全与保护
Security in an OS has three aims: confidentiality, integrity and availability, often remembered as CIA. Protection mechanisms stop one user or process from damaging another.
操作系统的安全有三项目标:保密性、完整性和可用性,常简称为 CIA。保护机制防止某个用户或进程破坏另一个用户或进程。
Authentication verifies identity, through something you know (password), something you have (phone or token) or something you are (fingerprint, face). Two-factor authentication combines two of these categories and is much stronger than a password alone.
身份认证用于验证身份,可使用你知道的信息(密码)、你拥有的物品(手机或令牌)或你的生物特征(指纹、人脸)。双因素认证结合其中两类,比只用密码安全得多。
Authorisation then decides what an authenticated user may do. Rights may be stored as an access control list (ACL) attached to each file, or as permissions such as read, write and execute. Misconfigured permissions are one of the most common real-world vulnerabilities.
授权则决定已认证用户可以做什么。权限可以以访问控制列表(ACL)的形式附在每个文件上,也可以用读、写、执行等权限位表示。权限配置错误是现实中最常见的漏洞之一。
- Encryption protects data at rest and in transit; full-disk encryption protects a stolen laptop. 加密保护静态与传输中的数据;全盘加密可保护被盗的笔记本电脑。
- Firewalls and antivirus filter network traffic and detect malware. 防火墙和杀毒软件过滤网络流量、检测恶意软件。
- Sandboxing runs untrusted code in a restricted environment, as browsers do for web pages. 沙箱在受限环境中运行不受信任的代码,浏览器对网页正是如此。
- Audit logs record who did what and when, supporting investigation. 审计日志记录谁在何时做了什么,便于事后调查。
- Principle of least privilege: give each process only the rights it truly needs. 最小权限原则:只给每个进程真正需要的权限。
9. Types of Operating Systems | 操作系统的类型
Different tasks need different OS designs, and exam questions often ask you to match a scenario to a type and justify the choice.
不同任务需要不同的操作系统设计,考试常要求你为某个场景匹配合适的类型并说明理由。
| Type 类型 | Key feature 关键特征 | Typical use 典型用途 |
| Batch 批处理 | Jobs grouped, no user interaction 作业成批、无交互 | Payroll, overnight reports 工资单、夜间报表 |
| Real-time 实时 | Guaranteed response time 保证响应时间 | Airbag, pacemaker, robot arm 安全气囊、起搏器、机械
广告 / Sponsored 英文原版 Collins International Primary Computing 柯林斯国际小学计算机科学学生… 计算机 备考教辅 · 正版现货 · 学习备考通用 查看详情 / View on Taobao广告 / Sponsored 英文原版 Collins International Primary Computing 柯林斯国际小学计算机科学学生… 计算机 备考教辅 · 正版现货 · 学习备考通用 查看详情 / View on Taobao更多咨询请联系16621398022(同微信) 备考资讯每日更新,关注不错过 考纲变化 · 科目分析 · 学习方法 ![]() 在微信里长按二维码识别关注 或截图后用「扫一扫 → 相册」选择本图 公众号:tutorhao |
