Hind Forsum
Hind Forsum

Reputation: 10527

Does linux c/c++ programming support setting process priority?

Under linux, I can use "nice" command to set process priority, NP. But I didn't find a way to set this information within my c program, I don't find clue in [APUE] book.

Is there a posix api to do this job? Thanks a lot.

Upvotes: 1

Views: 2321

Answers (1)

Sylvain P
Sylvain P

Reputation: 91

There is nice() function in unistd.h.

Example :

#include <unistd.h>

int main()
{
    nice(4); // To set level 4 as nice value to current process
    return 0;
}

Upvotes: 2

Related Questions