Linux 現代調度器 (CFS, Completely Fair Scheduler) **不使用固定時間片**,而是基於虛擬運行時間 vruntime 實現「完全公平」。
vruntime,單位納秒,表示「已佔用 CPU 的虛擬時間」。vruntime 排序,最左節點 (最小 vruntime) 下一個獲得 CPU。timeslice = sched_latency * (weight / total_weight),權重由 nice 值決定。schedule())。vruntime 保留,下次入隊繼續累加。vruntime 超過下一個進程太多 (觸發 resched_task)。need_resched 標誌。kernel/sched/fair.c、kernel/sched/core.c「剩下的時間片是繼續運行下一個進程還是計時器清零」—— 兩者都不是,CFS 沒有固定時間片,只有動態 vruntime 排隊。