📚 A-Level CCEA Computer Science: Operating System In-Depth Revision | A-Level CCEA 计算机:操作系统 考点精讲
An operating system (OS) is the fundamental software that manages computer hardware, software resources, and provides common services for application programs. For the CCEA A-Level Computer Science specification, understanding the inner workings of an OS is essential. This guide walks you through the core concepts, from interrupt handling and process scheduling to memory management and deadlock, ensuring you have a firm grasp of the examination material.
操作系统(OS)是管理计算机硬件、软件资源并为应用程序提供通用服务的基础软件。对 CCEA A-Level 计算机科学考试而言,理解操作系统的内部机制至关重要。本指南将带你梳理中断处理、进程调度、内存管理及死锁等核心概念,帮助你扎实掌握考点知识。
1. What is an Operating System? | 什么是操作系统?
An operating system is a layer of software that sits between the user and the bare hardware. It acts as a resource manager and an extended machine, hiding tedious hardware details behind clean, high-level abstractions. For instance, file operations such as open, read, and write are provided without needing to understand sector layouts on a disk.
操作系统是位于用户和裸机之间的一层软件。它扮演着资源管理者和扩展机器的角色,将繁琐的硬件细节隐藏在清晰的高级抽象之后。例如,用户可以使用打开、读取和写入等文件操作,而无需了解磁盘上的扇区布局。
The OS kernel is the core component that remains in main memory. It manages processes, memory, device drivers, and system calls. In a typical A-Level scenario, you will encounter concepts like multitasking, multi-user environments, and the distinction between kernel mode and user mode. Kernel mode has full access to all hardware, while user mode restricts direct hardware manipulation for safety.
操作系统内核是常驻主存的核心组件。它管理进程、内存、设备驱动程序和系统调用。在典型的 A-Level 场景中,你会遇到多任务、多用户环境以及内核态与用户态的区别。内核态可以完全访问所有硬件,而用户态出于安全考虑会限制直接操作硬件。
2. Functions of an Operating System | 操作系统的功能
The OS performs several crucial functions: process management, memory management, file system management, I/O system management, protection and security, and user interface provision. Process management involves creating, scheduling, and terminating processes, while ensuring efficient CPU sharing. Memory management allocates and deallocates memory space, keeping track of which parts are in use.
操作系统执行多项关键功能:进程管理、内存管理、文件系统管理、I/O 系统管理、保护与安全以及用户界面提供。进程管理包括创建、调度和终止进程,并确保高效的 CPU 共享。内存管理则负责分配和回收内存空间,记录哪些部分正在使用。
File system management organises files into directories, controls access rights, and maps logical file names to physical storage. I/O management coordinates device drivers and provides a uniform interface to diverse hardware devices. Security mechanisms, such as user authentication and access control lists, protect data against unauthorised access.
文件系统管理将文件组织成目录、控制访问权限,并将逻辑文件名映射到物理存储。I/O 管理协调设备驱动,为各种硬件设备提供统一接口。安全机制(如用户认证和访问控制列表)可保护数据免遭未授权访问。
3. Interrupts and the Interrupt Cycle | 中断与中断周期
Interrupts are signals sent by hardware or software to gain the CPU’s attention. When an interrupt occurs, the CPU suspends its current activity, saves its state, and executes an interrupt service routine (ISR). The fetch-decode-execute cycle is thus extended to include an interrupt check at the end of each cycle. If an interrupt is pending, the processor branches to the corresponding ISR.
中断是由硬件或软件发送的信号,用于引起 CPU 的注意。当中断发生时,CPU 暂停当前活动、保存状态,然后执行中断服务例程(ISR)。因此,取指-解码-执行周期被扩展,在每个周期结束时增加中断检查。若有中断等待,处理器便跳转到相应的 ISR。
Interrupts can be maskable (can be ignored) or non-maskable (must be handled immediately). The interrupt vector table stores the addresses of ISRs. Prioritised interrupts allow more urgent tasks—like a keyboard vs. a power failure—to be handled in the correct order. The concept of context switching is central: the OS must save the current process’s context before switching to the ISR and later restore it.
中断可分为可屏蔽中断(可被忽略)和不可屏蔽中断(必须立即处理)。中断向量表存储 ISR 的地址。优先级中断确保更紧急的任务(如电源故障对比键盘输入)能按正确顺序处理。上下文切换的概念至关重要:操作系统在切换到 ISR 前必须保存当前进程的上下文,之后再恢复。
4. Scheduling | 调度
Scheduling is the method by which the OS decides which process may use the CPU at a given time. The scheduler aims to maximise CPU utilisation and throughput, minimise turnaround time and waiting time, and ensure fairness. CCEA students should know preemptive vs. non-preemptive scheduling: preemptive scheduling can forcibly remove a process from the CPU (e.g., Round Robin), while non-preemptive cannot (e.g., First Come First Served).
调度是操作系统决定哪个进程可在何时使用 CPU 的方法。调度器的目标是最大化 CPU 利用率和吞吐量,最小化周转时间和等待时间,并确保公平性。CCEA 学生应掌握抢占式调度与非抢占式调度的区别:抢占式调度可强制将进程从 CPU 移走(如轮转法),非抢占式则不能(如先来先服务)。
| Scheduling Algorithm | Type | Key Feature |
|---|---|---|
| First Come First Served (FCFS) | Non-preemptive | Simple queue, high waiting time for short jobs behind long ones (convoy effect). |
| Shortest Job First (SJF) | Non-preemptive | Minimises average waiting time, requires knowing burst times in advance. |
| Round Robin (RR) | Preemptive | Fixed time quantum, fair among processes; performance depends on quantum size. |
| Priority Scheduling | Preemptive / Non | Processes with higher priority run first; may cause starvation of low-priority processes. |
| Multilevel Feedback Queue | Preemptive | Multiple queues with different priorities and time quanta; processes move between queues based on behaviour. |
Understanding how to calculate waiting time and turnaround time is a common examination requirement. For Round Robin, remember that context switching adds overhead, so an extremely small quantum may degrade CPU performance.
掌握如何计算等待时间和周转时间是常见的考试要求。对于轮转法,需要记住上下文切换会增加开销,因此极短的时间片可能会降低 CPU 性能。
5. Memory Management | 内存管理
Memory management involves keeping track of which parts of memory are in use and which are free, allocating memory to processes, and deallocating memory once they finish. Basic techniques include fixed partitioning and dynamic partitioning. Fixed partitioning divides memory into predetermined sizes, leading to internal fragmentation, whereas dynamic partitioning uses exactly the requested size but causes external fragmentation over time.
内存管理涉及跟踪哪些内存区域正在使用、哪些空闲,为进程分配内存,并在其结束后回收。基本技术包括固定分区和动态分区。固定分区将内存划分为预先确定的大小,会产生内部碎片;动态分区则按请求大小精确分配,但随时间推移会导致外部碎片。
Paging eliminates external fragmentation by dividing physical memory into fixed-size blocks called frames, and logical memory into pages of the same size. A page table maps each page to a frame, with the CPU’s Memory Management Unit (MMU) handling the address translation. The logical address is split into a page number and an offset. Segmentation, on the other hand, divides memory into variable-sized logical segments (e.g., code, data, stack). Each segment is addressed by a segment number and an offset.
分页技术通过将物理内存划分为固定大小的块(称为帧),将逻辑内存划分为同样大小的页,从而消除了外部碎片。页表将每个页映射到一个帧,由 CPU 的内存管理单元(MMU)负责地址转换。逻辑地址分为页号和偏移量。而分段则是将内存划分为可变大小的逻辑段(如代码、数据、栈),每个段由段号和偏移量寻址。
6. Paging and Segmentation | 分页与分段
CCEA examiners often ask you to compare paging and segmentation. Paging provides a uniform view of memory which is invisible to the programmer; it simplifies allocation and avoids external fragmentation entirely. However, it may suffer from internal fragmentation when the last page of a process is not completely full. Segmentation reflects the programmer’s view of memory as a collection of segments, such as functions and arrays. It facilitates sharing and protection of logically related data but can lead to external fragmentation.
CCEA 考官经常要求比较分页和分段。分页提供了一种程序员不可见的内存统一视图;它简化了分配并完全避免了外部碎片。然而,当进程的最后一页未被完全填满时,可能会产生内部碎片。分段则反映了程序员将内存视为一组段(如函数和数组)的观点。它便于共享和保护逻辑相关的数据,但可能导致外部碎片。
The combination of both, known as segmented paging, is used in modern architectures. Here, the virtual address is divided into a segment number, a page number within that segment, and an offset. It inherits the benefits of both techniques at the cost of increased translation complexity.
两者的结合称为段页式,在现代体系结构中广泛使用。此时虚拟地址分为段号、段内页号和偏移量。它继承了两种技术的优点,却以增加地址转换复杂性为代价。
7. Virtual Memory | 虚拟内存
Virtual memory is a technique that allows the execution of processes that may not be completely loaded into main memory. It gives the illusion of a large, contiguous address space while using a combination of RAM and disk storage. When a requested page is not in memory (a page fault), the OS loads it from disk, possibly swapping out another page if no free frames are available.
虚拟内存是一种允许执行未完全装入主存的进程的技术。它通过结合 RAM 和磁盘存储,营造出一个巨大、连续地址空间的假象。当请求的页不在内存中时(缺页异常),操作系统会从磁盘加载该页,若无空闲帧可用,则可能换出其他页。
Page replacement algorithms decide which page to evict. Common ones are First In First Out (FIFO), Least Recently Used (LRU), and the Second-Chance (Clock) algorithm. LRU is often approximated because true LRU implementation is expensive. Thrashing occurs when a system spends more time swapping pages than executing processes, usually due to insufficient frames allocated to active processes.
页面置换算法决定将哪一页移出。常见的有先进先出(FIFO)、最近最少使用(LRU)和第二次机会(时钟)算法。LRU 常被近似实现,因为真实的 LRU 开销高昂。当系统花费在页面交换上的时间超过执行进程的时间时,就会发生颠簸现象,这通常是因为分配给活动进程的帧数不足。
8. Processes, Threads, and Concurrency | 进程、线程与并发
A process is an executing program that includes the program code, current activity (program counter), stack, data section, and process control block (PCB). The PCB contains process state, PID, register contents, and memory limits. Threads are lightweight units of execution within a process; they share the same address space and resources but have their own stack and registers. Multithreading improves responsiveness and resource sharing.
进程是一个正在执行的程序,包含程序代码、当前活动(程序计数器)、栈、数据段和进程控制块(PCB)。PCB 保存进程状态、PID、寄存器内容和内存界限。线程是进程内的轻量级执行单元;它们共享相同的地址空间和资源,但拥有自己的栈和寄存器。多线程可提高响应性和资源共享。
Concurrency introduces challenges such as race conditions, where multiple threads access shared data simultaneously and the outcome depends on the order of execution. Synchronisation mechanisms like semaphores, mutexes, and monitors protect critical sections. Semaphore operations (wait and signal) are atomic. The producer-consumer problem and dining philosophers problem are classic examples used to illustrate synchronisation needs.
并发带来了竞态条件等挑战,即多个线程同时访问共享数据,结果取决于执行顺序。信号量、互斥量和管程等同步机制用于保护临界区。信号量的操作(wait 和 signal)是原子的。生产者-消费者问题和哲学家进餐问题是说明同步需求的经典示例。
9. Deadlock | 死锁
Deadlock is a state where two or more processes are unable to proceed because each is waiting for a resource held by another. Four necessary conditions must hold simultaneously for deadlock to occur: mutual exclusion, hold and wait, no preemption, and circular wait. The OS can handle deadlock through prevention (denying one of the conditions), avoidance (using Banker’s algorithm to ensure safe state), detection and recovery, or simply ignoring it (the Ostrich algorithm).
死锁是一种两个或多个进程因彼此等待对方持有的资源而无法继续执行的状态。死锁发生必须同时满足四个必要条件:互斥、持有并等待、不可抢占和循环等待。操作系统可通过预防(否定其中一个条件)、避免(使用银行家算法确保安全状态)、检测与恢复,或者干脆忽略(鸵鸟算法)来处理死锁。
Banker’s algorithm requires knowledge of processes’ maximum resource needs in advance. It checks whether granting a request leaves the system in a safe state—one where processes can complete without deadlock. This is a typical exam question; you may be asked to simulate the allocation matrices or determine if a request can be granted safely.
银行家算法需要预先知道进程的最大资源需求。它检查授予请求后系统是否仍处于安全状态——即进程能够在不死锁的情况下完成的状态。这是典型的考题;你可能需要模拟分配矩阵或判断某个请求是否能安全授予。
10. File Systems and I/O | 文件系统与输入输出
A file system organises data on storage devices. It defines a logical structure—directories and files—and maps it to physical blocks. Common file allocation methods are contiguous, linked, and indexed allocation. Contiguous allocation stores a file as a continuous block of sectors, offering fast sequential access but suffers from external fragmentation and difficulty in file growth.
文件系统负责组织存储设备上的数据。它定义了一种逻辑结构(目录和文件),并将其映射到物理块。常见的文件分配方法有连续分配、链接分配和索引分配。连续分配将文件存储为连续扇区块,提供快速顺序访问,但存在外部碎片且文件增长困难。
Linked allocation scatters file blocks across the disk, each block containing a pointer to the next. It eliminates external fragmentation but random access is slow. Indexed allocation gathers all block pointers into an index block (i-node). It supports fast random access and easy file growth. Directories are special files that map file names to their attributes or i-node numbers.
链接分配将文件块分散在磁盘各处,每个块包含指向下一块的指针。它消除了外部碎片,但随机访问缓慢。索引分配将所有块指针集中到一个索引块(i 节点)中。它支持快速随机访问和轻松的文件增长。目录是一种特殊文件,它将文件名映射到其属性或 i 节点号。
11. Types of Operating System | 操作系统的类型
Operating systems can be classified based on their design and usage. Batch operating systems execute jobs in groups without direct user interaction. Time-sharing systems allow multiple users to interact simultaneously via terminals through rapid context switching. Real-time operating systems (RTOS) guarantee a response within a fixed time constraint, critical for embedded systems like airbag controllers.
操作系统可按设计和用途分类。批处理操作系统以成组方式执行作业,无需直接用户交互。分时系统通过快速上下文切换,允许多个用户通过终端同时交互。实时操作系统(RTOS)保证在固定时间限制内做出响应,对安全气囊控制器等嵌入式系统至关重要。
Distributed operating systems manage a group of independent computers and present them as a single system. Networks OSes allow resource sharing across a network but each node maintains its own autonomy. For CCEA, you should recognise embedded OSes, multi-tasking OSes, and the concept of virtualisation where multiple guest OSes run on a hypervisor.
分布式操作系统管理一组独立计算机,并将其呈现为单一系统。网络操作系统允许跨网络共享资源,但每个节点保持自主性。对 CCEA 而言,你应能识别嵌入式操作系统、多任务操作系统以及虚拟化概念(在一台物理机上通过虚拟机监控程序运行多个客户操作系统)。
12. Security and Protection | 安全与保护
Protection mechanisms control access to resources, ensuring that only authorised processes and users can perform allowed operations. The domain of protection is often implemented using access matrices, access control lists (ACLs), or capabilities. User authentication (passwords, biometrics) and the principle of least privilege are fundamental security concepts.
保护机制控制对资源的访问,确保只有授权的进程和用户才能执行允许的操作。保护域通常使用访问矩阵、访问控制列表(ACL)或能力表来实现。用户认证(密码、生物识别)和最小权限原则是基本的安全概念。
Malware protection, firewall configuration, and encryption are part of the OS’s security toolkit. Examination questions may expect you to discuss the importance of keeping the OS patched, managing user permissions, and understanding common threats such as buffer overflow attacks. An OS also provides an audit trail by logging security-relevant events.
恶意软件防护、防火墙配置和加密构成操作系统安全工具包的一部分。考题可能会期望你讨论及时为操作系统打补丁、管理用户权限以及理解缓冲区溢出攻击等常见威胁的重要性。操作系统还通过记录安全相关事件来提供审计追踪。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导