summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1999-03-03 18:15:29 +0000
committerjulian <julian@FreeBSD.org>1999-03-03 18:15:29 +0000
commitee38b913245110a5902f02f489c58c5b31c1cb92 (patch)
tree21b5407e4d59507c52477cb76e84db75154e9279 /sys
parent118df06bdcd43b5a9fcca61243a7ff85da4c40e0 (diff)
downloadFreeBSD-src-ee38b913245110a5902f02f489c58c5b31c1cb92.zip
FreeBSD-src-ee38b913245110a5902f02f489c58c5b31c1cb92.tar.gz
The tunable parameter for the scheduler quantum was inverted.
Higher numbers led to smaller quanta. In discussion with BDE, change this parameter to be in uSecs to make it machine independent, and limit it to non zero multiples of 'tick' (rounding down). Also make the variabel globally available so that the present function that returns its value (used for posix scheduling I believe) can go away. Submitted by: Bruce Evans <bde@freebsd.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_synch.c53
-rw-r--r--sys/sys/proc.h3
2 files changed, 25 insertions, 31 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index 8473adee..892f8bb 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_synch.c 8.9 (Berkeley) 5/19/95
- * $Id: kern_synch.c,v 1.73 1999/02/22 16:57:47 bde Exp $
+ * $Id: kern_synch.c,v 1.74 1999/02/28 10:53:29 bde Exp $
*/
#include "opt_ktrace.h"
@@ -64,43 +64,37 @@
static void rqinit __P((void *));
SYSINIT(runqueue, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, rqinit, NULL)
+static void sched_setup __P((void *dummy));
+SYSINIT(sched_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, sched_setup, NULL)
-u_char curpriority; /* usrpri of curproc */
+u_char curpriority;
int hogticks;
-int lbolt; /* once a second sleep address */
+int lbolt;
+int sched_quantum; /* Roundrobin scheduling quantum in ticks. */
static void endtsleep __P((void *));
static void roundrobin __P((void *arg));
static void schedcpu __P((void *arg));
static void updatepri __P((struct proc *p));
-#define MAXIMUM_SCHEDULE_QUANTUM (1000000) /* arbitrary limit */
-#ifndef DEFAULT_SCHEDULE_QUANTUM
-#define DEFAULT_SCHEDULE_QUANTUM 10
-#endif
-static int quantum = DEFAULT_SCHEDULE_QUANTUM; /* default value */
-
static int
sysctl_kern_quantum SYSCTL_HANDLER_ARGS
{
- int error;
- int new_val = quantum;
+ int error, new_val;
- new_val = quantum;
+ new_val = sched_quantum * tick;
error = sysctl_handle_int(oidp, &new_val, 0, req);
- if (error == 0) {
- if ((new_val > 0) && (new_val < MAXIMUM_SCHEDULE_QUANTUM)) {
- quantum = new_val;
- } else {
- error = EINVAL;
- }
- }
- hogticks = 2 * (hz / quantum);
- return (error);
+ if (error != 0 || req->newptr == NULL)
+ return (error);
+ if (new_val < tick)
+ return (EINVAL);
+ sched_quantum = new_val / tick;
+ hogticks = 2 * sched_quantum;
+ return (0);
}
SYSCTL_PROC(_kern, OID_AUTO, quantum, CTLTYPE_INT|CTLFLAG_RW,
- 0, sizeof quantum, sysctl_kern_quantum, "I", "");
+ 0, sizeof sched_quantum, sysctl_kern_quantum, "I", "");
/* maybe_resched: Decide if you need to reschedule or not
* taking the priorities and schedulers into account.
@@ -126,10 +120,10 @@ static void maybe_resched(struct proc *chk)
}
}
-#define ROUNDROBIN_INTERVAL (hz / quantum)
-int roundrobin_interval(void)
+int
+roundrobin_interval(void)
{
- return ROUNDROBIN_INTERVAL;
+ return (sched_quantum);
}
/*
@@ -152,7 +146,7 @@ roundrobin(arg)
need_resched();
#endif
- timeout(roundrobin, NULL, ROUNDROBIN_INTERVAL);
+ timeout(roundrobin, NULL, sched_quantum);
}
/*
@@ -358,11 +352,12 @@ static TAILQ_HEAD(slpquehead, proc) slpque[TABLESIZE];
int safepri;
void
-sleepinit()
+sleepinit(void)
{
int i;
- hogticks = 2 * (hz / quantum);
+ sched_quantum = hz/10;
+ hogticks = 2 * sched_quantum;
for (i = 0; i < TABLESIZE; i++)
TAILQ_INIT(&slpque[i]);
}
@@ -915,7 +910,6 @@ resetpriority(p)
}
/* ARGSUSED */
-static void sched_setup __P((void *dummy));
static void
sched_setup(dummy)
void *dummy;
@@ -924,5 +918,4 @@ sched_setup(dummy)
roundrobin(NULL);
schedcpu(NULL);
}
-SYSINIT(sched_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, sched_setup, NULL)
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 53eef6d..1d0a9b7 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)proc.h 8.15 (Berkeley) 5/19/95
- * $Id: proc.h,v 1.71 1999/02/25 14:28:46 newton Exp $
+ * $Id: proc.h,v 1.72 1999/02/28 10:53:29 bde Exp $
*/
#ifndef _SYS_PROC_H_
@@ -329,6 +329,7 @@ extern struct proc proc0; /* Process slot for swapper. */
extern int hogticks; /* Limit on kernel cpu hogs. */
extern int nprocs, maxproc; /* Current and max number of procs. */
extern int maxprocperuid; /* Max procs per uid. */
+extern int sched_quantum; /* Scheduling quantum in ticks */
extern int switchticks; /* `ticks' at last context switch. */
extern struct timeval switchtime; /* Uptime at last context switch */
OpenPOWER on IntegriCloud