summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authorrrs <rrs@FreeBSD.org>2010-03-03 21:46:51 +0000
committerrrs <rrs@FreeBSD.org>2010-03-03 21:46:51 +0000
commit17cf51b0bb72fa08f25c8a9d75cc5ea8bafbe411 (patch)
treec9c68201502ab8e8bc6bf2ede01d6073c3665076 /sys/kern/kern_resource.c
parent555659f03fccad2ea37af5f10d72d2e843df9ec1 (diff)
downloadFreeBSD-src-17cf51b0bb72fa08f25c8a9d75cc5ea8bafbe411.zip
FreeBSD-src-17cf51b0bb72fa08f25c8a9d75cc5ea8bafbe411.tar.gz
sched_getparam was just plain broke for time-share
processes. It did not return an error but instead just let garbage be passed back. This I fix so it actually properly translates the priority the process is at to a posix's high means more priority. I also fix it so that if the ULE scheduler has bumped it up to a realtime process you get back a sane value i.e. the highest priority (63 for time-share). sched_setscheduler() had the setting of the timeshare class priority disabled. With some notes about rejecting the posix high numbers is greater priority and use nice instead. This fix also adjusts that to work, with the cavet that a t-s process may well get bumped up or down i.e. the setscheduler() will NOT change the nice value only the current priority. I think this is reasonable considering if the user wants to play with nice then he can. At least all the posix'ish interfaces now respond sanely. MFC after: 3 weeks
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 81a03ef..f867839 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -471,14 +471,20 @@ rtp_to_pri(struct rtprio *rtp, struct thread *td)
u_char newpri;
u_char oldpri;
- if (rtp->prio > RTP_PRIO_MAX)
- return (EINVAL);
thread_lock(td);
switch (RTP_PRIO_BASE(rtp->type)) {
case RTP_PRIO_REALTIME:
+ if (rtp->prio > RTP_PRIO_MAX) {
+ thread_unlock(td);
+ return (EINVAL);
+ }
newpri = PRI_MIN_REALTIME + rtp->prio;
break;
case RTP_PRIO_NORMAL:
+ if (rtp->prio > (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE)) {
+ thread_unlock(td);
+ return (EINVAL);
+ }
newpri = PRI_MIN_TIMESHARE + rtp->prio;
break;
case RTP_PRIO_IDLE:
OpenPOWER on IntegriCloud