Operating Systems: Key Concepts for A-Level Computer Science | 操作系统:A-Level计算机科学关键概念

📚 Operating Systems: Key Concepts for A-Level Computer Science | 操作系统:A-Level计算机科学关键概念

An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. For A-Level Computer Science, understanding how an OS functions is essential, as it underpins everything from program execution to resource management and security. This revision guide covers core OS concepts aligned with the Edexcel specification, including process scheduling, memory allocation, interrupt handling, and file systems.

操作系统(OS)是管理计算机硬件、软件资源并为计算机程序提供通用服务的系统软件。在 A-Level 计算机科学中,理解操作系统如何运行至关重要,因为它是程序执行、资源管理和安全等一切操作的基础。本复习指南涵盖了符合 Edexcel 大纲的核心操作系统概念,包括进程调度、内存分配、中断处理和文件系统。


1. What is an Operating System? | 什么是操作系统?

An operating system is a layer of software that sits between the user/application software and the bare hardware. It abstracts the complexity of hardware, providing a consistent environment in which programs can run without needing to know the specifics of the underlying machine.

操作系统是位于用户/应用软件与裸硬件之间的一层软件。它抽象了硬件的复杂性,提供了一个一致的环境,使得程序无需了解底层机器的具体细节即可运行。

The OS performs two fundamental roles: it acts as a virtual machine by hiding messy hardware details, and as a resource manager that allocates CPU time, memory, I/O devices, and storage fairly and efficiently among competing processes.

操作系统扮演两个基本角色:它通过隐藏杂乱的硬件细节充当虚拟机,并作为资源管理器,在竞争进程之间公平、高效地分配 CPU 时间、内存、I/O 设备和存储空间。


2. Functions of an Operating System | 操作系统的功能

Modern operating systems provide a wide range of functions. These include process management, memory management, file system management, device management, security and access control, networking, and a user interface. Each function is delivered through a combination of kernel code and system utility programs.

现代操作系统提供广泛的功能,包括进程管理、内存管理、文件系统管理、设备管理、安全和访问控制、网络以及用户界面。每个功能都通过内核代码和系统实用程序的组合来实现。

Specifically, the OS must handle the creation, scheduling, and termination of processes; allocate and deallocate memory dynamically; manage reading and writing of files on disk; handle communication with peripherals through device drivers; and enforce permissions to protect data integrity.

具体来说,操作系统必须处理进程的创建、调度和终止;动态分配和释放内存;管理磁盘上的文件读写;通过设备驱动程序处理与外设的通信;并强制执行权限以保护数据完整性。


3. Process Management | 进程管理

A process is a program in execution. The OS maintains a process control block (PCB) for each process, containing process ID, program counter, register values, memory limits, and a list of open files. The PCB enables the system to save and restore a process’s state during context switching.

进程是正在执行的程序。操作系统为每个进程维护一个进程控制块(PCB),其中包含进程 ID、程序计数器、寄存器值、内存限制和打开文件列表。PCB 使得系统能够在上下文切换期间保存和恢复进程的状态。

Process states typically include NEW, READY, RUNNING, BLOCKED (or WAITING), and TERMINATED. When a process is first created, it enters the NEW state. After being admitted, it moves to READY, and from there it can be dispatched to RUNNING. If it needs to wait for an I/O event, it goes to BLOCKED; once the event completes, it returns to READY. Finally, it reaches TERMINATED when execution finishes.

进程状态通常包括新建、就绪、运行、阻塞(或等待)和终止。进程首次创建时进入新建状态;被接纳后转为就绪状态,然后可被分派到运行状态。如果需要等待 I/O 事件,就进入阻塞状态;事件完成后返回就绪状态。最终,执行结束时到达终止状态。


4. CPU Scheduling | CPU 调度

CPU scheduling determines which process gets the CPU when multiple processes are ready. The scheduler aims to maximise CPU utilisation, throughput, and fairness while minimising turnaround time, waiting time, and response time. Preemptive scheduling allows a running process to be interrupted, whereas non‑preemptive scheduling lets a process run until it voluntarily yields the CPU.

CPU 调度决定在多个进程就绪时哪个进程获得 CPU。调度程序的目标是最大化 CPU 利用率、吞吐量和公平性,同时最小化周转时间、等待时间和响应时间。抢占式调度允许中断正在运行的进程,而非抢占式调度则让进程持续运行直到主动让出 CPU。

Common algorithms include First‑Come, First‑Served (FCFS), Shortest Job First (SJF), Priority Scheduling, and Round Robin (RR). Round Robin uses a fixed time quantum; if the quantum is too large it degenerates to FCFS, and if too small it causes excessive context switches. Multilevel Feedback Queue scheduling combines multiple queues with different priorities and time quanta.

常见算法包括先来先服务(FCFS)、最短作业优先(SJF)、优先级调度和轮转调度(RR)。轮转调度使用固定的时间片;如果时间片太大,会退化为先来先服务,太小则导致过多的上下文切换。多级反馈队列调度结合了多个具有不同优先级和时间片的队列。


