
在Linux 2.6,每個CPU有屬於自己的一個runqueue,而runqueue又分成兩個結構,active跟expired。這2個queue是根據每個process的priority來由高到低依序排列(範圍:0~139)。
active代表process的quantum尚未使用完畢的。
expire則代表quantum已經使用完畢的process。

現在有1、2、3三個Task在active這個結構等待被執行。
Priority: Task1>Task2=Task3
Time quantum:Task1>Task2=Task3
(Time quantum ≒ 1/Priority)

由Task1開始執行(因為Priority最高),當Task1將自己的Time quantum使用完畢後,就移動到expired。

Task2和Task3的priority是相同的,所以用linked list將兩個串聯起來,而兩者的執行是採用round-robin演算法。

每個Task有一個時間片段(time slice),因為Task2無法在time slice內執行完畢,就要移動到該linked list的最後面去排隊重新等待執行。

Task2在經由round-robin演算法,排隊了幾次之後結束了他的執行Time quantum,也會移動到expired去。

因為有動態優先權(dynamic priority)。動態優先權會以「上一個cycle中,該Task的averge sleep time值的大小」為依據給予該Task一個bouns值。所以Task3移動到expired時,priority比Task2高。

3個Task都到了expired

當active結構裡已經沒有Task在等待被執行,而expired有Task,兩者的指標就會做交換的動作