Date: Wed, 9 Jan 2002 14:39:52 -0800 (PST) From: Julian Elischer <julian@elischer.org> To: arch@freebsd.org Subject: priority and swapping: Message-ID: <Pine.BSF.4.21.0201091426370.44623-100000@InterJet.elischer.org>
next in thread | raw e-mail | index | archive | help
The swapping code has teh following snippet in schedular() (what a
misnamed function) which tries to select which swapped out process to swap
back in:
FOREACH_PROC_IN_SYSTEM(p) {
struct ksegrp *kg;
if (p->p_sflag & (PS_INMEM | PS_SWAPPING)) {
continue;
}
mtx_lock_spin(&sched_lock);
FOREACH_THREAD_IN_PROC(p, td) {
/* Only consider runnable threads */
if (td->td_state == TDS_RUNQ) {
kg = td->td_ksegrp;
pri = p->p_swtime + kg->kg_slptime;
if ((p->p_sflag & PS_SWAPINREQ) == 0) {
pri -= kg->kg_nice * 8;
}
/*
* if this ksegrp is higher priority
* and there is enough space, then select
* this process instead of the previous
* selection.
*/
if (pri > ppri) {
pp = p;
ppri = pri;
}
}
This is a directly 'expanded' version of what was there before the KSE
changes... (basically just the 2nd FOREACH was added)
nowhere in this code does it look at the actual priority of the thread
(was process) priority even referenced.
Instead they are creating this rather strange number derived from
various timings.
The original pre KSE code was:
LIST_FOREACH(p, &allproc, p_list) {
mtx_lock_spin(&sched_lock);
if (p->p_stat == SRUN &&
(p->p_sflag & (PS_INMEM | PS_SWAPPING)) == 0) {
pri = p->p_swtime + p->p_slptime;
if ((p->p_sflag & PS_SWAPINREQ) == 0) {
pri -= p->p_nice * 8;
}
/*
* if this process is higher priority and there is
* enough space, then select this process instead
of
* the previous selection.
*/
if (pri > ppri) {
pp = p;
ppri = pri;
}
}
which didn't reference the priority either.
What exactly is it trying to do?
scheduel a process for swappin based purely on time swapped out?
doesn't priority (despite the names in the code) come into it?
Was it originally there in some pre-freebsd version?
The code in 1.1 of the file is:
for (p = (struct proc *)allproc; p != NULL; p = p->p_next) {
if (p->p_stat == SRUN && (p->p_flag & P_INMEM) == 0) {
pri = p->p_swtime + p->p_slptime - p->p_nice * 8;
if (pri > ppri) {
pp = p;
ppri = pri;
}
}
}
SWAPINREQ simply disabling the effect of NICE is a bit wierd too.
thoughts anyone?
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0201091426370.44623-100000>
