How can you determine which process scheduler is being used?

10,572

You can call sched_getscheduler(process_pid) to determine the scheduling policy for a process.

If /sys/kernel/uids exists, you have CFS. Or you could try

[[ -n $(awk '$3 == "load_balance_fair" {print;}' < /proc/kallsyms) ]] && 
  echo CFS

I'm not sure how you could distinguish the O(1) scheduler from other obsolete schedulers. You could use the kernel version I suppose, but since distributions applied patches to their shipped kernels, this will be unreliable.

Share:
10,572

Related videos on Youtube

daveb
Author by

daveb

Updated on September 18, 2022

Comments

  • daveb
    daveb over 1 year

    I.e. is it the O(1) scheduler, the CFS scheduler, or an older one?

    • Karlson
      Karlson about 12 years
      Which OS are you asking about?
    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' about 12 years
      I assume you're talking about Linux? I don't think there's any other unix variant with these scheduler names.
    • daveb
      daveb about 12 years
      It's a linux variant: RHEL
  • Mikel
    Mikel about 12 years
    That's what I thought at first, but it looks like the return value from sched_getscheduler doesn't tell you which process scheduler is being used, just what scheduling policy is being used for the current process (essentially: normal/batch/realtime/low priority).
  • Batfan
    Batfan about 12 years
    Yes. That's why the second and following sentences of my answer are there!
  • Jaime
    Jaime over 6 years
    The sched_setscheduler allows a program to define parameters for the scheduler. It is not selecting which scheduler O(1) or CFS the linux is using. Nowadays, since kernel 2.6.23, the official kernel uses the CFS scheduler -- You may check man7.org/linux/man-pages/man2/sched_setscheduler.2.html