In particular, the parameter which can be set to PRIO_PROCESS or
PRIO_USER, respectively, indicating that the parameter will be interpreted
as a process identifier or user ID. In the first case, they set a priority for a
specific process (or for the current process, if who equals zero), in the
second - for all processes of that user.
The priority parameter sets a new priority. Priority may vary from –20 to
20, smaller values indicate higher priority. The default value is 0.
Negative priority values can only be set by users with admin privileges.
Use the getpriority () call to get information about the current base priority :
Int getpriority (int which, int who);
This call returns the priority value, the which and who parameters for it
have the same meaning as for the setpriority () function.
Here's an example of how to use these calls:
// set a priority for the current process
setpriority ( PRIO _ PROCESS , 0.10);
// find out about the current priority value
printf (" current priority: % d \ n ", getpriority ( PRIO _ PROCESS , 0));
You can also use the nice () system call to change the underlying priority of
the current process relatively :
# Include < unistd . h >
int nice ( int inc ); // changes the priorities of the current process to inc .