Search code examples
linuxlinux-kernelschedulingscheduler

How linux scheduler decides a process as realtime, interactive, batch


When we are writing a program we are not specifying the nature of the process like whether it is realtime, interactive... I read that Linux kernel does scheduling based on the nature of the process. Couldn't find an article explaining how Linux decides on that. Would be nice is someone could give some info that. The question is of academic interest only.

I have read that I can use the system call sched_setscheduler to set the scheduler. But what happens when the call is not made?

Also how scheduler decides a process as interactive/batch?


Solution

  • Found an answer from Understanding the Linux 2.6.8.1 CPU Scheduler By Josh Aas, 2005:

    Dynamic priority bonuses and penalties are based on interactivity heuristics. This heuristic is implemented by keeping track of how much time tasks spend sleeping (presumably blocked on I/O) as opposed to running. Tasks that are I/O-bound tend to sleep quite a bit as they block on I/O, whereas CPU-bound task rarely sleep as they rarely block on I/O. Quite often, tasks are in the middle, and are not entirely CPU-bound or I/O-bound so the heuristic produces some sort of scale instead of a simple binary label (I/O-bound or CPU-bound).