getpriority setpriority

头文件:

#include <sys/time.h>
#include <sys/resource.h>

原型:

int getpriority(int which, int who);
int setpriority(int which, int who, int prio);

参数:

which为PRIO_PROCESS,则who指定进程ID;

which为PRIO_PGRP,则who指定进程组ID;

which为PRIO_USER,则who指定用户ID.

who为0,代表调用该函数的当前进程ID,进程组ID或用户ID.

prio  -20---19,一般默认为0,pri越小,优先级越高,执行越频繁。

返回值:

get:成功,返回进程优先权;失败,返回-1,错误码存于errno.

set:成功,0;失败,-1.

功能:取得或设置进程、进程组或用户执行优先级。

原文地址:https://www.cnblogs.com/helloweworld/p/2772313.html