summaryrefslogtreecommitdiffstats
path: root/sys/kern/ksched.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/ksched.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/ksched.c')
-rw-r--r--sys/kern/ksched.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/sys/kern/ksched.c b/sys/kern/ksched.c
index 192034f..2d11363 100644
--- a/sys/kern/ksched.c
+++ b/sys/kern/ksched.c
@@ -81,9 +81,8 @@ ksched_detach(struct ksched *ks)
* higher priority. It also permits sched_setparam to be
* implementation defined for SCHED_OTHER. I don't like
* the notion of inverted priorites for normal processes when
- * you can use "setpriority" for that.
+ * you can use "setpriority" for that.
*
- * I'm rejecting sched_setparam for SCHED_OTHER with EINVAL.
*/
/* Macros to convert between the unix (lower numerically is higher priority)
@@ -93,6 +92,9 @@ ksched_detach(struct ksched *ks)
#define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P))
#define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P))
+#define p4prio_to_tsprio(P) ((PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE) - (P))
+#define tsprio_to_p4prio(P) ((PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE) - (P))
+
/* These improve readability a bit for me:
*/
#define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX)
@@ -134,9 +136,6 @@ ksched_setparam(struct ksched *ksched,
if (e == 0)
{
- if (policy == SCHED_OTHER)
- e = EINVAL;
- else
e = ksched_setscheduler(ksched, td, policy, param);
}
@@ -152,7 +151,16 @@ ksched_getparam(struct ksched *ksched,
pri_to_rtp(td, &rtp);
if (RTP_PRIO_IS_REALTIME(rtp.type))
param->sched_priority = rtpprio_to_p4prio(rtp.prio);
-
+ else {
+ if (PRI_MIN_TIMESHARE < rtp.prio)
+ /*
+ * The interactive score has it to min realtime
+ * so we must show max (64 most likely
+ */
+ param->sched_priority = (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE);
+ else
+ param->sched_priority = tsprio_to_p4prio(rtp.prio);
+ }
return 0;
}
@@ -191,11 +199,14 @@ ksched_setscheduler(struct ksched *ksched,
break;
case SCHED_OTHER:
- {
+ if (param->sched_priority >= 0 &&
+ param->sched_priority <= (PRI_MAX_TIMESHARE - PRI_MIN_TIMESHARE)) {
rtp.type = RTP_PRIO_NORMAL;
rtp.prio = p4prio_to_rtpprio(param->sched_priority);
rtp_to_pri(&rtp, td);
- }
+ } else
+ e = EINVAL;
+
break;
default:
OpenPOWER on IntegriCloud