Add SCHED_FIFO/SCHED_RR support to sched_get_priority_{min,max}.

This commit is contained in:
njoly 2008-05-01 16:06:17 +00:00
parent 50fa672c8b
commit 4c44d432ea
1 changed files with 34 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: linux_sched.c,v 1.54 2008/04/28 20:23:44 martin Exp $ */
/* $NetBSD: linux_sched.c,v 1.55 2008/05/01 16:06:17 njoly Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.54 2008/04/28 20:23:44 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: linux_sched.c,v 1.55 2008/05/01 16:06:17 njoly Exp $");
#include <sys/param.h>
#include <sys/mount.h>
@ -231,9 +231,13 @@ sched_native2linux(int native_policy, struct sched_param *native_params,
if (native_params != NULL) {
int prio = native_params->sched_priority;
#if 0
KASSERT(prio >= SCHED_PRI_MIN);
KASSERT(prio <= SCHED_PRI_MAX);
KASSERT(linux_params != NULL);
#endif
printf("native2linux: native: policy %d, priority %d\n",
native_policy, prio);
if (native_policy == SCHED_OTHER) {
linux_params->sched_priority = 0;
@ -244,6 +248,8 @@ sched_native2linux(int native_policy, struct sched_param *native_params,
/ (SCHED_PRI_MAX - SCHED_PRI_MIN)
+ LINUX_SCHED_RTPRIO_MIN;
}
printf("native2linux: linux: policy %d, priority %d\n",
-1, linux_params->sched_priority);
}
return 0;
@ -308,10 +314,14 @@ linux_sys_sched_getparam(struct lwp *l, const struct linux_sys_sched_getparam_ar
error = do_sched_getparam(SCARG(uap, pid), 0, &policy, &sp);
if (error)
goto out;
printf("getparam: native: policy %d, priority %d\n",
policy, sp.sched_priority);
error = sched_native2linux(policy, &sp, NULL, &lp);
if (error)
goto out;
printf("getparam: linux: policy %d, priority %d\n",
policy, lp.sched_priority);
error = copyout(&lp, SCARG(uap, sp), sizeof(lp));
if (error)
@ -341,10 +351,14 @@ linux_sys_sched_setscheduler(struct lwp *l, const struct linux_sys_sched_setsche
error = copyin(SCARG(uap, sp), &lp, sizeof(lp));
if (error)
goto out;
printf("setscheduler: linux: policy %d, priority %d\n",
SCARG(uap, policy), lp.sched_priority);
error = sched_linux2native(SCARG(uap, policy), &lp, &policy, &sp);
if (error)
goto out;
printf("setscheduler: native: policy %d, priority %d\n",
policy, sp.sched_priority);
error = do_sched_setparam(SCARG(uap, pid), 0, policy, &sp);
if (error)
@ -393,15 +407,18 @@ linux_sys_sched_get_priority_max(struct lwp *l, const struct linux_sys_sched_get
syscallarg(int) policy;
} */
/*
* We can't emulate anything put the default scheduling policy.
*/
if (SCARG(uap, policy) != LINUX_SCHED_OTHER) {
*retval = -1;
switch (SCARG(uap, policy)) {
case LINUX_SCHED_OTHER:
*retval = 0;
break;
case LINUX_SCHED_FIFO:
case LINUX_SCHED_RR:
*retval = LINUX_SCHED_RTPRIO_MAX;
break;
default:
return EINVAL;
}
*retval = 0;
return 0;
}
@ -412,15 +429,18 @@ linux_sys_sched_get_priority_min(struct lwp *l, const struct linux_sys_sched_get
syscallarg(int) policy;
} */
/*
* We can't emulate anything put the default scheduling policy.
*/
if (SCARG(uap, policy) != LINUX_SCHED_OTHER) {
*retval = -1;
switch (SCARG(uap, policy)) {
case LINUX_SCHED_OTHER:
*retval = 0;
break;
case LINUX_SCHED_FIFO:
case LINUX_SCHED_RR:
*retval = LINUX_SCHED_RTPRIO_MIN;
break;
default:
return EINVAL;
}
*retval = 0;
return 0;
}