Obviously, in order to achieve this, the OS must expose some APIs; indeed, there are a few system calls that deal with exactly this—changing a given process or thread's scheduling policy and priority.
Here's a list—a sampling, really—of some of the more important of these APIs:
- sched_setscheduler(2): Sets the scheduling policy and parameters of a specified thread.
- sched_getscheduler(2): Returns the scheduling policy of a specified thread.
- sched_setparam(2): Sets the scheduling parameters of a specified thread.
- sched_getparam(2): Fetches the scheduling parameters of a specified thread.
- sched_get_priority_max(2): Returns the maximum priority available in a specified scheduling policy.
- sched_get_priority_min(2) ...