5. Interrupts and Interrupt Handling | 中断与中断处理

An interrupt is a signal that causes the processor to temporarily suspend the current task and transfer control to a special routine called an interrupt handler. Interrupts can be hardware‑generated (e.g., a key press, a disk I/O completion) or software‑generated (traps, such as division by zero). They allow the CPU to respond quickly to external events without continuous polling.

中断是一种信号,它使处理器暂时挂起当前任务并将控制权转移给称为中断处理程序的特殊例程。中断可以由硬件产生(例如按键、磁盘 I/O 完成)或由软件产生(陷阱,例如除零错误)。它们使 CPU 能够快速响应外部事件,而无需持续轮询。

When an interrupt occurs, the CPU finishes the current instruction, pushes the program counter and registers onto the stack, determines the interrupt vector, and jumps to the corresponding interrupt service routine (ISR). After servicing the interrupt, the saved state is restored and normal execution resumes. Priority levels ensure that higher‑priority interrupts can pre‑empt lower‑priority ones.

当中断发生时,CPU 完成当前指令,将程序计数器和寄存器压入栈,确定中断向量,然后跳转到相应的中断服务例程(ISR)。处理完中断后,恢复保存的状态,继续正常执行。优先级机制确保高优先级中断可以抢占低优先级处理。


6. Memory Management | 内存管理

Memory management is concerned with allocating primary memory among processes and ensuring that they do not interfere with each other. The OS usually divides memory into user space and kernel space; the kernel is protected from direct access by user processes.

内存管理涉及在进程之间分配主存并确保它们互不干扰。操作系统通常将内存分为用户空间和内核空间;内核受保护,用户进程不能直接访问。

Simple schemes include single contiguous allocation, fixed‑sized partitioning, and dynamic partitioning. Fixed partitions lead to internal fragmentation, while dynamic partitions can cause external fragmentation. Compaction can be used to reduce external fragmentation, but it is costly. Base and limit registers provide hardware protection: every memory access is checked against these registers.

简单的管理方案包括单一连续分配、固定大小分区和动态分区。固定分区导致内部碎片,而动态分区可能引起外部碎片。压缩可用于减少外部碎片,但代价较高。基址寄存器和界限寄存器提供硬件保护:每次内存访问都要根据这些寄存器进行检查。


7. Paging and Virtual Memory | 分页与虚拟内存

Paging is a memory management scheme that eliminates the need for contiguous allocation of physical memory. The logical address space of a process is divided into fixed‑sized pages, and physical memory is divided into frames of the same size. The OS maintains a page table for each process, mapping page numbers to frame numbers, which allows non‑contiguous allocation.

分页是一种内存管理方案,消除了对物理内存连续分配的需求。进程的逻辑地址空间被划分为固定大小的页面,物理内存被划分为相同大小的帧。操作系统为每个进程维护一个页表,将页码映射到帧号,从而实现非连续分配。

Virtual memory extends paging by allowing a process to execute even if not all its pages are in physical RAM. Pages that are not currently needed can be swapped out to secondary storage (e.g., disk) and brought back on demand. This allows the execution of programs larger than physical memory. Modern systems use a demand paging with a page replacement algorithm (e.g., Least Recently Used, LRU) to decide which page to evict when a page fault occurs.

虚拟内存扩展了分页,允许进程即使未将所有页面加载到物理 RAM 中也能执行。当前不需要的页面可以被换出到辅助存储器(如磁盘),并在需要时调入。这允许执行比物理内存更大的程序。现代系统采用请求分页和页面置换算法(如最近最少使用,LRU),在发生缺页异常时决定淘汰哪个页面。


8. File Systems | 文件系统

A file system provides a way of organising and storing files on storage devices. It defines how data is structured in directories, and how metadata such as file names, permissions, creation date, and size are managed. The OS presents a logical view of files and directories, hiding the physical layout on disk.

文件系统提供了一种在存储设备上组织和存储文件的方法。它定义了数据在目录中的结构,以及如何管理文件名、权限、创建日期和大小等元数据。操作系统呈现文件和目录的逻辑视图,隐藏磁盘上的物理布局。

Common allocation methods include contiguous allocation, linked allocation, and indexed allocation. Contiguous allocation offers fast sequential access but suffers from external fragmentation. Linked allocation avoids fragmentation but is poor for random access. Indexed allocation, used in systems like Unix (inodes), keeps all block pointers together, supporting both sequential and random access. Free space management is handled through bitmaps or free lists.

常见的分配方法包括连续分配、链接分配和索引分配。连续分配提供快速的顺序访问,但存在外部碎片问题。链接分配避免了碎片,但随机访问性能差。索引分配(如 Unix 中的 inode 节点)将所有块指针集中在一起,同时支持顺序访问和随机访问。空闲空间管理通过位图或空闲列表来处理。


9. Device Management and I/O | 设备管理与输入输出

