12

Would like to know what scheduling mechanisms is employed in 15.04, time-sharing or real-time, I'm pretty sure its FIFO, Round Robin, SJF?

P.S: New to Linux

1 Answers1

13

Process scheduler

A process scheduler handles CPU resource allocation for executing processes, and aims to maximize overall CPU utilization while also maximizing interactive performance.

Since kernel 2.6.23 (that would be as of Hardy 8.04 LTS) Completely Fair Scheduler (CFS) based on "Rotating Staircase Deadline". Overview from kernel.org:

CFS stands for "Completely Fair Scheduler," and is the new "desktop" process scheduler implemented by Ingo Molnar and merged in Linux 2.6.23. It is the replacement for the previous vanilla scheduler's SCHED_OTHER interactivity code.

80% of CFS's design can be summed up in a single sentence: CFS basically models an "ideal, precise multi-tasking CPU" on real hardware.

"Ideal multi-tasking CPU" is a (non-existent :-)) CPU that has 100% physical power and which can run each task at precise equal speed, in parallel, each at 1/nr_running speed. For example: if there are 2 tasks running, then it runs each at 50% physical power --- i.e., actually in parallel.

On real hardware, we can run only a single task at once, so we have to introduce the concept of "virtual runtime." The virtual runtime of a task specifies when its next timeslice would start execution on the ideal multi-tasking CPU described above. In practice, the virtual runtime of a task is its actual runtime normalized to the total number of running tasks.


  • Kernel 2.4: O(n) scheduler; there is no Ubuntu release with that kernel.
  • Kernel 2.6.0 to 2.6.22: O(1) scheduler. Warty 4.10 (1st release) used 2.6.8. Gutsy 7.10 was the last one that used 2.6.22 or lower.

I/O scheduler

Input/output scheduling is the method that operating system uses to decide in which order block I/O operations will be submitted to storage volumes.

Phoronix article on scheduling: Linux 3.16: Deadline I/O Scheduler Generally Leads With A SSD.


You can change the I/O scheduler by appending the option "elevator=" to "GRUB_CMDLINE_LINUX_DEFAULT=" in grub.

It is probably easier (assuming sda and deadline) to do it like this though:

  • To show the list of available schedulers:

    cat /sys/block/sda/queue/scheduler
    
  • And to alter a scheduler (can be done on the fly):

    echo deadline > /sys/block/sda/queue/scheduler
    

From kernel/git/torvalds/linux.git


You can check what is being used with (assuming sda as primairy):

cat /sys/block/sda/queue/scheduler
Sergey
  • 43,665
Rinzwind
  • 299,756
  • Does this mean the scheduling mechanism used in Ubuntu 15.04 by default is time-sharing algorithm, CFS? Or it comes with OTHER, RR and FIFO?

    I got my information here: http://manpages.ubuntu.com/manpages/hardy/man2/sched_setscheduler.2.html

    – leslie_lyj Jun 08 '15 at 11:28
  • You are looking at the manpages for Hardy. That is a bit old ;) 'cfq' is the default. See the added link to kernel/git/torvalds/linux.git. – Rinzwind Jun 08 '15 at 11:31
  • 1
    ...isn't this confusing between disk and cpu scheduler? They are quite different beasts. CPU scheduler decides which process is run next, and the disk scheduler decides how blocks of data in disks are accessed. See for example https://wiki.archlinux.org/index.php/Maximizing_performance – Rmano Jun 08 '15 at 11:42
  • Well, not really, main point of this question was to clarify what process scheduling mechanism is Ubuntu 15.04 running on. (Sorry if I wasn't being clear) – leslie_lyj Jun 08 '15 at 12:29
  • 2
    @Rmano I assumed this was for information not specifically for actually using it. But the neurotic in me went all out >:-D Anyone wanting to play with this should be expected to be an expert :X – Rinzwind Jun 08 '15 at 12:32
  • I've added sub-headers, otherwise it was difficult to tell where is stop talking about process scheduling and starts discussing I/O scheduling – Sergey Jun 09 '15 at 22:16