Kernel scheduler
Tweak and tune your own kernel scheduler
Mats Tage Axelsson explains how Linux keeps all its plates up in the air and when it can be helpful to intervene and stop it all crashing down.
SCHEDTOOL
Credit: https://github.com/freequaos/schedtool
OUR EXPERT
Mats Tage Axelsson can be counted on to find new ways to simplify your Linux usage in complex ways. Anything to seem as cool as he thinks he is.
QUICK TIP
The first time you compile your own kernel, prepare the disk for handling up to 12GB of new data. Also reserve a good chunk of time and your favourite brew. A compile runs on its own but choosing the tweaks you want is a chore.
Your computer does not do everything at once [I know how it feels – Ed]. It slices things into Y chunks. How those chunks come into being and how they affect your system is the subject of the scheduler we’re going to discuss now!
While using your computer, you take it for granted that other things are happening while you type away or play a game. The complexity of scheduling the tasks inside your computer is staggering, but you can grasp the gist of it without a degree in computing. You can also make better use of it, albeit on rare occasions.
The occasions are when you have special projects that have either high-load or strict responsiveness demands. Creating music is an area where even regular users need stringent response times. When compiling software or doing other high-load tasks, you need keep running your machine even during this CPU stress.
For most use normal cases, the default scheduler can handle the situation and make sure your UI feels responsive without sacrificing other running tasks. Most of the optimisation comes from clever decisions made by the software designers, who know how typical users use their software. On occasion, you may not be a typical user and so might need to tweak how the scheduling works for you.
Schedulers through history!
Before getting deeper into the Linux scheduler, remember that many systems existed before Linus Torvalds went to university. The first Linux version was so simple it did not even multitask.
As the need of systems to run more processes grew, so did the need for a scheduler. With small systems with few processes, a simple round-robin queue worked well. But ever-growing systems, both in memory and number of processes, required more control. The first modes included time-sharing and time slices, which allow a process to run for the specified time and then the system preempts it. In the ’80s, with BSD, the scheduler added the ‘nice’ concept. Now users and programmers could influence the scheduling priorities.
In the ’90s, Solaris added a class-based scheduler aimed at prioritising according to the needs of the process. As an example, I/O-bound processes need less CPU than others. Needs of a single process may vary over time, though, adding more complexity. The 4BSD system introduced dynamic priority adjustments based on I/O activity and other behaviours. FreeBSD added a deadline scheduler to satisfy the needs of real-time tasks.