Device management involves the OS controlling hardware peripherals through device drivers. A device driver is a software module that translates generic operating system requests into device‑specific commands. This abstraction allows applications to perform I/O without needing to know the physical characteristics of the hardware.

设备管理涉及操作系统通过设备驱动程序控制硬件外设。设备驱动程序是一种软件模块,将通用的操作系统请求转换为特定于设备的命令。这种抽象使应用程序能够执行 I/O 操作而无须了解硬件的物理特性。

I/O can be performed using programmed I/O, interrupt‑driven I/O, or direct memory access (DMA). In programmed I/O, the CPU continuously polls the device status register. In interrupt‑driven I/O, the device triggers an interrupt when ready, reducing CPU waste. DMA allows a dedicated controller to transfer blocks of data between memory and device without CPU intervention, further improving efficiency.

I/O 操作可以采用程序控制 I/O、中断驱动 I/O 或直接存储器访问(DMA)。在程序控制 I/O 中,CPU 持续轮询设备状态寄存器。在中断驱动 I/O 中,设备就绪时触发中断,减少 CPU 浪费。DMA 允许专用控制器在内存和设备之间传输数据块,无需 CPU 干预,从而进一步提高效率。


10. Security and Protection | 安全与保护

Operating systems enforce security policies to protect system resources from unauthorised access and malicious software. Protection mechanisms include user authentication (passwords, biometrics), access control lists (ACLs), and capability‑based systems. The OS runs processes in distinct privilege levels: user mode and kernel mode, with the kernel having unrestricted access.

操作系统强制执行安全策略,以保护系统资源免受未经授权的访问和恶意软件的侵害。保护机制包括用户身份验证(密码、生物识别)、访问控制列表(ACL)和基于能力的安全系统。操作系统在不同的特权级别下运行进程:用户模式和内核模式,内核拥有不受限制的访问权限。

Encryption, secure boot, and trusted platform modules (TPM) are used to ensure data confidentiality and system integrity. Additionally, modern operating systems implement sandboxing and privilege separation to limit the damage caused by a compromised application. The principle of least privilege is applied, granting each process only the minimum rights it needs.

加密、安全启动和可信平台模块(TPM)用于确保数据机密性和系统完整性。此外,现代操作系统实施沙箱和权限分离,以限制被攻破的应用程序所造成的损害。最小特权原则得到应用,仅授予每个进程所需的最低权限。


11. Types of Operating Systems | 操作系统的类型

Operating systems can be categorised by their design goals and usage contexts. Batch operating systems process jobs in groups without direct user interaction. Multiprogramming systems keep multiple jobs in memory simultaneously, switching between them to improve CPU utilisation. Timesharing (multitasking) systems extend this by giving the illusion of concurrency to multiple interactive users.

操作系统可根据设计目标和使用场景进行分类。批处理操作系统成组处理作业,无需直接用户交互。多道程序系统将多个作业同时保留在内存中,在它们之间切换以提高 CPU 利用率。分时(多任务)系统进一步扩展了这一思想,为多个交互式用户提供了并发的错觉。

Real‑time operating systems (RTOS) guarantee that tasks are completed within strict time constraints, which is critical for embedded systems, aviation, and medical devices. Distributed operating systems manage a collection of independent computers to appear as a single system to users. Mobile operating systems are optimised for touch input, battery efficiency, and connectivity.

实时操作系统(RTOS)确保任务在严格的时间约束内完成,这对于嵌入式系统、航空和医疗设备至关重要。分布式操作系统管理一组独立的计算机,使用户看到单一系统。移动操作系统针对触摸输入、电池效率和连接性进行了优化。


12. Summary and Exam Tips | 总结与考试技巧

In your Edexcel A-Level exam, you will need to explain how the OS manages processes, memory, and I/O, and compare scheduling algorithms. Be prepared to draw state diagrams for processes, illustrate paging with address translation, and discuss how interrupts support multitasking. Use precise terminology—refer to PCBs, page tables, and interrupt vectors accurately.

在 Edexcel A-Level 考试中,你需要解释操作系统如何管理进程、内存和 I/O,并比较调度算法。准备绘制进程的状态图,用地址转换说明分页,并讨论中断如何支持多任务处理。使用精确的术语——准确提及 PCB、页表和中断向量。

Understanding how these components work together will also strengthen your programming skills, as you will appreciate how memory allocation and I/O operations affect the performance of your code. Remember to link theory to practical examples, such as how a round‑robin scheduler gives the feeling of a responsive system, or why virtual memory allows large datasets to be processed even on machines with limited RAM.

理解这些组件如何协同工作也将增强你的编程技能,因为你会理解内存分配和 I/O 操作如何影响代码的性能。记住将理论与实际例子联系起来,例如轮转调度器如何给人一种系统反应灵敏的感觉,或者为什么虚拟内存允许在 RAM 有限的机器上处理大型数据集。

Published by TutorHao | Programming Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading