📚 Operating Systems Key Concepts for CCEA | IB CCEA 计算机:操作系统 考点精讲
An operating system (OS) is the most essential software that runs on a computer. It manages both hardware and software resources and provides common services for application programs. For CCEA Computer Science, understanding the core concepts of operating systems is fundamental, as it forms the bridge between the bare machine and user applications. In this revision guide, we will explore the key topics: the role and functions of an OS, process and memory management, scheduling, interrupts, file systems, device handling, user interfaces, and security.
操作系统是计算机上运行的最基本软件。它管理硬件和软件资源,并为应用程序提供公共服务。对于 CCEA 计算机科学考试,理解操作系统的核心概念至关重要,因为它是裸机与用户应用之间的桥梁。在本复习指南中,我们将探讨关键主题:操作系统的角色和功能、进程和内存管理、调度、中断、文件系统、设备处理、用户界面和安全。
1. Role of an Operating System | 操作系统的角色
The primary role of an OS is to act as an intermediary between the user and the computer hardware. It provides an environment in which a user can execute programs conveniently and efficiently. The OS hides the complexity of hardware operations behind a set of system calls, making software development easier and more portable across different machines.
操作系统的主要角色是充当用户与计算机硬件之间的中介。它提供一个用户能够方便、高效地执行程序的环境。操作系统通过一组系统调用隐藏硬件操作的复杂性,使软件开发更容易,并在不同机器间更具可移植性。
Another key role is resource management. The OS allocates and deallocates resources such as CPU time, memory space, and I/O devices among competing processes. This ensures fair and efficient use of the system, preventing conflicts and deadlocks.
另一个关键角色是资源管理。操作系统在竞争进程之间分配和回收 CPU 时间、内存空间和 I/O 设备等资源。这确保系统公平高效地使用,防止冲突和死锁。
2. Functions of an Operating System | 操作系统的功能
The OS performs several core functions: process management, memory management, file management, device management, and providing a user interface. It also handles security, accounting, and error detection. Each function involves a set of system services accessible through system calls or APIs.
操作系统执行几项核心功能:进程管理、内存管理、文件管理、设备管理以及提供用户界面。它还处理安全、记账和错误检测。每一项功能都包含一组可通过系统调用或 API 访问的系统服务。
Process management includes creating, scheduling, and terminating processes. Memory management keeps track of each byte in main memory, allocating and freeing space as needed. File management organises data into files and directories, providing naming conventions and access controls. Device management uses drivers to communicate with I/O hardware, often employing buffering, caching, and spooling to improve performance.
进程管理包括创建、调度和终止进程。内存管理跟踪主存中的每个字节,根据需要分配和释放空间。文件管理将数据组织成文件和目录,提供命名约定和访问控制。设备管理使用驱动程序与 I/O 硬件通信,通常利用缓冲、缓存和假脱机来提高性能。
3. Types of Operating Systems | 操作系统类型
Common types of operating systems in the CCEA syllabus include batch, real-time, multi-tasking (multi-programming), multi-user, distributed, and embedded systems. Each type is designed for specific workloads: batch systems process jobs without user interaction; real-time systems provide deterministic response times; multi-tasking systems allow several programs to run concurrently; multi-user systems support multiple users simultaneously; distributed systems manage a group of independent computers as a single coherent system; embedded systems are tailored for devices like routers or car engine controllers.
CCEA 教学大纲中常见的操作系统类型包括批处理、实时、多任务(多道程序)、多用户、分布式和嵌入式系统。每种类型都针对特定工作负载设计:批处理系统无需用户交互即可处理作业;实时系统提供确定性的响应时间;多任务系统允许多个程序并发运行;多用户系统同时支持多个用户;分布式系统将一组独立计算机作为单一协调系统管理;嵌入式系统专为路由器或汽车引擎控制器等设备定制。
Modern general-purpose OSs like Windows, Linux, and macOS are multi-tasking and multi-user, often incorporating elements of real-time and distributed capabilities. In the exam, you may be asked to compare these types based on resource utilisation, responsiveness, and complexity.
像 Windows、Linux 和 macOS 这样的现代通用操作系统是多任务和多用户的,通常结合了实时和分布式能力。在考试中,你可能会被要求根据资源利用率、响应速度和复杂性来比较这些类型。
4. Process Management and States | 进程管理与状态
A process is a program in execution. Process management is the heartbeat of the OS. Each process can be in one of several states: new, ready, running, waiting (blocked), or terminated. The transition diagram is crucial for understanding scheduling: a new process is admitted to the ready queue; the CPU scheduler dispatches it to running; if the process must wait for I/O or an event, it moves to the waiting state; once the event occurs, it goes back to ready; finally, it terminates.
进程是正在执行的程序。进程管理是操作系统的心跳。每个进程可以处于以下几种状态之一:新创建、就绪、运行、等待(阻塞)或终止。状态转换图对于理解调度至关重要:新进程被接纳到就绪队列;CPU 调度程序将其分派为运行;如果进程必须等待 I/O 或事件,它会移到等待状态;一旦事件发生,它回到就绪;最后终止。
The process control block (PCB) stores vital information about each process, including its state, program counter, CPU registers, memory allocation, and I/O status. Context switching saves the PCB of one process and loads another’s, enabling multi-tasking. However, context switching overhead wastes CPU time, so efficient scheduling is essential.
进程控制块(PCB)存储每个进程的重要信息,包括其状态、程序计数器、CPU 寄存器、内存分配和 I/O 状态。上下文切换保存一个进程的 PCB 并加载另一个进程的 PCB,从而实现多任务处理。然而,上下文切换的开销会浪费 CPU 时间,因此高效的调度至关重要。
5. CPU Scheduling Algorithms | CPU 调度算法
CPU scheduling decides which ready process to run next. CCEA candidates must know the following algorithms: First-Come First-Served (FCFS), Shortest Job First (SJF), Priority Scheduling, and Round Robin (RR). Each has its strengths and weaknesses measured by criteria like CPU utilisation, throughput, turnaround time, waiting time, and response time.
CPU 调度决定下一个运行哪个就绪进程。CCEA 考生必须了解以下算法:先来先服务(FCFS)、最短作业优先(SJF)、优先级调度和轮转调度(RR)。每种算法都有其优缺点,通过 CPU 利用率、吞吐量、周转时间、等待时间和响应时间等指标来衡量。
FCFS is simple but can cause the convoy effect where short processes wait behind a long CPU burst. SJF minimises average waiting time but requires knowing burst lengths in advance, which is unrealistic. Priority scheduling can starve low-priority processes; aging can solve this. Round Robin assigns a fixed time quantum; if chosen well, it gives good response time and fair sharing, but too small a quantum increases context switching overhead. Calculation of average waiting and turnaround times is a common exam task.
FCFS 很简单,但可能导致护航效应,即短进程在一个长 CPU 脉冲后面等待。SJF 最小化平均等待时间,但需要提前知道脉冲长度,这不现实。优先级调度可能使低优先级进程饥饿;老化可以解决此问题。轮转调度分配固定的时间片;如果选择得当,它提供良好的响应时间和公平分享,但时间片太小会增加上下文切换开销。计算平均等待时间和周转时间是常见的考试任务。
6. Interrupts and Context Switching | 中断与上下文切换
Interrupts are signals to the processor that an event needs immediate attention. Hardware interrupts come from devices like the keyboard or disk; software interrupts (or traps) are caused by program errors or system calls. When an interrupt occurs, the CPU stops its current thread, saves its state, and executes the corresponding interrupt service routine (ISR) from the interrupt vector table. Once handled, it restores the saved state and resumes the interrupted process.
中断是发送给处理器的信号,表示某个事件需要立即关注。硬件中断来自键盘或磁盘等设备;软件中断(或陷阱)由程序错误或系统调用引起。当中断发生时,CPU 停止当前线程,保存其状态,并从中断向量表执行相应的中断服务程序(ISR)。处理完毕后,它恢复保存的状态并继续被中断的进程。
Context switching is similar: it occurs when the CPU changes from executing one process to another, usually after a timer interrupt in preemptive scheduling. The OS stores the PCB of the current process and loads the PCB of the next. Context switching is pure overhead; the system must minimise its frequency while still providing good interactivity.
上下文切换类似:当 CPU 从一个进程切换到另一个进程时发生,通常在抢占式调度中的定时器中断后。操作系统存储当前进程的 PCB,并加载下一个进程的 PCB。上下文切换纯属开销;系统必须最小化其频率,同时仍提供良好的交互性。
7. Memory Management: Paging and Segmentation | 内存管理:分页与分段
Memory management allocates main memory among processes. Two fundamental techniques are paging and segmentation, both supported by hardware through the memory management unit (MMU). Paging divides physical memory into fixed-size blocks called frames and logical memory into pages of the same size. The page table maps each virtual page to a physical frame, allowing non-contiguous allocation and eliminating external fragmentation.
内存管理在进程之间分配主存。两种基本技术是分页和分段,两者都由内存管理单元(MMU)通过硬件支持。分页将物理内存分成固定大小的块,称为帧,将逻辑内存分成相同大小的页。页表将每个虚拟页映射到一个物理帧,允许非连续分配并消除外部碎片。
Segmentation, on the other hand, divides memory into variable-sized segments corresponding to logical units like functions, arrays, or stacks. Each segment has a base and a limit. Segmentation avoids internal fragmentation but can suffer from external fragmentation. Modern OSs often combine both: paged segmentation (e.g., Intel x86). For CCEA, you must be able to translate logical addresses to physical addresses using page tables or segment tables, and describe fragmentation types.
另一方面,分段将内存分成大小可变的段,对应逻辑单元,如函数、数组或堆栈。每个段有一个基址和界限。分段避免了内部碎片,但可能遭受外部碎片。现代操作系统通常结合两者:页式分段(例如 Intel x86)。对于 CCEA,你必须能够使用页表或段表将逻辑地址转换为物理地址,并描述碎片类型。
8. Virtual Memory | 虚拟内存
Virtual memory is a technique that allows execution of processes that may not be completely in main memory. It provides the illusion of a very large, continuous address space. When a required page is not in memory (a page fault), the OS fetches it from secondary storage, perhaps replacing an existing page. This is called demand paging. A crucial aspect is the page replacement algorithm, such as FIFO, Optimal, or LRU (Least Recently Used).
虚拟内存是一种允许执行可能不完全在主存中的进程的技术。它提供一种非常大的、连续的地址空间错觉。当某个需要的页不在内存中(缺页错误),操作系统从辅助存储获取它,并可能替换现有页。这称为请求调页。一个关键方面是页面置换算法,如 FIFO、最优算法或 LRU(最近最少使用)。
The exam often asks to simulate page replacement for a given reference string and calculate the number of page faults. LRU approximates the optimal policy by tracking when pages were last used. Another important concept is thrashing: when a system spends more time paging than executing, caused by excessive multi-programming or insufficient memory.
考试常要求对给定引用串模拟页面置换,并计算缺页错误数。LRU 通过跟踪页面上次使用时间来近似最优策略。另一个重要概念是颠簸:当系统花费在调页上的时间多于执行时间,由过度的多道程序或内存不足引起。
9. File Management | 文件管理
The file system provides a logical view of data stored on secondary storage. It organises data into files – a collection of related information – and directories (folders) for hierarchical organisation. File attributes include name, type, size, location, and access permissions. The OS supports operations like create, delete, open, close, read, write, and seek.
文件系统提供存储在辅助存储上数据的逻辑视图。它将数据组织成文件——相关信息的集合——以及用于层次化组织的目录(文件夹)。文件属性包括名称、类型、大小、位置和访问权限。操作系统支持创建、删除、打开、关闭、读、写和定位等操作。
Directory structures can be single-level, two-level, tree-structured, or acyclic graph. Tree-structured directories are most common. File allocation methods include contiguous, linked, and indexed allocation. Contiguous allocation suffers from external fragmentation; linked allocation (FAT) avoids fragmentation but is inefficient for direct access; indexed allocation (e.g., UNIX i-nodes) supports direct access by keeping a block of pointers to the file’s data blocks.
目录结构可以是单级、两级、树形或有向无环图。树形目录最为常见。文件分配方法包括连续分配、链接分配和索引分配。连续分配受外部碎片困扰;链接分配(FAT)避免了碎片,但直接访问效率低下;索引分配(如 UNIX i 节点)通过维护一个指向文件数据块的指针块来支持直接访问。
10. Device Management and Drivers | 设备管理与驱动程序
Device management is responsible for controlling I/O devices, which vary widely in speed and function. The OS uses device drivers – software modules that communicate with the device controller. Drivers provide a uniform interface to the rest of the OS, hiding hardware specifics. Techniques like buffering (storing data temporarily in memory while transferring) and caching (keeping frequently used data in fast storage) improve performance.
设备管理负责控制各种速度和功能差异很大的 I/O 设备。操作系统使用设备驱动程序——与设备控制器通信的软件模块。驱动程序为操作系统其他部分提供统一接口,隐藏硬件细节。诸如缓冲(在传输时将数据临时存储在内存中)和缓存(将常用数据保存在快速存储中)等技术可提高性能。
Spooling (Simultaneous Peripheral Operations OnLine) is particularly important for slow devices like printers. It allows multiple jobs to be queued on disk, enabling the CPU to continue processing while a device works at its own pace. The exam may ask you to explain how spooling resolves the problem of mismatched speeds between CPU and peripheral.
假脱机(SPOOLing,同时联机外围操作)对打印机等慢速设备尤为重要。它允许多个作业排队在磁盘上,使 CPU 可以继续处理,而设备以自己的速度工作。考试可能会要求你解释假脱机如何解决 CPU 与外设速度不匹配的问题。
11. User Interfaces | 用户界面
The user interface (UI) is the part of the OS that enables interaction with the user. Two main types are Command-Line Interface (CLI) and Graphical User Interface (GUI). A CLI accepts text commands typed by the user; it is powerful, scriptable, and consumes few resources, but requires memorisation of commands. GUIs provide visual elements like windows, icons, menus, and a pointer (WIMP); they are intuitive and user-friendly but demand more CPU and memory.
用户界面是操作系统使用户能够与之交互的部分。两种主要类型是命令行界面(CLI)和图形用户界面(GUI)。CLI 接受用户键入的文本命令;它功能强大、可编写脚本且消耗资源少,但需要记忆命令。GUI 提供窗口、图标、菜单和指针(WIMP)等视觉元素;它直观且用户友好,但需要更多的 CPU 和内存。
Modern OSs often include a shell that can be either text-based or graphical. In CCEA, be able to compare CLI and GUI in terms of ease of use, resource consumption, flexibility, and typical use cases (e.g., servers vs. desktops).
现代操作系统通常包含一个基于文本或图形的外壳。在 CCEA 中,要能够从易用性、资源消耗、灵活性和典型用例(如服务器与桌面)方面比较 CLI 和 GUI。
12. Security and Protection Mechanisms | 安全与保护机制
Protection refers to mechanisms that control access of programs, processes, or users to system resources. Security defends the system against internal and external threats. The OS implements authentication (e.g., username/password), access control lists (ACLs), and privilege levels. A common model is the access matrix, where rows represent subjects (users/processes) and columns represent objects (files, devices), with entries specifying access rights.
保护是指控制程序、进程或用户对系统资源的访问的机制。安全防御系统免受内部和外部威胁。操作系统实施身份验证(如用户名/密码)、访问控制列表(ACL)和特权级别。一个常见模型是访问矩阵,其中行代表主体(用户/进程),列代表客体(文件、设备),条目指定访问权限。
Modern OSs separate kernel mode and user mode to prevent user programs from executing privileged instructions directly. System calls act as the controlled gateway. Encryption, firewalls, and virus scanners are additional security measures often built into or integrated with the OS. For CCEA, you should describe examples of threats (viruses, worms, trojans, denial-of-service) and how OS features mitigate them.
现代操作系统将内核态和用户态分开,以防止用户程序直接执行特权指令。系统调用充当受控的网关。加密、防火墙和防病毒扫描程序通常是内置于或集成于操作系统的附加安全措施。对于 CCEA,你应该描述威胁示例(病毒、蠕虫、木马、拒绝服务攻击)以及操作系统功能如何缓解它们。
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课程辅导,国外大学本科硕士研究生博士课程论文辅导