📚 Operating Systems: Key Concepts for A-Level | A-Level 操作系统核心概念
The operating system (OS) is the most essential software running on any computing device, acting as an intermediary between users and hardware. In A-Level Computer Science, a solid grasp of how the OS manages resources, schedules processes, and handles interrupts is vital. This article covers the core OS concepts required for the Edexcel specification, including memory management, scheduling algorithms, interrupt handling, and virtualisation.
操作系统是运行在任何计算设备上最重要的软件,充当用户与硬件之间的中介。在A-Level计算机科学中,牢固掌握操作系统如何管理资源、调度进程以及处理中断至关重要。本文涵盖了Edexcel考纲要求的核心操作系统概念,包括内存管理、调度算法、中断处理和虚拟化。
1. What is an Operating System? | 什么是操作系统?
An operating system is a suite of programs that controls the execution of applications and manages computer hardware. It provides a user interface, executes and provides services for applications software, and manages system resources such as the processor, memory, and I/O devices. The kernel is the core component, residing in memory at all times, handling low-level tasks like process scheduling and hardware communication. Without an OS, users would need to write programs that directly interact with hardware, which is impractical.
操作系统是一组控制应用程序执行并管理计算机硬件的程序。它提供用户界面,执行并为应用软件提供服务,并管理系统资源,如处理器、内存和I/O设备。内核是核心组件,始终驻留在内存中,处理低级任务,如进程调度和硬件通信。没有操作系统,用户就需要编写直接与硬件交互的程序,这很不现实。
2. Functions of an Operating System | 操作系统的功能
The OS performs several critical functions that can be grouped into resource management and service provision. Key functions include: memory management (allocating RAM to processes and handling virtual memory), processor scheduling (deciding which process runs at what time), file management (organising data on secondary storage), input/output management (controlling peripherals through device drivers), networking (enabling communication between devices), security (enforcing access rights and user authentication), and interrupt handling (responding to hardware and software events). Each of these functions ensures the system operates efficiently and securely.
操作系统执行多项关键功能,可归为资源管理和服务提供两大类。主要功能包括:内存管理(为进程分配RAM并处理虚拟内存)、处理器调度(决定哪个进程何时运行)、文件管理(组织辅助存储器上的数据)、输入/输出管理(通过设备驱动程序控制外设)、网络(实现设备间通信)、安全(执行访问权限和用户认证)以及中断处理(响应硬件和软件事件)。每一项功能都确保系统高效、安全地运行。
3. Memory Management | 内存管理
Memory management involves allocating blocks of RAM to processes and ensuring efficient use of limited physical memory. The OS uses techniques such as paging, where memory is divided into fixed-size pages (typically 4 KB), and segmentation, where it is divided into variable-sized segments according to logical divisions like code, data, and stack. Virtual memory combines RAM and disk space to allow execution of programs larger than physical memory. When RAM is full, the OS swaps idle pages to a swap file on disk. A page fault occurs if a required page is not in RAM, triggering the OS to load it from disk, possibly replacing another page. This abstraction enables multitasking and protects processes from interfering with each other.
内存管理涉及为进程分配RAM块,并确保有限物理内存的高效使用。操作系统采用分页(将内存划分为固定大小的页,通常4 KB)和分段(根据逻辑划分如代码、数据、堆栈划分为可变大小的段)等技术。虚拟内存结合RAM和磁盘空间,允许运行比物理内存更大的程序。当RAM已满时,操作系统将空闲页面交换到磁盘上的交换文件。如果所需的页不在RAM中,则发生缺页错误,触发操作系统从磁盘加载它,可能替换另一个页。这种抽象支持多任务处理,并保护进程互不干扰。
4. Processes and Process States | 进程与进程状态
A process is a program in execution, consisting of the program code, current activity represented by the program counter, and associated resources. The OS assigns each process a process control block (PCB) that stores its state, priority, and resource allocation. Processes can be in one of five states: New (just created), Ready (waiting in a queue for CPU time), Running (currently executing on the processor), Blocked (waiting for an event such as I/O completion), and Terminated (finished execution). Transitions occur due to scheduler decisions or I/O events. For example, a running process may voluntarily yield the CPU (becoming ready) or be preempted if its time slice expires. A blocked process moves to ready when the awaited event occurs.
进程是正在执行的程序,由程序代码、由程序计数器表示的当前活动以及相关资源组成。操作系统为每个进程分配一个进程控制块(PCB),存储其状态、优先级和资源分配。进程可处于五种状态之一:新建(刚创建)、就绪(在队列中等待CPU时间)、运行(正在处理器上执行)、阻塞(等待I/O完成等事件)和终止(执行结束)。由于调度决策或I/O事件,会发生状态转换。例如,一个正在运行的进程可能自愿释放CPU(变为就绪),或者如果其时间片用完则被抢占。当等待的事件发生时,阻塞进程转移到就绪状态。
5. Scheduling Algorithms | 调度算法
Scheduling determines the order in which processes gain CPU access. The long-term scheduler admits processes to the ready queue, while the short-term scheduler (dispatcher) selects the next process to run. Common algorithms include:
调度决定进程获得CPU访问的顺序。长期调度器将进程接纳到就绪队列,而短期调度器(分派器)选择下一个运行的进程。常见的算法包括:
| Algorithm | Type | Advantage | Disadvantage |
|---|---|---|---|
| First-Come, First-Served (FCFS) | Non-preemptive | Simple; no starvation | Convoy effect; poor average waiting time |
| Shortest Job First (SJF) | Non-preemptive / Preemptive (SRTF) | Minimises average waiting time | Requires knowledge of burst times; starvation for long jobs |
| Round Robin (RR) | Preemptive | Fair; good response time for interactive systems | Performance depends on time quantum; high overhead if quantum too small |
| Priority Scheduling | Preemptive / Non-preemptive | Allows important processes to run quickly | Starvation of low-priority processes; solved by aging |
| Multilevel Feedback Queue | Preemptive (dynamic) | Adaptive; balances short and long jobs | Complex to configure |
The goal of scheduling is to optimise performance metrics such as throughput (processes completed per unit time), turnaround time (total time from submission to completion), waiting time (sum of periods spent in ready queue), and response time (time until the first response). Real-world operating systems often use hybrid approaches with multiple queues and dynamic priorities.
调度的目标是优化性能指标,如吞吐量(单位时间内完成的进程数)、周转时间(从提交到完成的总时间)、等待时间(在就绪队列中花费的时间总和)和响应时间(首次响应的时间)。现实中的操作系统通常采用多队列和动态优先级的混合方法。
6. Interrupts and Interrupt Handling | 中断与中断处理
An interrupt is a hardware or software signal that causes the CPU to suspend its current task and transfer control to a special routine called an interrupt service routine (ISR). Hardware interrupts come from devices like a keyboard, mouse, or timer. Software interrupts (also called traps or exceptions) are generated by programs, for example, when a system call is requested or an error like division by zero occurs. When an interrupt is received, the CPU finishes the current instruction, saves the program counter and processor status word onto the stack, and then uses an interrupt vector table to locate the ISR address. After the ISR executes, the context is restored and the original process resumes. Interrupts are fundamental to modern multitasking because the timer interrupt triggers the scheduler to preempt a running process, ensuring fair CPU time distribution.
中断是一个硬件或软件信号,它使CPU暂停当前任务,并将控制权转交给一个称为中断服务程序(ISR)的特殊例程。硬件中断来自键盘、鼠标或定时器等设备。软件中断(也称为陷阱或异常)由程序生成,例如,当请求系统调用或发生除零错误时。接收到中断后,CPU完成当前指令,将程序计数器和处理器状态字保存在堆栈上,然后使用中断向量表定位ISR地址。ISR执行完毕后,恢复上下文并恢复原进程。中断对现代多任务处理至关重要,因为定时器中断会触发调度器抢占正在运行的进程,确保公平分配CPU时间。
7. Types of Operating Systems | 操作系统的类型
Operating systems are categorised based on their intended use and capabilities. The main types are:
操作系统根据其预期用途和功能进行分类。主要类型如下:
- Batch OS: Jobs are collected, batched, and processed without user interaction. Efficient for processing large volumes of data but provides no interactivity.
- Multi-tasking OS: Allows multiple processes to reside in memory and share the CPU. Time-sharing gives the illusion of simultaneous execution. Examples: Windows, macOS.
- Real-time OS (RTOS): Must process events and respond within strict time constraints. Used in embedded systems like airbag controllers, medical devices, and industrial robots. Can be hard real-time (missed deadline = system failure) or soft.
- Distributed OS: Manages a collection of independent computers connected via a network, presenting them as a single system. Resources are shared across nodes.
- Embedded OS: Designed for dedicated devices with limited resources, often stored in ROM. Found in microwaves, ATMs, and car infotainment.
- Mobile OS: Optimised for smartphones and tablets, emphasising touch interfaces and power efficiency. Examples: Android, iOS.
In the A-Level exam, you should be able to explain the characteristics of multi-tasking, real-time, and embedded systems, and give appropriate scenarios where each is used.
- 批处理OS:作业被收集、成批处理,无需用户交互。处理大量数据高效,但无交互性。
- 多任务OS:允许多个进程驻留内存并共享CPU。分时技术给人以同时执行的错觉。例如:Windows、macOS。
- 实时OS(RTOS):必须在严格的时间限制内处理并响应事件。用于安全气囊控制器、医疗设备和工业机器人等嵌入式系统。可以是硬实时(错过截止时间=系统失败)或软实时。
- 分布式OS:管理一组通过网络连接的独立计算机,将其呈现为单一系统。资源跨节点共享。
- 嵌入式OS:为资源有限的专用设备设计,通常存储在ROM中。见于微波炉、ATM和车载信息娱乐系统。
- 移动OS:针对智能手机和平板电脑优化,强调触控界面和功耗效率。例如:Android、iOS。
在A-Level考试中,应能解释多任务、实时和嵌入式系统的特征,并列举每种适用的场景。
8. BIOS and Device Drivers | BIOS 与设备驱动程序
The BIOS (Basic Input/Output System) is firmware stored on a ROM chip on the motherboard. When a computer is powered on, the BIOS performs the Power-On Self-Test (POST) to check essential hardware, then loads the bootloader from the boot sector of the hard disk. The bootloader in turn loads the operating system kernel. The BIOS also provides a basic set of routines for input/output, which the OS can use during early boot. Device drivers are software components that translate generic OS commands into device-specific instructions. Each hardware device (e.g., printer, graphics card) requires a driver that understands its controller’s registers and data formats. Modern operating systems include a large library of drivers and support plug-and-play, where new devices are automatically detected and drivers installed. Drivers operate in kernel mode, having direct access to hardware, so a faulty driver can crash the entire system.
BIOS(基本输入/输出系统)是存储在主板上ROM芯片中的固件。计算机开机时,BIOS执行加电自检(POST)检查基本硬件,然后从硬盘启动扇区加载引导程序。引导程序随后加载操作系统内核。BIOS还提供了一套基本的输入/输出例程,操作系统可在
Published by TutorHao | A-Level 编程 Revision Series | aleveler.com
Find Edexcel A Level Business Textbooks on eBay UK
New, used and second-hand copies of textbooks and revision guides are often much cheaper than retail — check current listings and prices before you buy.
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply