Difference between nice and setpriority in unix

Aswin Parthasarathy picture Aswin Parthasarathy · Oct 1, 2011 · Viewed 8.4k times · Source

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() ?

Answer

Foo Bah picture Foo Bah · Oct 1, 2011

It's historical. nice() was introduced long before setpriority(). For backwards compatibility, the nice function was retained.