20

What scheduling algorithms does Linux kernel use?

Where can I get more info about linux's kernel? (OS first course... student level)

DVK
  • 126,886
  • 32
  • 213
  • 327
Nick
  • 201
  • 1
  • 2
  • 3
  • 1
    Do you mean the "scheduling algorithm the Linux kernel uses"? – Austin Salonen Oct 21 '09 at 20:22
  • mm maybe, my english is not good. I mean, FCFS, round robin or what uses the linux kernel to handle the processes. – Nick Oct 21 '09 at 20:25
  • It's a little old, but try reading [this page](http://web.archive.org/web/20141016155917/http://oreilly.com/catalog/linuxkernel/chapter/ch10.html). (This was previously posted as a separate answer, which received 4 upvotes. Unfortunately, it seems this site's policy towards such useful answers, even ones which have helped people for _7 years_, is that they should be deleted...) – user200783 Dec 02 '16 at 14:32

8 Answers8

7

The linux kernel has several different available scheduling algorithms both for the process scheduling and for I/O scheduling. Download it from www.kernel.org and call

make menuconfig

You will get a full list of all available options with a built-in help. One guy that once came up with his O(1) scheduler is Con Kolivas. Definitively have to have a look at what he did. I was once a great break-through.

jdehaan
  • 19,700
  • 6
  • 57
  • 97
  • 3
    It would be nice if you can please mention the category in menuconfig that the schedulers can be found. – recluze Mar 17 '12 at 04:25
7

Note: As Abdullah Shahin noted, this answer is about IO queing scheduler, not for processes.

If you just want to check what scheduler your linux system is using and which are available you can run the following command:

cat /sys/block/sda/queue/scheduler

The one between the [] is the one it's using at the moment. The other ones are available. To change it:

sudo bash -c 'echo deadline > /sys/block/sda/queue/scheduler'

Be carefull to set it back to default though, unless you know what you are doing and want.

Default (in newer Ubuntu distros at least) is CFQ (Completely Fair Scheduling):

http://en.wikipedia.org/wiki/CFQ

Interview with the creator (Jens Axboe):

http://kerneltrap.org/node/7637

user2220771
  • 419
  • 4
  • 6
  • 1
    for the record, this is a completely misleading answer, should have included in the answer that this is an io queuing scheduler, not for processes, in systems that use SSDs this won't be enabled at all, and it will show [none] in designated files. – Abdullah Shahin Dec 06 '19 at 23:53
2

As others have already mentioned, there are several scheduling algorithms available, according to the intended use.

Check this article if you want to learn more about scheduling in Linux.

Anax
  • 9,122
  • 5
  • 34
  • 68
1

i believe "completely fair scheduler" is in use with latest kernels. I think you can good amount of information if you just search for it in google.

link : http://en.wikipedia.org/wiki/Completely_Fair_Scheduler

Sabeen Malik
  • 10,816
  • 4
  • 33
  • 50
1

A new addition to Linux Kernel is EDF (Earliest Deadline First) for guaranteed RealTime support http://lkml.org/lkml/2009/9/22/186 http://www.evidence.eu.com/content/view/313/390/

subbul
  • 947
  • 1
  • 7
  • 14
0

I think the Linux kernel actually has a few different schedulers you can choose from at compile-time. To find out more about the Linux kernel, you can download the kernel source code (or browse it online) and look in the Documentation directory. For example, the scheduler subdirectory might be helpful. You can also just look at the code itself, obviously.

wdebeaum
  • 4,101
  • 1
  • 22
  • 12
0

Modern GNU/Linux distributions use CFS (Completely Fair Scheduler). You may read more on that in the 4th chapter of this book: Linux Kernel Development 3rd Edition by Robert Love

You will find many interesting and easy to understand explanations there. I enjoyed a lot.

-1

Linux Kernel allows three different scheduling algorithms mainly

  1. shortest job first
  2. Round Robin Scheduling
  3. Priority based preemptive scheduling algorithm.

The third scheduling method which it differs with lower version of Linux versions such as 2.4

jacoz
  • 3,508
  • 5
  • 26
  • 42