在 Windows 上我可以做:
HANDLE hCurrentProcess = GetCurrentProcess();
SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS);
我怎样才能在 *nix 上做同样的事情?
最佳答案
尝试:
#include <sys/time.h>
#include <sys/resource.h>
int main(){
setpriority(PRIO_PROCESS, 0, -20);
}
请注意,您必须以 super 用户身份运行才能运行。
(有关更多信息,请在提示符下键入“man setpriority”。)
关于在 C 中更改当前进程的优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29621/