SCCS-vsn: sys/kern/tty.c 7.36
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)tty.c 7.35 (Berkeley) %G%
+ * @(#)tty.c 7.36 (Berkeley) %G%
struct tty *tp;
{
register struct proc *p, *pick = NULL;
struct tty *tp;
{
register struct proc *p, *pick = NULL;
- register char *cp = hostname;
int x, s;
struct timeval utime, stime;
#define pgtok(a) (((a)*NBPG)/1024)
if (ttycheckoutq(tp,0) == 0)
return;
int x, s;
struct timeval utime, stime;
#define pgtok(a) (((a)*NBPG)/1024)
if (ttycheckoutq(tp,0) == 0)
return;
- /*
- * hostname
- */
- if (ttyhostname) {
- if (*cp == '\0')
- ttyprintf(tp, "amnesia");
- else
- while (*cp && *cp != '.')
- tputchar(*cp++, tp);
- tputchar(' ');
- }
*
*/
#define isrun(p) (((p)->p_stat == SRUN) || ((p)->p_stat == SIDL))
*
*/
#define isrun(p) (((p)->p_stat == SRUN) || ((p)->p_stat == SIDL))
+#define TESTAB(a, b) ((a)<<1 | (b))
+#define ONLYA 2
+#define ONLYB 1
+#define BOTH 3
+
proc_compare(p1, p2)
register struct proc *p1, *p2;
{
proc_compare(p1, p2)
register struct proc *p1, *p2;
{
/*
* see if at least one of them is runnable
*/
/*
* see if at least one of them is runnable
*/
- switch (isrun(p1)<<1 | isrun(p2)) {
- case 0x01:
- return (1);
- case 0x10:
+ switch (TESTAB(isrun(p1), isrun(p2))) {
+ case ONLYA:
+ case ONLYB:
+ return (1);
+ case BOTH:
/*
* tie - favor one with highest recent cpu utilization
*/
/*
* tie - favor one with highest recent cpu utilization
*/
return (0);
return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
}
return (0);
return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
}
+ /*
+ * weed out zombies
+ */
+ switch (TESTAB(p1->p_stat == SZOMB, p2->p_stat == SZOMB)) {
+ case ONLYA:
+ return (1);
+ case ONLYB:
+ return (0);
+ case BOTH:
+ return (p2->p_pid > p1->p_pid); /* tie - return highest pid */
+ }
/*
* pick the one with the smallest sleep time
*/
/*
* pick the one with the smallest sleep time
*/
return (0);
return(p2->p_pid > p1->p_pid); /* tie - return highest pid */
}
return (0);
return(p2->p_pid > p1->p_pid); /* tie - return highest pid */
}
#define TOTTY 0x2 /* XXX should be in header */
/*VARARGS2*/
ttyprintf(tp, fmt, x1)
#define TOTTY 0x2 /* XXX should be in header */
/*VARARGS2*/
ttyprintf(tp, fmt, x1)