📚 A-Level CIE Computer Science: Operating System Essentials | A-Level CIE 计算机科学:操作系统考点精讲
An operating system (OS) is the most fundamental software that enables all other programs to run. It acts as a bridge between the user, application software, and the computer hardware, managing resources such as the processor, memory, storage, and input/output devices. Mastering OS concepts is essential for A-Level CIE Computer Science, as it forms the backbone of understanding how computers efficiently execute tasks, ensure security, and handle concurrent operations. This guide covers every critical topic from process management and scheduling to memory, files, interrupts, and concurrency, providing clear bilingual explanations aligned with the CIE syllabus.
操作系统是最基础的软件,它使所有其他程序得以运行。它充当用户、应用软件与计算机硬件之间的桥梁,管理处理器、内存、存储和输入/输出设备等资源。掌握操作系统概念对于 A-Level CIE 计算机科学至关重要,因为它是理解计算机如何高效执行任务、确保安全以及处理并发操作的基础。本指南覆盖从进程管理和调度到内存、文件、中断与并发的每一个关键主题,提供与 CIE 大纲一致的中英双语清晰讲解。
1. What is an Operating System? | 什么是操作系统?
An operating system is a collection of system software that manages hardware resources and provides a platform for application software to execute. It hides the complexity of hardware by offering a simplified interface through system calls. The core part of the OS, called the kernel, remains in memory at all times and handles critical tasks such as process scheduling, memory allocation, and interrupt handling.
操作系统是管理硬件资源并为应用软件提供执行平台的系统软件集合。它通过系统调用提供简化的接口,隐藏硬件的复杂性。操作系统的核心部分称为内核,始终驻留在内存中,处理进程调度、内存分配和中断处理等关键任务。
Without an operating system, every application would need to include code to directly control the hardware, making software development extremely complex. The OS also ensures fair and secure sharing of resources when multiple programs run simultaneously. In A-Level terms, you must be able to distinguish between the OS and utility software, and explain the role of the kernel.
如果没有操作系统,每个应用程序都需要包含直接控制硬件的代码,软件将变得极其复杂。当多个程序同时运行时,操作系统还确保资源公平且安全地共享。在 A-Level 中,必须能够区分操作系统和实用程序软件,并解释内核的作用。
2. Functions of an Operating System | 操作系统的功能
The operating system performs several key functions: process management, memory management, file management, device management, security and access control, networking, and providing a user interface. It also handles error detection and system performance monitoring. Each function is carried out by dedicated OS components that work together seamlessly.
操作系统执行若干关键功能:进程管理、内存管理、文件管理、设备管理、安全与访问控制、网络以及提供用户界面。它还负责错误检测和系统性能监控。每项功能由专门的 OS 组件执行,它们协同工作。
Process management involves creating, scheduling, and terminating processes. Memory management keeps track of which parts of memory are in use. File management organises data into files and directories. Device management uses drivers to communicate with hardware. I/O management is crucial for interacting with peripherals. Security ensures that only authorised users access the system.
进程管理涉及创建、调度和终止进程。内存管理跟踪内存中哪些部分正在使用。文件管理将数据组织成文件和目录。设备管理使用驱动程序与硬件通信。输入/输出管理对于与外围设备交互至关重要。安全确保只有授权用户才能访问系统。
3. Process Management | 进程管理
A process is a program in execution. Unlike a program, which is a passive collection of instructions stored on disk, a process is active and requires resources such as CPU time, memory, and I/O. Each process is represented in the OS by a Process Control Block (PCB) containing its state, program counter, register contents, and memory allocation details.
进程是正在执行的程序。与程序不同——程序是存储在磁盘上的被动指令集合——进程是活动的,需要 CPU 时间、内存和 I/O 等资源。每个进程在操作系统中由一个进程控制块(PCB)表示,其中包含进程状态、程序计数器、寄存器内容和内存分配细节。
A process can be in one of several states: new (being created), ready (waiting for CPU), running (currently using the CPU), waiting/blocked (waiting for an event, e.g. I/O completion), and terminated (finished). The OS moves processes between these states through scheduling and interrupt handling. Understanding the process state diagram is a common exam requirement.
进程可以处于以下几种状态之一:新建(正在创建)、就绪(等待 CPU)、运行(正在使用 CPU)、等待/阻塞(等待事件,如 I/O 完成)和终止(已完成)。操作系统通过调度和中断处理在状态之间转移进程。理解进程状态图是常见的考试要求。
Context switching occurs when the CPU switches from one process to another, saving the state of the current process and loading the state of the next. This introduces overhead, so efficient scheduling is important.
上下文切换发生在 CPU 从一个进程切换到另一个进程时,保存当前进程的状态并加载下一个进程的状态。这会引入开销,因此高效调度非常重要。
4. Process Scheduling | 进程调度
Scheduling decides which ready process gets the CPU next. The OS maintains a ready queue and uses a scheduling algorithm. Algorithms can be preemptive (the OS can take the CPU away) or non-preemptive (a running process continues until it blocks or terminates). Key algorithms tested in CIE include First Come First Served (FCFS), Shortest Job First (SJF), Priority Scheduling, and Round Robin (RR).
调度决定哪个就绪进程接下来获得 CPU。操作系统维护一个就绪队列并使用调度算法。算法可以是抢占式(操作系统可以夺走 CPU)或非抢占式(运行的进程一直运行到阻塞或终止)。CIE 考核的关键算法包括先来先服务(FCFS)、最短作业优先(SJF)、优先级调度和轮转法(RR)。
| Algorithm | Type | Characteristics |
|---|---|---|
| FCFS | Non-preemptive | Simple, convoy effect possible |
| SJF | Non-preemptive / Preemptive (SRTF) | Min average waiting time, need to estimate burst time |
| Priority | Preemptive / Non-preemptive | Starvation possible; ageing used to prevent it |
| Round Robin | Preemptive | Time quantum critical; fair but high turnaround |
In FCFS, processes are executed in arrival order. SJF selects the process with the shortest expected CPU burst. Priority scheduling assigns a priority; Round Robin gives each process a small time quantum (e.g., 10ms) and cycles through them. You need to analyse waiting time, turnaround time, and be able to draw Gantt charts.
在 FCFS 中,进程按到达顺序执行。SJF 选择预计 CPU 执行时间最短的进程。优先级调度分配优先级;轮转法给每个进程一个小的固定时间片(例如 10ms)并循环执行。需要分析等待时间、周转时间,并能够绘制甘特图。
5. Memory Management | 内存管理
Memory management ensures that multiple processes can reside in main memory without interfering with each other. It is responsible for allocating and deallocating memory spaces, while keeping track of used and free memory. Two fundamental techniques are contiguous allocation and non-contiguous allocation (paging and segmentation).
内存管理确保多个进程可以驻留在主存中而不彼此干扰。它负责分配和释放内存空间,并跟踪已使用和空闲的内存。两种基本技术是连续分配和非连续分配(分页和分段)。
In contiguous allocation, each process is placed in a single block of memory. This can lead to external fragmentation – free memory broken into small pieces. Compaction can solve this but is time-consuming. Paging, on the other hand, divides memory into fixed-size frames and processes into pages of the same size. It eliminates external fragmentation but introduces internal fragmentation (wasted space inside a page).
在连续分配中,每个进程放置在一个内存块中。这可能导致外部碎片——空闲内存破碎成小块。紧凑可以解决此问题但耗时。另一方面,分页将内存划分为固定大小的帧,进程划分为相同大小的页。它消除了外部碎片,但引入了内部碎片(页内浪费的空间)。
The OS maintains a page table for each process to map logical addresses to physical addresses. A logical address consists of a page number and an offset. For example, with 4 KiB pages, the offset is 12 bits, allowing addressing within a page. Address translation uses the page table base register.
操作系统为每个进程维护一个页表以将逻辑地址映射到物理地址。逻辑地址由页号和偏移量组成。例如,对于 4 KiB 页面,偏移量为 12 位,允许在页内寻址。地址转换使用页表基址寄存器。
6. Virtual Memory & Paging | 虚拟内存与分页
Virtual memory is a technique that allows the execution of processes that are not completely in memory. It gives the illusion of a very large, contiguous logical address space by using a backing store (usually a disk). Only the required pages are loaded into physical memory, a concept known as demand paging.
虚拟内存是一种允许执行未完全装入内存的进程的技术。它通过使用后备存储(通常是磁盘)来提供非常大的、连续的逻辑地址空间错觉。只将需要的页面加载到物理内存中,这一概念称为按需调页。
When a page that is not in memory is accessed, a page fault occurs. The OS must load the page from disk, possibly replacing an existing page. Page replacement algorithms include FIFO (oldest page replaced) and LRU (Least Recently Used, which replaces the page that has not been accessed for the longest time). LRU generally gives better performance but is harder to implement.
当访问不在内存中的页面时,会发生缺页中断。操作系统必须从磁盘加载该页面,可能需要替换一个现有页面。页面置换算法包括 FIFO(替换最旧的页面)和 LRU(最近最少使用,替换最长时间未访问的页面)。LRU 通常性能更好但实现更困难。
Excessive paging activity, where the system spends more time swapping than executing, is called thrashing. It severely degrades performance. To prevent thrashing, the OS can reduce the degree of multiprogramming or use a working set model.
当系统花费在交换上的时间多于执行时间时,过度的分页活动称为抖动。它会严重降低性能。为了预防抖动,操作系统可以减少多道程序度或使用工作集模型。
7. File Management | 文件管理
The file system organises and stores information on secondary storage devices. It provides a logical view of files and directories, abstracting physical storage details. Files have attributes such as name, type, size, protection, and creation date. The OS supports operations like create, delete, open, close, read, and write.
文件系统组织并存储辅助存储设备上的信息。它提供文件和目录的逻辑视图,抽象掉物理存储细节。文件具有名称、类型、大小、保护及创建日期等属性。操作系统支持创建、删除、打开、关闭、读取和写入等操作。
Files can be allocated on disk using contiguous allocation (fast, but suffers from external fragmentation), linked allocation (each block points to the next, no fragmentation but slow random access), or indexed allocation (an index block holds pointers to all data blocks, supporting efficient direct access). The CIE syllabus expects you to compare these methods.
文件可以采用连续分配(快速但有外部碎片)、链接分配(每个块指向下一个,无碎片但随机访问慢)或索引分配(一个索引块保存所有数据块的指针,支持高效直接访问)的方式分配在磁盘上。CIE 大纲希望你能比较这些方法。
Directory structures include single-level, two-level, and tree-structured (hierarchical) directories. Access control mechanisms, such as access control lists (ACLs), determine who can read, write, or execute a file.
目录结构包括单级、两级和树形(层次)目录。访问控制机制,如访问控制列表(ACL),决定谁可以读、写或执行文件。
8. Interrupts & I/O Management | 中断与输入输出管理
An interrupt is a signal that causes the CPU to suspend its current task and transfer control to an interrupt handler. Interrupts can be generated by hardware (e.g., key press, disk I/O completion) or software (system calls, exceptions). They allow the OS to respond promptly to events, enabling efficient multitasking and I/O handling.
中断是一个信号,使 CPU 暂停当前任务并将控制权转移给中断处理程序。中断可以由硬件(如按键、磁盘 I/O 完成)或软件(系统调用、异常)产生。它们使操作系统能迅速响应事件,实现高效多任务和 I/O 处理。
When an interrupt occurs, the CPU completes the current instruction, saves the program counter and other registers, and jumps to the interrupt service routine (ISR). After execution, it restores the saved state and resumes the interrupted task. The OS maintains an interrupt vector to locate ISRs quickly. Prioritisation ensures critical interrupts (e.g., power failure) are handled first.
当中断发生时,CPU 完成当前指令,保存程序计数器和其他寄存器,然后跳转到中断服务程序(ISR)。执行完毕后,恢复保存的状态并继续被中断的任务。操作系统维护中断向量表以快速定位 ISR。优先级确保关键中断(如电源故障)首先被处理。
I/O management uses techniques like programmed I/O (CPU polls device), interrupt-driven I/O (device interrupts when ready), and Direct Memory Access (DMA) (a controller transfers data directly to memory, bypassing CPU). DMA is essential for high-speed devices to reduce CPU overhead.
I/O 管理使用程序控制 I/O(CPU 轮询设备)、中断驱动 I/O(设备就绪时中断)和直接内存访问(DMA,控制器直接向内存传输数据,绕过 CPU)等技术。DMA 对于高速设备至关重要,以减少 CPU 开销。
9. Concurrency & Deadlock | 并发与死锁
Concurrency arises when multiple processes execute simultaneously, leading to potential issues like race conditions, where the outcome depends on the order of execution. To ensure mutual exclusion, the OS provides mechanisms such as semaphores and mutex locks. A critical section is a code segment that accesses shared resources and must not be executed by more than one process at a time.
当多个进程同时执行时出现并发,可能导致竞态条件等问题,其结果取决于执行顺序。为确保互斥,操作系统提供信号量和互斥锁等机制。临界区是访问共享资源的代码段,一次不能由多个进程执行。
A deadlock is a state where two or more processes are blocked forever, each waiting for a resource held by another. Four necessary conditions must hold simultaneously: mutual exclusion, hold and wait, no preemption, and circular wait. Deadlock can be handled by prevention (breaking one of the conditions), avoidance (using Banker’s algorithm to ensure safe state), or detection and recovery.
死锁是两个或多个进程永远阻塞,每个进程都在等待另一个进程持有的资源的状态。必须同时满足四个必要条件:互斥、持有并等待、不可抢占和循环等待。死锁可通过预防(破坏其中一个条件)、避免(使用银行家算法确保安全状态)或检测与恢复来处理。
10. User Interface & System Calls | 用户界面与系统调用
The operating system provides interfaces for users to interact with the system: Command Line Interface (CLI) and Graphical User Interface (GUI). CLI allows users to type commands and is more resource-efficient, while GUI provides a visual, intuitive environment with windows, icons, and pointers.
操作系统为用户提供交互界面:命令行界面(CLI)和图形用户界面(GUI)。CLI 允许用户键入命令,资源效率更高;GUI 提供窗口、图标和指针的直观视觉环境。
Applications request services from the OS through system calls. They provide an interface between a process and the kernel. When a system call is made, the processor switches from user mode to kernel mode to execute privileged instructions, then returns to user mode. Examples include file operations (open, read, write) and process control (fork, exit).
应用程序通过系统调用向操作系统请求服务。它们提供进程与内核之间的接口。当进行系统调用时,处理器从用户态切换到内核态以执行特权指令,然后返回用户态。示例包括文件操作(打开、读取、写入)和进程控制(fork、退出)。
11. Security & Protection | 安全与保护
Security in an OS involves protecting the system and user data from unauthorised access, malicious software, and internal threats. Protection mechanisms include authentication (verifying user identity, e.g., passwords, biometrics), access control (managing permissions using Access Control Lists), and encryption of data at rest and in transit.
操作系统的安全性涉及保护系统和用户数据免受未经授权的访问、恶意软件和内部威胁。保护机制包括认证(验证用户身份,如密码、生物识别)、访问控制(使用访问控制列表管理权限)以及静态和传输数据的加密。
Memory protection prevents one process from accessing another’s memory space, often using base and limit registers or paging hardware. The OS also enforces file permissions (read, write, execute) for owner, group, and others. A trusted computing base (TCB) includes the components responsible for enforcing security policies.
内存保护防止一个进程访问另一个进程的内存空间,通常使用基址-界限寄存器或分页硬件。操作系统还针对所有者、组和其他人强制实施文件权限(读、写、执行)。可信计算基(TCB)包括负责执行安全策略的组件。
12. Exam Tips & Common Pitfalls | 考试技巧与常见误区
When answering CIE exam questions on operating systems, always define key terms precisely. For instance, state that a process is a program in execution, and distinguish it from a program. Use clear, labelled diagrams (e.g., process state diagram, page table translation) where feasible, and practise drawing Gantt charts for scheduling.
在回答 CIE 操作系统考试问题时,务必精确定义关键术语。例如,说明进程是执行中的程序,并区别于程序本身。在可行的情况下使用清晰、带标注的图表(如进程状态图、页表转换),并练习绘制调度甘特图。
Avoid confusing paging with segmentation, or deadlock prevention with avoidance. Remember that internal fragmentation is in paging, external fragmentation in contiguous allocation. When comparing scheduling algorithms, mention both advantages and limitations. For page replacement, explain the difference between FIFO and LRU, and describe Belady’s anomaly for FIFO.
避免混淆分页与分段,或者死锁预防与避免。记住内部碎片存在于分页中,外部碎片存在于连续分配中。在比较调度算法时,要提及优点和局限。对于页面置换,解释 FIFO 和 LRU 的区别,并描述 FIFO 的 Belady 异常。
Always relate your explanations to the OS’s role as a resource manager. For concurrency and deadlock, clearly state the necessary conditions and provide a simple scenario. Ensure you understand how interrupts enable multitasking and why DMA is efficient. Finally, practise past paper questions to become familiar with the depth of analysis expected.
始终将解释与操作系统作为资源管理者的角色联系起来。对于并发和死锁,清楚地说明必要条件并给出简单场景。确保理解中断如何实现多任务以及 DMA 为何高效。最后,练习历年真题以熟悉所需的深度分析。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导