- 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.
- 零基礎學Visual C++第3版
- Python編程自學手冊
- Machine Learning with R Cookbook(Second Edition)
- Cassandra Design Patterns(Second Edition)
- 前端架構:從入門到微前端
- Hands-On JavaScript High Performance
- 用Python實現深度學習框架
- 深入淺出Serverless:技術原理與應用實踐
- Mobile Device Exploitation Cookbook
- 深入實踐Kotlin元編程
- 動手打造深度學習框架
- Mockito Essentials
- OpenCV Android Programming By Example
- 邊玩邊學Scratch3.0少兒趣味編程
- ROS機器人編程實戰