简体   繁体   中英

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.

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM