I'm trying to implement a different flavor of the 'nice' command of unix in C. I have seen the definitions of nice() system call and setpriority() call. The nice() call only increments/decrements the priority of the process. If I want to set the priority of a process to a particular value, can't I use the nice() call? Basically, other than how the priority is modified, is there any difference between nice() and setpriority() ?
It's historical. nice()
was introduced long before setpriority()
. For backwards compatibility, the nice
function was retained.
nice
sets your own priority (the niceness of the current process). setpriority
lets you set the niceness of other processes (or process groups or users). Think of it as renice
.
man 3p nice
int nice(int incr);
man 3p setpriority
int setpriority(int which, id_t who, int value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With