📚 A-Level OCR Computer Science: Operating Systems Exam Essentials | 操作系统考点精讲
The operating system (OS) is the backbone of any computer system, silently managing hardware, running processes, and providing the interfaces we rely on every day. For OCR A-Level Computer Science, a deep understanding of how an OS works—from interrupt handling to paging—is essential for top marks. This article breaks down the key topics you need to master, with bilingual explanations to reinforce every concept.
操作系统是任何计算机系统的支柱,它无声地管理硬件、运行进程,并提供我们日常依赖的接口。对于 OCR A-Level 计算机科学,深入理解操作系统的工作原理——从中断处理到分页——是取得高分的关键。本文拆解你需要掌握的核心主题,并用双语解释强化每个概念。
1. What is an Operating System? | 什么是操作系统?
An operating system (OS) is a layer of system software that sits between the computer hardware and the application software or user. It acts as a resource manager, controlling access to the CPU, memory, storage, and I/O devices, and provides a convenient environment for program execution.
操作系统是位于计算机硬件与应用软件或用户之间的一层系统软件。它充当资源管理器,控制对 CPU、内存、存储和 I/O 设备的访问,并为程序执行提供便利的环境。
Without an OS, every application would need to include its own hardware control code, leading to chaos and inefficiency. The OS abstracts hardware differences, offering a uniform set of services through system calls and APIs, so software can run on diverse machines without modification.
没有操作系统,每个应用程序都需要包含自己的硬件控制代码,导致混乱和低效。操作系统抽象了硬件差异,通过系统调用和 API 提供一套统一的服务,使软件能够在不同机器上运行而无需修改。
2. Core Functions of an OS | 操作系统核心功能
The OCR specification identifies six key functions of an OS: memory management, processor scheduling, file management, interrupt handling, provision of a user interface, and security (including access control). These functions are not independent; they work together to ensure efficient and secure operation.
OCR 大纲明确了操作系统的六个关键功能:内存管理、处理器调度、文件管理、中断处理、提供用户界面,以及安全(包括访问控制)。这些功能并非独立,它们协同工作以确保高效、安全地运行。
- Memory management: Allocating and deallocating RAM to processes, protecting memory spaces from interference.
- Processor scheduling: Deciding which process gets the CPU at what time, using algorithms like Round Robin or SJF.
- File management: Organising files on storage, handling directories, permissions, and file system metadata.
- Interrupt handling: Responding to hardware or software signals that require immediate attention.
- User interface: Providing a command-line, graphical, or touch-based interface for interaction.
- Security: Authenticating users, enforcing access policies, and isolating processes.
(以下为对应中文列表)内存管理:为进程分配和回收 RAM,保护内存空间不受干扰。处理器调度:使用轮转调度或最短作业优先等算法,决定哪个进程在何时获得 CPU。文件管理:在存储设备上组织文件,处理目录、权限和文件系统元数据。中断处理:响应需要立即关注的硬件或软件信号。用户界面:提供命令行、图形或触摸界面用于交互。安全:验证用户身份,强制访问策略,隔离进程。
3. Process Management & Process States | 进程管理与进程状态
A process is a program in execution. The OS creates, schedules, and terminates processes, maintaining a Process Control Block (PCB) for each, which stores the program counter, register contents, memory allocation, and I/O status. Processes transition between discrete states: New, Ready, Running, Blocked (Waiting), and Terminated.
进程是正在执行的程序。操作系统创建、调度和终止进程,并为每个进程维护一个进程控制块,其中保存了程序计数器、寄存器内容、内存分配和 I/O 状态。进程在以下离散状态间转换:新建、就绪、运行、阻塞(等待)和终止。
When a process is in the Running state on a single-core CPU, only one process can truly run at a time. The OS uses a dispatcher to switch processes rapidly, creating the illusion of multitasking. A process can be moved to Blocked if it requests I/O, and then back to Ready once the I/O is complete.
在单核 CPU 上,只有一个进程能真正处于运行态。操作系统使用分派器快速切换进程,创造出多任务并行的错觉。当进程请求 I/O 时,会被移入阻塞态;I/O 完成后,又返回就绪态。
4. Scheduling Algorithms for the CPU | CPU 调度算法
CPU scheduling is one of the most frequently examined topics. The goal is to optimise throughput, minimise waiting time, and ensure fairness. The main algorithms you must know for OCR are First Come First Served (FCFS), Shortest Job First (SJF), Round Robin (RR), and Multi-level Feedback Queues (MLFQ).
CPU 调度是最常考的主题之一。目标是最优化吞吐量、最小化等待时间并确保公平。OCR 考试要求掌握的主要算法有:先到先服务、最短作业优先、轮转调度和多级反馈队列。
| Algorithm | Description | Advantages | Disadvantages |
|---|---|---|---|
| FCFS | Processes are executed in arrival order; non-preemptive. | Simple, no starvation. | Convoy effect; long average wait. |
| SJF | Selects process with shortest burst time next; can be preemptive (SRTF). | Minimal average waiting time. | Needs burst time prediction; starvation risk for long jobs. |
| Round Robin | Each process gets a fixed time quantum; preemptive, cycles through ready queue. | Fair, good response time. | Performance depends on quantum size; high overhead if quantum too small. |
| MLFQ | Multiple queues with different priorities; processes move between queues based on behaviour. | Flexible; favours interactive processes. | Complex to configure; possible starvation of low-priority processes. |
FCFS 按到达顺序执行,非抢占式。简单,不会饥饿,但容易产生护航效应,平均等待时间长。SJF 选择预计 CPU 突发最短的进程,可抢占,平均等待时间最小,但难以预测突发时间,长作业可能饿死。轮转调度给每个进程一个时间片,公平,响应时间好,但时间片大小影响性能。多级反馈队列使用多个优先级队列,灵活,但配置复杂。
5. Interrupts and the Interrupt Service Routine | 中断与中断服务例程
An interrupt is a signal sent to the processor indicating an event that needs immediate attention. Interrupts can be hardware-generated (e.g., pressing a key, disk I/O completion) or software-generated (traps, exceptions). When an interrupt occurs, the CPU suspends the current process, saves its state, and jumps to the corresponding Interrupt Service Routine (ISR) stored at a specific memory address from the interrupt vector table.
中断是发送给处理器的信号,表明有事件需要立即处理。中断可由硬件产生(如按键、磁盘 I/O 完成),也可由软件产生(陷阱、异常)。当中断发生时,CPU 暂停当前进程,保存其状态,并跳转到中断向量表中特定内存地址处对应的中断服务例程。
The ISR executes quickly to handle the event and then returns control. The original process is resumed as if nothing happened. Effective interrupt handling is crucial for real-time responsiveness and for supporting multitasking without wasting CPU cycles on polling.
ISR 快速执行以处理事件,然后返回控制权。原进程继续执行,仿佛什么都没发生。高效的中断处理对于实时响应和支持多任务至关重要,避免了轮询带来的 CPU 周期浪费。
6. Memory Management: Paging | 内存管理:分页
Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. Both logical memory and physical memory are divided into fixed-size blocks: pages and frames, respectively. A page table for each process maps page numbers to frame numbers, allowing a process's pages to be scattered anywhere in RAM.
分页是一种内存管理方案,消除了对物理内存连续分配的需求。逻辑内存和物理内存都被划分为固定大小的块:分别称为页和帧。每个进程的页表将页号映射到帧号,使得进程的页面可以分散在 RAM 中的任何位置。
ss becomes f × frame size + d. Paging prevents external fragmentation, though internal fragmentation may occur within the last page of a process.
逻辑地址分为页号 (p) 和偏移量 (d)。页表提供对应的帧号 (f);物理地址则变为 f × 帧大小 + d。分页可防止外部碎片,但进程最后一页内可能产生内部碎片。
7. Segmentation, Virtual Memory & Thrashing | 分段、虚拟内存与抖动
Segmentation divides memory into logical segments such as code, data, stack, each of variable length. Unlike paging, segmentation reflects the programmer's view. Most modern systems combine paging with segmentation (segmented paging). Virtual memory extends the available memory by using disk space as an extension of RAM, swapping pages in and out as needed.
分段将内存划分为逻辑段,如代码段、数据段、堆栈段,每个段长度可变。与分页不同,分段反映了程序员的视角。大多数现代系统结合分页与分段(段页式)。虚拟内存通过使用磁盘空间作为 RAM 的扩展,按需换入换出页面,从而扩大了可用内存容量。
When a page needs to be loaded but no free frames exist, a page replacement algorithm (e.g., LRU, FIFO) selects a victim page to swap out. If the system spends more time swapping pages than executing processes, it results in thrashing, which severely degrades performance. The OS must carefully manage the working set of each process.
当需要加载页面但无空闲帧时,页面置换算法(如 LRU、FIFO)选择牺牲页换出。如果系统在页面交换上花费的时间比执行进程还多,就会导致抖动,严重降低性能。操作系统必须仔细管理每个进程的工作集。
8. I/O Management & Device Drivers | 输入输出管理与设备驱动程序
hardware-specific knowledge. The OS uses a layered approach: application → OS system calls → device driver → device controller → hardware. Device drivers are software modules that translate generic I/O requests into device-specific commands.
I/O 管理是关键的操作系统功能,使应用程序能够与键盘、磁盘、打印机等设备交互,而无需了解特定硬件。操作系统采用分层方式:应用程序 → 操作系统系统调用 → 设备驱动程序 → 设备控制器 → 硬件。设备驱动程序是将通用 I/O 请求转换为设备特定命令的软件模块。
The CPU can handle I/O via polling (repeatedly checking device status) or interrupt-driven I/O, which is far more efficient because the CPU is free to do other work until the device signals completion. Direct Memory Access (DMA) further reduces CPU load by allowing devices to transfer data directly to/from memory.
CPU 可通过轮询(反复检查设备状态)或中断驱动 I/O 来处理 I/O,后者效率更高,因为 CPU 可自由执行其他工作,直至设备发出完成信号。直接存储器访问允许设备直接与内存传输数据,进一步降低了 CPU 负担。
9. File Management & Security | 文件管理与安全
The file system organises data on storage media into files and directories. It maintains metadata such as file size, creation date, access permissions, and the mapping of files to physical blocks. Common operations include create, read, write, delete, and rename. Directory structures can be single-level, two-level, or tree-structured (hierarchical), the latter being the most common today.
文件系统将存储介质上的数据组织成文件和目录。它维护元数据,如文件大小、创建日期、访问权限以及文件到物理块的映射。常见操作包括创建、读取、写入、删除和重命名。目录结构可以是单级、两级或树形(层次结构),后者最为常见。
Security in the OS encompasses authentication (passwords, biometrics), authorisation (access control lists, capabilities), and protection against malware. The OS must isolate processes so that one cannot access another's memory or resources without permission. User accounts and privilege levels (kernel mode vs. user mode) enforce security boundaries.
操作系统安全涵盖认证(密码、生物识别)、授权(访问控制列表、能力)和防范恶意软件。操作系统必须隔离进程,使一个进程无法在未经许可的情况下访问另一个进程的内存或资源。用户账户和特权级别(内核模式与用户模式)强制执行安全边界。
10. Types of Operating Systems & User Interfaces | 操作系统类型与用户界面
A-Level questions often ask you to compare operating system types: batch, multi-tasking (time-sharing), multi-user, real-time, distributed, and embedded. Each type prioritises different goals. Real-time OS (RTOS) guarantees response within strict time constraints, used in airbag systems or industrial robots. A multi-user OS allows many users to simultaneously access a single system via terminals.
A-Level 考试经常要求比较操作系统类型:批处理、多任务(分时)、多用户、实时、分布式和嵌入式。每种类型优先考虑不同目标。实时操作系统保证在严格时间限制内响应,用于安全气囊系统或工业机器人。多用户操作系统允许多个用户通过终端同时访问一个系统。
User interfaces can be Command Line Interface (CLI), Graphical User Interface (GUI), or touch/natural interface. CLI is resource-light and scriptable, preferred by developers and server admins. GUI is intuitive and accessible, dominating consumer devices. Many modern OSes provide both options.
用户界面可以是命令行界面、图形用户界面或触控/自然界面。CLI 资源占用少且可脚本化,深受开发者和服务器管理员喜爱。GUI 直观易用,主导消费设备。许多现代操作系统同时提供这两种选择。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图