1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Patches that eliminate extra context switches in FIFO case.

Fixes p1003_1b regression test in the simple case of no RR and
FIFO processes competing.

Reviewed by:	jkh, bde
This commit is contained in:
Peter Dufault 2000-03-02 16:20:07 +00:00
parent 290c9a02c3
commit 383774c417
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=57701
9 changed files with 61 additions and 17 deletions

View File

@ -129,6 +129,7 @@ userret(p, pc, oticks)
}
curpriority = p->p_priority;
currtpriority = p->p_rtprio.prio;
}
static void

View File

@ -71,7 +71,7 @@ struct clockframe {
* Preempt the current process if in interrupt from user mode,
* or after the current trap/syscall if in system mode.
*/
#define need_resched() { want_resched = 1; aston(); }
#define need_resched() do { want_resched = 1; aston(); } while (0)
#define resched_wanted() want_resched
@ -80,7 +80,8 @@ struct clockframe {
* buffer pages are invalid. On the hp300, request an ast to send us
* through trap, marking the proc as needing a profiling tick.
*/
#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }
#define need_proftick(p) \
do { (p)->p_flag |= P_OWEUPC; aston(); } while (0)
/*
* Notify the current process (p) that it has a signal pending,

View File

@ -196,6 +196,7 @@ userret(p, frame, oticks)
(u_int)(p->p_sticks - oticks) * psratio);
curpriority = p->p_priority;
currtpriority = p->p_rtprio.prio;
}
/*

View File

@ -83,7 +83,7 @@
* Preempt the current process if in interrupt from user mode,
* or after the current trap/syscall if in system mode.
*/
#define need_resched() { want_resched = 1; aston(); }
#define need_resched() do { want_resched = 1; aston(); } while (0)
#define resched_wanted() want_resched
@ -94,7 +94,8 @@
* single tick and the P_OWEUPC flag served as a counter. Now there is a
* counter in the proc table and flag isn't really necessary.
*/
#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }
#define need_proftick(p) \
do { (p)->p_flag |= P_OWEUPC; aston(); } while (0)
/*
* Notify the current process (p) that it has a signal pending,

View File

@ -196,6 +196,7 @@ userret(p, frame, oticks)
(u_int)(p->p_sticks - oticks) * psratio);
curpriority = p->p_priority;
currtpriority = p->p_rtprio.prio;
}
/*

View File

@ -83,7 +83,7 @@
* Preempt the current process if in interrupt from user mode,
* or after the current trap/syscall if in system mode.
*/
#define need_resched() { want_resched = 1; aston(); }
#define need_resched() do { want_resched = 1; aston(); } while (0)
#define resched_wanted() want_resched
@ -94,7 +94,8 @@
* single tick and the P_OWEUPC flag served as a counter. Now there is a
* counter in the proc table and flag isn't really necessary.
*/
#define need_proftick(p) { (p)->p_flag |= P_OWEUPC; aston(); }
#define need_proftick(p) \
do { (p)->p_flag |= P_OWEUPC; aston(); } while (0)
/*
* Notify the current process (p) that it has a signal pending,

View File

@ -65,11 +65,14 @@ static void sched_setup __P((void *dummy));
SYSINIT(sched_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, sched_setup, NULL)
u_char curpriority;
u_char currtpriority;
int hogticks;
int lbolt;
int sched_quantum; /* Roundrobin scheduling quantum in ticks. */
static int curpriority_cmp __P((struct proc *p));
static void endtsleep __P((void *));
static void maybe_resched __P((struct proc *chk));
static void roundrobin __P((void *arg));
static void schedcpu __P((void *arg));
static void updatepri __P((struct proc *p));
@ -93,28 +96,59 @@ sysctl_kern_quantum SYSCTL_HANDLER_ARGS
SYSCTL_PROC(_kern, OID_AUTO, quantum, CTLTYPE_INT|CTLFLAG_RW,
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.
/*-
* Compare priorities. Return:
* <0: priority of p < current priority
* 0: priority of p == current priority
* >0: priority of p > current priority
* The priorities are the normal priorities or the normal realtime priorities
* if p is on the same scheduler as curproc. Otherwise the process on the
* more realtimeish scheduler has lowest priority. As usual, a higher
* priority really means a lower priority.
*/
static void maybe_resched(struct proc *chk)
static int
curpriority_cmp(p)
struct proc *p;
{
int c_class, p_class;
if (curproc->p_rtprio.prio != currtpriority)
Debugger("currtprio");
c_class = RTP_PRIO_BASE(curproc->p_rtprio.type);
p_class = RTP_PRIO_BASE(p->p_rtprio.type);
if (p_class != c_class)
return (p_class - c_class);
if (p_class == RTP_PRIO_NORMAL)
return (((int)p->p_priority - (int)curpriority) / PPQ);
return ((int)p->p_rtprio.prio - (int)currtpriority);
}
/*
* Arrange to reschedule if necessary, taking the priorities and
* schedulers into account.
*/
static void
maybe_resched(chk)
struct proc *chk;
{
struct proc *p = curproc; /* XXX */
/*
* Compare priorities if the new process is on the same scheduler,
* otherwise the one on the more realtimeish scheduler wins.
*
* XXX idle scheduler still broken because proccess stays on idle
* scheduler during waits (such as when getting FS locks). If a
* standard process becomes runaway cpu-bound, the system can lockup
* due to idle-scheduler processes in wakeup never getting any cpu.
*/
if (p == 0 ||
(chk->p_priority < curpriority && RTP_PRIO_BASE(p->p_rtprio.type) == RTP_PRIO_BASE(chk->p_rtprio.type)) ||
RTP_PRIO_BASE(chk->p_rtprio.type) < RTP_PRIO_BASE(p->p_rtprio.type)
) {
if (p == NULL) {
#if 0
need_resched();
#endif
} else if (chk == p) {
/* We may need to yield if our priority has been raised. */
if (curpriority_cmp(chk) > 0)
need_resched();
} else if (curpriority_cmp(chk) < 0)
need_resched();
}
}
int
@ -437,6 +471,7 @@ tsleep(ident, priority, wmesg, timo)
mi_switch();
resume:
curpriority = p->p_usrpri;
currtpriority = p->p_rtprio.prio;
splx(s);
p->p_flag &= ~P_SINTR;
if (p->p_flag & P_TIMEOUT) {
@ -576,6 +611,7 @@ await(int priority, int timo)
mi_switch();
resume:
curpriority = p->p_usrpri;
currtpriority = p->p_rtprio.prio;
splx(s);
p->p_flag &= ~P_SINTR;

View File

@ -196,6 +196,7 @@ userret(p, frame, oticks)
(u_int)(p->p_sticks - oticks) * psratio);
curpriority = p->p_priority;
currtpriority = p->p_rtprio.prio;
}
/*

View File

@ -59,6 +59,7 @@ extern int nswap; /* size of swap space */
extern int selwait; /* select timeout address */
extern u_char curpriority; /* priority of current process */
extern u_char currtpriority; /* realtime priority of current process */
extern int physmem; /* physical memory */