内核函数 设置 获取进程nice值

void set_user_nice( struct task_struct *p,   long nice)

功能: 设置进程的nice值

p:进程的描述符

nice:设置的nice值 取值范围为 -20 ~ 19 值越大优先级越小

头文件: #include <linux/sched.h>

int task_nice(const struct task_struct *p)
{
    return TASK_NICE(p);
}

功能: 获得进程的nice值

p: 进程描述符

返回值: 进程的nice值

头文件: #include <linux/sched.h>

#define MAX_USER_RT_PRIO    100
#define MAX_RT_PRIO                  MAX_USER_RT_PRIO

#define PRIO_TO_NICE(prio)        ((prio) - MAX_RT_PRIO - 20)
#define TASK_NICE(p)                    PRIO_TO_NICE((p)->static_prio)

例子如下:

猜你喜欢

转载自blog.csdn.net/yldfree/article/details/81108449