First exams 2027 · SL & HL 2027 年首次开考 · SL 与 HL

A1.3 · Computer fundamentals

A1.3 · 计算机基础

Approaches to Scheduling

调度方式的比较

Hundreds of processes are ready to run and one core can run one at a time. The order the OS picks them in changes how quickly work finishes, how responsive the machine feels, and whether some processes wait forever.

上百个进程就绪待运行,而一个核心一次只能运行一个。操作系统选择它们的顺序,决定了工作完成得多快、机器用起来多灵敏,以及某些进程是否会永远等下去。

Core for SL & HL SL 与 HL 核心内容 Typically 4–6 marks · AO3 通常 4–6 分 · AO3 Command term: compare 命令词:compare(比较)

Explainer

讲解

What scheduling has to solve

调度要解决什么

Df

Scheduling is the OS function that decides which of the ready processes runs on the CPU next, and for how long, so that CPU time is shared in a way that keeps the whole system performing well.

调度是操作系统的一项功能:它决定下一个由哪个就绪进程使用 CPU、用多久,从而以让整个系统保持良好表现的方式来分享 CPU 时间。

At any moment there may be hundreds of processes ready to run, some urgent, some long, some tiny. The scheduler is judged on a few measures: throughput (jobs finished per second), waiting time, turnaround time, responsiveness for interactive work, and fairness, avoiding starvation where a process never gets the CPU.

任何时刻都可能有上百个进程就绪待运行,有的紧急、有的很长、有的很小。评判调度器的指标有几个:吞吐量(每秒完成的任务数)、等待时间、周转时间、交互工作的响应性,以及公平性,即避免某个进程永远拿不到 CPU 的饥饿现象。

Every switch from one process to another is a context switch: the OS saves the first process’s registers and state and loads the next one’s. This is pure overhead, so an approach that switches very often pays a price.

从一个进程切换到另一个进程,每一次都是一次上下文切换:操作系统保存第一个进程的寄存器和状态,再载入下一个进程的。这纯粹是开销,所以切换非常频繁的方式要付出代价。

Explainer

讲解

The four approaches side by side

四种方式并排比较

ApproachHow it picksPre-emptive?Main weakness
First-come first-served (FCFS)Runs processes in arrival order, each to completionNoThe convoy effect: one long job delays every shorter job behind it
Round robinGives each process a fixed time slice (quantum) in turn, then moves it to the back of the queueYesA quantum that is too small wastes time on context switches
Priority schedulingRuns the ready process with the highest priority firstCan be eitherLow-priority processes can starve
Multilevel queueSplits the ready queue into several queues by process type, each with its own algorithm and priorityYesComplex to tune; lower queues can still starve
方式如何选择是否抢占主要弱点
先来先服务(FCFS)按到达顺序运行进程,每个都运行到结束否护航效应:一个长任务会拖延排在它后面的每个较短任务
轮转(round robin)轮流给每个进程一个固定的时间片(时间量),然后把它移到队尾是时间片太小会把时间浪费在上下文切换上
优先级调度先运行优先级最高的就绪进程两者皆可低优先级进程可能饥饿
多级队列按进程类型把就绪队列分成几个队列,每个队列有自己的算法和优先级是调优复杂;较低的队列仍可能饥饿

Explore

探索

How each approach behaves

每种方式的表现

Click each approach to see its mechanism, what it is good at, where it falls down, and the kind of system it suits.

点击每种方式,看看它的机制、擅长什么、在哪里失灵,以及它适合哪类系统。

Check your understanding

检验你的理解

A round robin scheduler is set with a very short time quantum. What is the most likely effect?

一个轮转调度器被设成了很短的时间片。最可能的后果是什么?

Common mistake

常见错误

A recurring weakness on “compare” scheduling answers “比较”调度这类答案中反复出现的弱点

RecurringTwo problems recur. First, answers describe each algorithm in a separate paragraph and never compare them: compare means put them against shared criteria (fairness, responsiveness, overhead, starvation) and say how they differ, ideally with a judgement about which suits a given system. Second, round robin and FCFS get confused: FCFS runs each job to completion in arrival order (non-pre-emptive); round robin interrupts each job after a fixed slice and cycles round (pre-emptive).

反复出现有两个问题反复出现。第一,答案用一段分别描述每个算法,却从不加以比较:比较意味着把它们放在共同的标准下(公平性、响应性、开销、饥饿),说明它们有何不同,最好还给出哪种适合某个系统的判断。第二,轮转和 FCFS 被搞混了:FCFS 按到达顺序把每个任务运行到结束(非抢占);轮转在固定的一片时间后打断每个任务并循环轮流(抢占)。

✕

Two descriptions, no comparison: “FCFS runs jobs in the order they arrive. Round robin gives each job a time slice. Priority scheduling runs the most important job first.” Three facts, but nothing set against anything.

两段描述,没有比较: “FCFS 按到达顺序运行任务。轮转给每个任务一片时间。优先级调度先运行最重要的任务。”三个事实,却没有任何对比。

✓

A real comparison: “FCFS and round robin both treat jobs equally, but FCFS is non-pre-emptive so a long job blocks short ones behind it (the convoy effect), while round robin pre-empts after a fixed slice so short interactive jobs stay responsive, at the cost of context-switch overhead. Priority scheduling beats both for urgent work but, unlike round robin, can starve low-priority jobs unless ageing is used.”

一次真正的比较: “FCFS 和轮转都平等对待任务,但 FCFS 非抢占,所以一个长任务会挡住排在它后面的短任务(护航效应),而轮转在固定一片时间后抢占,使短小的交互任务保持响应,代价是上下文切换的开销。优先级调度在处理紧急工作上胜过两者,但与轮转不同,除非采用老化机制,否则可能饿死低优先级任务。”

Revision questions

复习题

Specimen-paper style. Write an answer, then reveal the marking points and mark yourself.

采用样卷风格。写下答案,然后展开评分要点给自己打分。

Question 1 · 6 marks 第 1 题 · 6 分

[6]Compare first-come first-served and round robin scheduling.

[6]比较先来先服务调度与轮转调度。

Question 2 · 4 marks 第 2 题 · 4 分

[4]Compare priority scheduling and multilevel queue scheduling.

[4]比较优先级调度与多级队列调度。

Question 3 · 6 marks 第 3 题 · 6 分

[6]Compare the four scheduling approaches in terms of fairness and the risk of starvation.

[6]就公平性和饥饿风险,比较这四种调度方式。

Question 4 · 4 marks 第 4 题 · 4 分

[4]Explain how the choice of time quantum affects the behaviour of round robin scheduling.

[4]解释时间片的选择如何影响轮转调度的表现。

Question 5 · 3 marks 第 5 题 · 3 分

[3]Explain how context switching creates overhead in a scheduler that switches processes frequently.

[3]解释在频繁切换进程的调度器中,上下文切换如何造成开销。

Flashcards

记忆卡片

Active recall for this statement’s key terms.

针对本条考纲陈述关键术语的主动回忆练习。

Prototype render · grounded in the IB CS 2027 subject guide and the Hodder and Oxford IB CS 2027 texts for A1.3.3 · not yet wired to live routes