scheduler hints (or, hint-based scheduling) for Linux Robert Love So I went ahead and implemented scheduler hints on top of the O(1) scheduler. I tried to find a decent paper on the web covering scheduler hints (sometimes referred to as hint-based scheduling) but could not find anything worthwhile. Solaris, for example, implements scheduler hints so perhaps the "Solaris Internals" book has some information. Basically, scheduler hints are a way for a program to give a "hint" to the scheduler about its present behavior in the hopes of the scheduler subsequently making better scheduling decisions. After all, who knows better than the application what it is about to do? For example, consider a group of SCHED_RR threads that share a semaphore. Before one of the threads were to acquire the semaphore, it could give a "hint" to the scheduler to increase its remaining timeslice in order to ensure it could complete its work and drop the semaphore before being preempted. Since, if it were preempted, it would just end up being rescheduled as the other real-time threads would eventually block on the held semaphore. Other hints could be "I am interactive" or "I am a batch (i.e. cpu hog) task" or "I am cache hot: try to keep me on this CPU". The scheduler tries hard to figure out the three qualities and it is usually right, although perhaps it can react quicker to these hints than it can figure things out on its own. If nothing else, this serves as a useful tool for determining just how accurate our O(1) scheduler is. I suspect, however, at least the first item I mentioned (boosting timeslice) is useful - Solaris has had some luck sticking the call in the library down semaphore function itself. You use scheduler hints in a program by doing something like, sched_hint(hint) where `hint' is currently one or more of: HINT_TIME - task needs some more quanta, boost remaining timeslice HINT_INTERACTIVE - task is interactive, give it a small priority bonus to help. HINT_BATCH - task is a batch-processed task, give it a small priority penalty to be fair. Any comments or suggestions or patches are welcome. Thanks, Robert Loved