summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authorjake <jake@FreeBSD.org>2001-02-12 00:20:08 +0000
committerjake <jake@FreeBSD.org>2001-02-12 00:20:08 +0000
commit55d5108ac58bdc48fbd9eccefcb58a49682107b5 (patch)
tree2e0de19f9802474be1018e6086f4bb4e01fed0be /sys/kern/kern_resource.c
parent3acecaf2d523e3763f225a429b3007ff059b4253 (diff)
downloadFreeBSD-src-55d5108ac58bdc48fbd9eccefcb58a49682107b5.zip
FreeBSD-src-55d5108ac58bdc48fbd9eccefcb58a49682107b5.tar.gz
Implement a unified run queue and adjust priority levels accordingly.
- All processes go into the same array of queues, with different scheduling classes using different portions of the array. This allows user processes to have their priorities propogated up into interrupt thread range if need be. - I chose 64 run queues as an arbitrary number that is greater than 32. We used to have 4 separate arrays of 32 queues each, so this may not be optimal. The new run queue code was written with this in mind; changing the number of run queues only requires changing constants in runq.h and adjusting the priority levels. - The new run queue code takes the run queue as a parameter. This is intended to be used to create per-cpu run queues. Implement wrappers for compatibility with the old interface which pass in the global run queue structure. - Group the priority level, user priority, native priority (before propogation) and the scheduling class into a struct priority. - Change any hard coded priority levels that I found to use symbolic constants (TTIPRI and TTOPRI). - Remove the curpriority global variable and use that of curproc. This was used to detect when a process' priority had lowered and it should yield. We now effectively yield on every interrupt. - Activate propogate_priority(). It should now have the desired effect without needing to also propogate the scheduling class. - Temporarily comment out the call to vm_page_zero_idle() in the idle loop. It interfered with propogate_priority() because the idle process needed to do a non-blocking acquire of Giant and then other processes would try to propogate their priority onto it. The idle process should not do anything except idle. vm_page_zero_idle() will return in the form of an idle priority kernel thread which is woken up at apprioriate times by the vm system. - Update struct kinfo_proc to the new priority interface. Deliberately change its size by adjusting the spare fields. It remained the same size, but the layout has changed, so userland processes that use it would parse the data incorrectly. The size constraint should really be changed to an arbitrary version number. Also add a debug.sizeof sysctl node for struct kinfo_proc.
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c64
1 files changed, 49 insertions, 15 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 8af2be5..1feea8b 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -264,7 +264,8 @@ rtprio(curp, uap)
switch (uap->function) {
case RTP_LOOKUP:
- return (copyout(&p->p_rtprio, uap->rtp, sizeof(struct rtprio)));
+ pri_to_rtp(&p->p_pri, &rtp);
+ return (copyout(&rtp, uap->rtp, sizeof(struct rtprio)));
case RTP_SET:
if ((error = p_can(curp, p, P_CAN_SCHED, NULL)))
return (error);
@@ -287,26 +288,59 @@ rtprio(curp, uap)
if (rtp.type != RTP_PRIO_NORMAL)
return (EPERM);
}
- switch (rtp.type) {
-#ifdef RTP_PRIO_FIFO
- case RTP_PRIO_FIFO:
-#endif
- case RTP_PRIO_REALTIME:
- case RTP_PRIO_NORMAL:
- case RTP_PRIO_IDLE:
- if (rtp.prio > RTP_PRIO_MAX)
- return (EINVAL);
- p->p_rtprio = rtp;
+ if (rtp_to_pri(&rtp, &p->p_pri) == 0)
return (0);
- default:
- return (EINVAL);
- }
-
+ return (EINVAL);
default:
return (EINVAL);
}
}
+int
+rtp_to_pri(struct rtprio *rtp, struct priority *pri)
+{
+
+ if (rtp->prio > RTP_PRIO_MAX)
+ return (-1);
+ switch (RTP_PRIO_BASE(rtp->type)) {
+ case RTP_PRIO_REALTIME:
+ pri->pri_level = PRI_MIN_REALTIME + rtp->prio;
+ break;
+ case RTP_PRIO_NORMAL:
+ pri->pri_level = PRI_MIN_TIMESHARE + rtp->prio;
+ break;
+ case RTP_PRIO_IDLE:
+ pri->pri_level = PRI_MIN_IDLE + rtp->prio;
+ break;
+ default:
+ return (-1);
+ }
+ pri->pri_class = rtp->type;
+ pri->pri_native = pri->pri_level;
+ pri->pri_user = pri->pri_level;
+ return (0);
+}
+
+void
+pri_to_rtp(struct priority *pri, struct rtprio *rtp)
+{
+
+ switch (PRI_BASE(pri->pri_class)) {
+ case PRI_REALTIME:
+ rtp->prio = pri->pri_level - PRI_MIN_REALTIME;
+ break;
+ case PRI_TIMESHARE:
+ rtp->prio = pri->pri_level - PRI_MIN_TIMESHARE;
+ break;
+ case PRI_IDLE:
+ rtp->prio = pri->pri_level - PRI_MIN_IDLE;
+ break;
+ default:
+ break;
+ }
+ rtp->type = pri->pri_class;
+}
+
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
#ifndef _SYS_SYSPROTO_H_
struct osetrlimit_args {
OpenPOWER on IntegriCloud