Linux 2.6.36版本内核分析之sched_get_priority_max与sched_get_priority_min

sched_get_priority_max()获取实时优先级的最大值【在kernel/sched.c中】
/**
 * sys_sched_get_priority_max - return maximum RT priority.
 * @policy: scheduling class.
 *
 * this syscall returns the maximum rt_priority that can be used
 * by a given scheduling class.
 */
SYSCALL_DEFINE1(sched_get_priority_max, int, policy)
{
int ret = -EINVAL;


switch (policy) {
case SCHED_FIFO:
case SCHED_RR:
ret = MAX_USER_RT_PRIO-1;
break;
case SCHED_NORMAL:
case SCHED_BATCH:
case SCHED_IDLE:
ret = 0;
break;
}
return ret;
}


sched_get_priority_max()获取实时优先级的最小值【在kernel/sched.c中】
/**
 * sys_sched_get_priority_min - return minimum RT priority.
 * @policy: scheduling class.
 *
 * this syscall returns the minimum rt_priority that can be used
 * by a given scheduling class.
 */
SYSCALL_DEFINE1(sched_get_priority_min, int, policy)
{
int ret = -EINVAL;


switch (policy) {
case SCHED_FIFO:
case SCHED_RR:
ret = 1;
break;
case SCHED_NORMAL:
case SCHED_BATCH:
case SCHED_IDLE:
ret = 0;
}
return ret;
}


实时调度策略(SCHED_FIFO、SCHED_RR)优先级最大值为99;普通调度策略(SCHED_NORMAL、SCHED_BATCH、SCHED_IDLE),始终返回0,即普通任务调用此函数,无效果。

实时任务的优先级范围为1~99,99最大。

你可能感兴趣的:(C,Linux)