2017-01-09 69 views
1

在linux下,我可以使用「nice」命令設置進程優先級NP。但是我沒有找到在我的c程序中設置這些信息的方法,我在[APUE]書中找不到線索。linux c/C++編程支持設置進程優先級嗎?

是否有posix api來完成這項工作? 非常感謝。

+1

http://www.tutorialspoint.com/unix_system_calls/nice.htm – Arunmu

+2

如何關於['nice'](http://man7.org/linux/man-pages /man2/nice.2.html)系統調用? –

回答

2

unistd.h中有nice()函數。

實施例:

#include <unistd.h> 

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