1
$ sudo time -f '%c %w' chrt -f 99 ./ft 1234567890
26 1

I am curious why my process has been involuntarily (because the time slice expired) context-switched 26 times even though I set the scheduler to FIFO with the max priority 99:

$ chrt -m
SCHED_OTHER min/max priority    : 0/0
SCHED_FIFO min/max priority         : 1/99
SCHED_RR min/max priority           : 1/99
SCHED_BATCH min/max priority    : 0/0
SCHED_IDLE min/max priority         : 0/0

$ uname -a
Linux localhost.localdomain 2.6.32-358.2.1.el6.x86_64 #1 SMP Wed Mar 13 00:26:49 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Any idea?

Thanks in advance.

Hei
  • 1,844
  • 3
  • 21
  • 35

1 Answers1

2

Even if there is no other process able to run the scheduler will still run once every time slice. It will be returning straight back to your process, but none the less your process has been descheduled for a short period of time.

FTRACE is very good, take a look at this page, especially section 3.3.1. The page is talking about on OMAP ARM devices, but it all works just fine on other linuxes. That viewer reveals a huge amount of information about the inner workings of your system!

bazza
  • 7,580
  • 15
  • 22
  • 1
    Though the new [timerless multitasking](http://kernelnewbies.org/LinuxChanges#head-952efcf3f3e5ce7120213222805c1847429ae3fc) in the 3.10 kernel might help with that effect. – Joe Jul 03 '13 at 07:43
  • @bazza, it seems like context switching 26 times over few minutes is a little bit too less then if the OS will swap out my process based on time slice. – Hei Jul 04 '13 at 02:42
  • @Hei, yes you're right, 26 times in a few minutes doesn't sound like the OS time slices. I recommend you give FTRACE a try, it is very revealing. Section 3.3.1 is of the link I gave above is well worth trying out, you get a nice graphical view of exactly what is running in your system and when. – bazza Jul 04 '13 at 21:41