Robert Love [earlier interview] released version 0.0.9 of his scheduler utilities package tonight. The schedutil README explains:
"These are the Linux scheduler utilities - schedutils for short. These programs take advantage of the scheduler family of syscalls that Linux implements across various kernels. These system calls implement interfaces for scheduler-related parameters such as CPU affinity and real-time attributes. The standard UNIX utilities do not provide support for these interfaces -- thus this package."
Having learned about these utilities, I decided to give them a try myself. I downloaded the source tarball from Robert's home page (an RPM is also available) and extracted the source. Compilation and installation from source was nothing more than the familiar './configure && make && su -c "make install"'. Very quickly I was reading the man pages and playing with these useful utilities.
A fifth utility was introduced with tonight's 0.0.9 release:
Currently this tool must be manually compilied ('gcc -O2 -o chbatch chbatch.c'). It will become part of the default install once/if SCHED_BATCH is merged into the 2.5 kernel. For more information on SCHED_BATCH find a summary at Kernel Traffic.
Essentially, SCHED_BATCH is for tasks that run infrequenty, but for a long time. SCHED_IDLE is for tasks that only run when nothing else is running, i.e. the system is idle. The new SCHED_BATCH patch incorporates both features into a new policy. I talked with Robert tonight for more details:
"The reason SCHED_IDLE is hard to do (I did it over a year ago but did not fully solve this problem -- see lkml archives) is priority inversion. Consider what happens if a SCHED_IDLE task grabs a critical kernel resource but is then preempted by a normal SCHED_OTHER task. Eventually all the other tasks on the system can block waiting for the SCHED_IDLE task to release the resource ... but it will not release the resource until it runs and it will not run until there are no runnable tasks left. Ouch.
"The fix is a lot of code in a lot of places..."
Robert also further described the schedule utilities:
"It is a standard set of utilities to provide interfaces for all the scheduler stuff we are doing. There is a utility for doing real-time attributes, one for task CPU affinity, one for IRQ CPU affinity, one for the new SCHED_BATCH stuff, and one for listing real-time processes.
"They are all very clean but fairly full featured. The idea is to have a standard set of utilities for doing this stuff. For example, we have a fileutils for doing common file work and programs and scripts know every Linux system has them... but not the same for scheduler-related stuff.
"So the goal is to have a standard set of GNU-style tools that everyone supports... I am getting there: Debian includes schedutils and RedHat is planning on it. Of course MontaVista Linux does too :)"
Download the scheduler utilities from Robert's home page.
At sourceforge also.
There is also a project at sourceforge - http://sourceforge.net/schedutils that lets you change/run a process under another scheduler(SCHED_RR/SCHED_FIFO), works many systems other than linux.