#include <sched.h>
int sched_setparam(pid_t pid, const struct sched_param *param);
int sched_getparam(pid_t pid, struct sched_param *param);
struct sched_param {
int sched_priority; /* process execution
scheduling priority */
...
}
sched_getparam() stores the scheduling parameters of a process, specified by pid, in the sched_param structure pointed to by param.
If the target process has as its scheduling policy, SCHED_FIFO or SCHED_RR:
If pid is zero, the scheduling parameters are set/stored for the calling process. Otherwise, if a process specified by pid exists and if the calling process has permission, the scheduling parameters are set/stored for the process whose process ID is equal to pid. The real or effective user ID of the calling process must match the real or saved (from exec(2) ) user ID of the target process unless the effective user ID of the calling process is 0. See intro(2) .
The target process, pid, whether it is running or not running, resumes execution after all other runnable processes of equal or greater priority have been scheduled to run.
If the priority of the process, pid, is set higher than that of the lowest priority running process, and if process pid is ready to run, then process pid preempts a lowest priority running process. Similarly, if the process calling sched_setparam() sets its own priority lower than that of one or more other non-empty process lists, then the process that is the head of the highest priority list preempts the calling process. Thus, in either case, the originating process might not receive notification of the completion of the requested priority change until the higher priority process has executed.
The value of param->sched_priority must be an integer within the inclusive priority range for the current scheduling policy of the process specified by pid. Higher numerical values for the priority represent higher priorities.