📚 A-Level Computer Science: Operating Systems Exam Essentials | A-Level 计算机:操作系统考点精讲
Operating systems (OS) are the backbone of every computing device, managing hardware and software resources to provide a stable environment for applications. In A-Level Computer Science, a deep understanding of OS concepts such as process scheduling, memory management, interrupts and virtual memory is critical for exam success. This guide distills the key points you need to know, with paired explanations in English and Chinese to reinforce your learning.
操作系统是每台计算设备的中枢,负责管理硬件和软件资源,为应用程序提供稳定的运行环境。在A-Level计算机科学中,深入理解进程调度、内存管理、中断和虚拟内存等操作系统概念对考试至关重要。本指南提炼了您需要掌握的关键知识点,并采用中英双语对照讲解,帮助巩固学习。
1. What is an Operating System? | 什么是操作系统?
An operating system is the software layer that sits between the computer hardware and user applications. It provides a set of services that allow programs to execute while efficiently managing the underlying hardware. The OS hides the complexity of hardware through abstraction, presenting programmers with a simpler, uniform interface for tasks like file access and process creation.
操作系统是位于计算机硬件与用户应用程序之间的软件层。它提供了一组服务,使程序能够运行,同时高效地管理底层硬件。操作系统通过抽象隐藏硬件复杂性,为程序员呈现一个更简单、统一的接口,用于执行文件访问和进程创建等任务。
The kernel is the heart of the OS, loaded into memory at boot time and remaining resident. It handles critical functions such as process scheduling, memory allocation, interrupt handling and communication with devices. User-level programs interact with the kernel through system calls, while the shell or GUI provides the user interface.
内核是操作系统的心脏,在启动时被加载到内存并始终保持常驻。它处理进程调度、内存分配、中断处理以及与设备的通信等关键功能。用户级程序通过系统调用与内核交互,而Shell或图形用户界面则提供用户接口。
2. Core Functions of an Operating System | 操作系统的核心功能
The OS performs several key functions: process management (creating, scheduling and terminating processes), memory management (allocating and deallocating memory space), file system management (organising and controlling access to files), device management (handling I/O operations via drivers), and security & access control (protecting data and resources).
操作系统执行几项关键功能:进程管理(创建、调度和终止进程)、内存管理(分配和释放内存空间)、文件系统管理(组织并控制文件访问)、设备管理(通过驱动程序处理输入/输出操作)以及安全与访问控制(保护数据和资源)。
Resource allocation is central to all these functions. The OS must ensure fair and efficient sharing of CPU time, memory and I/O among concurrent processes, while preventing deadlock and starvation. It also provides a user interface, be it a command-line or graphical environment, to allow human interaction with the system.
资源分配是所有功能的核心。操作系统必须确保在并发的进程之间公平、高效地共享CPU时间、内存和I/O,同时防止死锁和饥饿。它还提供用户接口,无论是命令行还是图形环境,以便人与系统交互。
3. Process and Thread Management | 进程与线程管理
A process is a program in execution, consisting of the program code, data, stack, and a process control block (PCB) that stores the process’s state, program counter, CPU registers and memory limits. The OS can create, suspend, resume and terminate processes, transitioning them between states like new, ready, running, waiting and terminated.
进程是一个正在执行的程序,包含程序代码、数据、堆栈以及进程控制块(PCB),该块保存进程的状态、程序计数器、CPU寄存器和内存限制信息。操作系统可以创建、挂起、恢复和终止进程,使其在新、就绪、运行、等待和终止等状态之间转换。
Threads are lightweight units of execution within a process. A single process can have multiple threads sharing the same code, data and file resources, but each thread has its own program counter, registers and stack. Multithreading allows a program to perform several tasks concurrently, improving responsiveness and resource utilisation.
线程是进程内的轻量级执行单元。一个进程可以拥有多个线程,它们共享相同的代码、数据和文件资源,但每个线程拥有自己的程序计数器、寄存器和堆栈。多线程允许程序同时执行多个任务,提高响应速度和资源利用率。
4. Scheduling Algorithms | 调度算法
The CPU scheduler decides which ready process will be assigned the CPU next. The choice of algorithm affects system throughput, turnaround time, waiting time and response time. Preemptive scheduling allows the OS to take the CPU away from a running process, whereas non-preemptive scheduling lets the process voluntarily release the CPU.
CPU调度器决定下一个将CPU分配给哪个就绪进程。算法的选择会影响到系统吞吐量、周转时间、等待时间和响应时间。抢占式调度允许操作系统从正在运行的进程中夺走CPU,而非抢占式调度则让进程自愿释放CPU。
| Algorithm (English) | 算法(中文) | Description / 描述 |
|---|---|---|
| First Come First Served (FCFS) | 先来先服务 | Processes are executed in the order they enter the ready queue. Simple but may cause long average waiting times. / 进程按进入就绪队列的顺序执行,简单但可能导致较长的平均等待时间。 |
| Shortest Job First (SJF) | 最短作业优先 | The process with the shortest predicted CPU burst is scheduled next. Optimal for minimising average waiting time but requires knowledge of future burst lengths. / 预测CPU突发时间最短的进程优先调度。在最小化平均等待时间方面最优,但需要预知未来的突发长度。 |
| Round Robin (RR) | 轮转调度 | Each process is given a small time quantum (e.g. 10–100 ms). When the quantum expires, the process is moved to the back of the ready queue. Fair and responsive for time-sharing systems. / 每个进程获得一个小的时间片(如10–100毫秒)。时间片结束时,进程被移到就绪队列尾部。对分时系统公平且响应快。 |
| Priority Scheduling | 优先级调度 | Each process is assigned a priority; the CPU is allocated to the highest-priority ready process. Can be preemptive or non-preemptive. Risk of starvation for low-priority processes (solved by ageing). / 每个进程被分配一个优先级;CPU分配给优先级最高的就绪进程。可以是抢占式或非抢占式。低优先级进程可能饿死(通过老化解决)。 |
The multilevel feedback queue is a common practical scheduler that uses several queues with different scheduling policies and allows processes to move between queues based on their behaviour. Ageing gradually increases the priority of waiting processes to prevent indefinite blocking.
多级反馈队列是一种常见的实用调度器,它使用具有不同调度策略的多个队列,并允许进程根据其行为在队列之间移动。老化技术会逐步提高等待进程的优先级,以防止无限期阻塞。
5. Interrupt Handling | 中断处理
An interrupt is a signal sent to the CPU by hardware or software indicating an event that needs immediate attention. When an interrupt occurs, the CPU pauses the current process, saves its state, and jumps to an interrupt service routine (ISR) stored at a predefined address. After handling the interrupt, the saved state is restored and execution resumes.
中断是由硬件或软件发送给CPU的信号,表明发生了需要立即处理的事件。当中断发生时,CPU暂停当前进程,保存其状态,并跳转到存储在预定地址的中断服务程序(ISR)。处理完中断后,恢复保存的状态并继续执行。
Interrupts can be hardware interrupts (e.g. from a keyboard or disk) or software interrupts (traps caused by errors or system calls). Interrupt nesting allows higher-priority interrupts to preempt a running ISR. The interrupt vector table holds the starting addresses of ISRs, enabling the CPU to quickly locate the correct handler.
中断可以是硬件中断(例如来自键盘或磁盘)或软件中断(由错误或系统调用引起的陷阱)。中断嵌套允许更高优先级的中断抢占正在运行的ISR。中断向量表保存了ISR的起始地址,使CPU能够快速找到正确的处理程序。
6. Memory Management Basics | 内存管理基础
Memory management keeps track of which parts of memory are in use and which are free, allocates memory to processes, and deallocates it when no longer needed. The simplest scheme is contiguous allocation with fixed or dynamic partitions, though this leads to external fragmentation – free memory scattered in small holes.
内存管理者跟踪内存中哪些部分正在使用、哪些空闲,为进程分配内存,并在不再需要时将其释放。最简单的方案是采用固定或动态分区的连续分配,但这会导致外部碎片——空闲内存分散成小块。
Logical addresses (generated by the CPU) are translated to physical addresses (in main memory) by the memory management unit (MMU). Relocation registers can be used to add a base value to each logical address, allowing programs to be loaded anywhere in memory without changing the code.
逻辑地址(由CPU生成)通过内存管理单元(MMU)转换为物理地址(主存中的实际地址)。重定位寄存器可以为每个逻辑地址加上一个基址值,使得程序可以被加载到内存的任意位置而不需修改代码。
7. Paging, Segmentation & Virtual Memory | 分页、分段与虚拟内存
Paging divides physical memory into fixed-size blocks called frames and logical memory into pages of the same size. The logical address is split into a page number p and an offset d. A page table maps each page to a frame number, enabling non-contiguous allocation and eliminating external fragmentation.
Physical address = frame number x page size + offset
分页将物理内存划分为固定大小的块,称为帧;将逻辑内存划分为同样大小的页。逻辑地址被分为页号 p 和偏移量 d。页表将每一页映射到一个帧号,实现了非连续分配并消除了外部碎片。
物理地址 = 帧号 × 页面大小 + 偏移量
Virtual memory extends the available memory beyond physical RAM by using disk storage. When a page is not in memory (a page fault), the OS fetches it from disk, possibly swapping out another page. Demand paging loads only the pages that are actually referenced, while a translation lookaside buffer (TLB) caches recent page table entries to speed up translation.
虚拟内存通过使用磁盘存储将可用内存扩展到物理RAM之外。当某一页不在内存中(缺页)时,操作系统从磁盘取出该页,可能换出另一页。按需调页只加载实际引用的页,而转换后备缓冲器(TLB)缓存最近的页表项以加快地址转换。
Segmentation divides a program into logical segments (e.g. code, data, stack) of variable length. A segment table stores base and limit pairs. Combined systems (paged segmentation) provide the benefits of both by paging each segment, as used in some modern architectures.
分段将程序划分为变长的逻辑段(如代码段、数据段、堆栈段)。段表存储基址和限长对。组合系统(段页式)通过将每个段再进行分页来兼具两者优点,一些现代体系结构即采用这种方式。
8. File Management | 文件管理
The file system organises data on storage devices by providing a logical structure of directories and files. Common file allocation methods include contiguous allocation (fast but subject to fragmentation), linked allocation (no fragmentation but slow random access) and indexed allocation (each file has an index block of pointers, supporting both fast random access and no external fragmentation).
文件系统通过提供目录和文件的逻辑结构来组织存储设备上的数据。常见的文件分配方法包括连续分配(快速但会产生碎片)、链接分配(无碎片但随机访问慢)和索引分配(每个文件有一个指针索引块,既支持快速随机访问又没有外部碎片)。
Directories can be organised in a single-level, two-level or tree (hierarchical) structure. Access control is enforced through permission bits (e.g. read, write, execute) associated with owner, group and others, as in UNIX-like systems. The OS also manages free space with free lists or bitmaps.
目录可以组织为单级、两级或树状(层次)结构。访问控制通过权限位(如读、写、执行)实施,这些权限与所有者、组和其他人相关联,类Unix系统即采用此方式。操作系统还使用空闲列表或位图管理空闲空间。
9. Security and User Management | 安全与用户管理
The OS enforces security through user authentication (passwords, biometrics), access control lists (ACLs) and mandatory/ discretionary policies. It must protect processes from one another by keeping address spaces separate and preventing unauthorised memory access, often using hardware support like dual-mode operation (user mode vs. kernel mode).
操作系统通过用户认证(密码、生物识别)、访问控制列表(ACL)以及强制/自主策略来实施安全。它必须保护进程彼此隔离,保持地址空间独立并防止未经授权的内存访问,通常借助硬件支持,如双模式操作(用户模式与内核模式)。
Malicious software prevention is another aspect: the OS may provide built-in firewalls, anti-malware hooks, and sandboxing techniques to limit an application’s damage. Regular patches and updates are crucial to fix vulnerabilities. Additionally, the principle of least privilege ensures that users and processes only have the permissions they absolutely need.
恶意软件防护是另一个方面:操作系统可能提供内置防火墙、反恶意软件钩子和沙箱技术来限制应用程序的危害。定期的补丁和更新对于修复漏洞至关重要。此外,最小特权原则确保用户和进程只拥有其绝对需要的权限。
10. Input/Output Management | 输入/输出管理
I/O management hides the peculiarities of hardware devices from the user by providing a standardised interface via device drivers. A driver translates generic OS requests into device-specific commands. I/O can be performed using polling (CPU repeatedly checks status), interrupt-driven I/O (device signals completion), or Direct Memory Access (DMA) where a special controller transfers data directly to/from memory, freeing the CPU.
输入/输出管理通过设备驱动程序提供标准化接口,对用户隐藏硬件设备的特殊性。驱动程序将通用的操作系统请求翻译成设备专用命令。I/O的执行方式可以是轮询(CPU反复检查状态)、中断驱动I/O(设备发出完成信号)或直接存储器访问(DMA),后者通过专用控制器直接在内存间传输数据,释放CPU。
Buffering and caching smooth out speed mismatches between devices and CPU. Spooling (simultaneous peripheral operations online) is used for devices like printers, where output is temporarily stored on disk and sent to the device asynchronously, allowing multiple processes to send output without waiting.
缓冲和缓存技术可以平滑设备与CPU之间的速度差异。假脱机(SPOOLing,外部设备联机并行操作)用于打印机等设备,输出暂时存储在磁盘上并异步发送给设备,允许多个进程发送输出而无需等待。
11. Types of Operating Systems | 操作系统类型
Operating systems can be categorised by their design goals and usage environments. Batch systems execute jobs in groups without user interaction, maximising throughput. Time-sharing (multitasking) systems rapidly switch between processes to give the illusion of simultaneous execution for multiple interactive users. Real-time OS (RTOS) must process events within strict time deadlines, used in embedded control systems.
操作系统可以按其设计目标和使用环境分类。批处理系统成组执行作业而无需用户交互,以最大化吞吐量。分时(多任务)系统在进程之间快速切换,为多个交互用户营造同时执行的错觉。实时操作系统(RTOS)必须在严格的时间期限内处理事件,用于嵌入式控制系统。
Other types include distributed OS (managing a collection of independent computers as a single system), network OS (providing services like file and printer sharing over a network), and embedded OS (tightly integrated into appliances with limited resources, e.g. in cars or smart devices). Mobile OS like Android and iOS are optimised for touch interaction and power management.
其他类型包括分布式操作系统(将一组独立计算机作为单一系统管理)、网络操作系统(通过网络提供文件和打印机共享等服务),以及嵌入式操作系统(紧密集成到资源有限的设备中,例如汽车或智能设备)。像Android和iOS这样的移动操作系统针对触控交互和电源管理进行了优化。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply