- Mastering C++ Multithreading
- Maya Posch
- 365字
- 2021-07-15 17:34:00
Schedulers
A number of task-scheduling algorithms exist, each focusing on a different goal. Some may seek to maximize throughput, others minimize latency, while others may seek to maximize response time. Which scheduler is the optimal choice solely depends on the application the system is being used for.
For desktop systems, the scheduler is generally kept as general-purpose as possible, usually prioritizing foreground applications over background applications in order to give the user the best possible desktop experience.
For embedded systems, especially in real-time, industrial applications would instead seek to guarantee timing. This allows processes to be executed at exactly the right time, which is crucial in, for example, driving machinery, robotics, or chemical processes where a delay of even a few milliseconds could be costly or even fatal.
The scheduler type is also dependent on the multitasking state of the OS--a cooperative multitasking system would not be able to provide many guarantees about when it can switch out a running process for another one, as this depends on when the active process yields.
With a preemptive scheduler, processes are switched without them being aware of it, allowing the scheduler more control over when processes run at which time points.
Windows NT-based OSes (Windows NT, 2000, XP, and so on) use what is called a multilevel feedback queue, featuring 32 priority levels. This type of priority scheduler allows one to prioritize tasks over other tasks, allowing one to fine-tune the resulting experience.
Linux originally (kernel 2.4) also used a multilevel feedback queue-based priority scheduler like Windows NT with an O(n) scheduler. With version 2.6, this was replaced with an O(1) scheduler, allowing processes to be scheduled within a constant amount of time. Starting with Linux kernel 2.6.23, the default scheduler is the Completely Fair Scheduler (CFS), which ensures that all tasks get a comparable share of CPU time.
The type of scheduling algorithm used for a number of commonly used or well-known OSes is listed in this table:

(Source: https://en.wikipedia.org/wiki/Scheduling_(computing))
The preemptive column indicates whether the scheduler is preemptive or not, with the next column providing further details. As one can see, preemptive schedulers are very common, and used by all modern desktop operating systems.
- 大學計算機基礎(第三版)
- Modular Programming with Python
- 軟件項目管理(第2版)
- Offer來了:Java面試核心知識點精講(原理篇)
- 區塊鏈架構與實現:Cosmos詳解
- Web Application Development with MEAN
- HTML5 APP開發從入門到精通(微課精編版)
- Terraform:多云、混合云環境下實現基礎設施即代碼(第2版)
- 現代C++編程實戰:132個核心技巧示例(原書第2版)
- C專家編程
- 新印象:解構UI界面設計
- 大規模語言模型開發基礎與實踐
- iOS Development with Xamarin Cookbook
- 計算機系統解密:從理解計算機到編寫高效代碼
- 輕松學Scratch 3.0 少兒編程(全彩)