抢占式优先级 CPU 调度算法

Preemptive Priority CPU scheduling Algorithm

考虑一个执行三个任务 T1、T2 和 T3 的单处理器系统,每个任务都由无限序列的作业(或实例)组成,这些作业(或实例)分别以 3、7 和 20 毫秒的间隔周期性到达。每个任务的优先级是其周期的倒数,可用任务按优先级顺序安排,优先级最高的任务最先安排。 T1、T2 和 T3 的每个实例分别需要 1、2 和 4 毫秒的执行时间。鉴于所有任务最初都在第 1 毫秒开始到达并且允许任务抢占,因此 T3 的第一个实例在 ______________ 毫秒结束时完成其执行。

============================================= ===========================

My Take - 我认为第 1 毫秒的开始意味着所有进程都在时间 = 1 到达,0 到 1 时间是空闲的。当我使用甘特图时,我得到的答案是 13,而答案 = 12

如您的问题所述,"the priority of each task is the inverse of its period and the available tasks are scheduled in order of priority, with the highest priority task scheduled first"。因此,T1 的优先级高于 T2,而 T2 的优先级高于 T3。这意味着无论何时 T1 到达,它都会抢占其他任务,而 T2 会抢占任务 T3。

在任务 T1、T2 和 T3 中,它们中的每一个都由无限序列的作业(或实例)组成,这些作业(或实例)分别以 3、7 和 20 毫秒的间隔周期性到达。并且,T1、T2 和 T3 的每个实例分别需要 1、2 和 4 毫秒的执行时间。

因此,相应的甘特图将是:

T1 (0-1), T2 (1-2), T2 (2-3), T1 (3-4), T3 (4-5), T3 (5-6), T1 (6-7), T2 (7-8), T2 (8-9), 
                                                            T1 (9-10), T3 (10-11), T3 (11-12)...
// so first instance of T3 finishes at the end of 12 seconds.

I took that beginning of 1st ms means all the process arrives at time = 1 and 0 to 1 time is IDLE. and when I take the gantt chart I get answer as 13, whereas answer = 12.

你的答案不匹配是因为你的假设不正确

题目明确说了"given that all tasks initially arrive at the beginning of the 1st milliseconds...",意思是定时器一开始任务就到了,即第一个毫秒一开始(我在图表中的提示中标记为0-1)上图)。