1 /* 2 * Copyright (c) 1992 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * 9 * All advertising materials mentioning features or use of this software 10 * must display the following acknowledgement: 11 * This product includes software developed by the University of 12 * California, Lawrence Berkeley Laboratories. 13 * 14 * %sccs.include.redist.c% 15 * 16 * @(#)locore2.c 7.3 (Berkeley) 10/11/92 17 * 18 * from: $Header: locore2.c,v 1.7 92/06/20 08:47:28 mccanne Exp $ (LBL) 19 */ 20 21 /* 22 * Primitives which are in locore.s on other machines, 23 * but which have no reason to be assembly-coded on SPARC. 24 */ 25 26 #include <sys/param.h> 27 #include <sys/proc.h> 28 #include <sys/resourcevar.h> 29 30 int whichqs; 31 32 /* 33 * Put process p on the run queue indicated by its priority. 34 * Calls should be made at splstatclock(), and p->p_stat should be SRUN. 35 */ 36 setrq(p) 37 register struct proc *p; 38 { 39 register struct prochd *q; 40 register struct proc *oldlast; 41 register int which = p->p_pri >> 2; 42 43 if (p->p_rlink != NULL) 44 panic("setrq"); 45 q = &qs[which]; 46 whichqs |= 1 << which; 47 p->p_link = (struct proc *)q; 48 p->p_rlink = oldlast = q->ph_rlink; 49 q->ph_rlink = p; 50 oldlast->p_link = p; 51 } 52 53 /* 54 * Remove process p from its run queue, which should be the one 55 * indicated by its priority. Calls should be made at splstatclock(). 56 */ 57 remrq(p) 58 register struct proc *p; 59 { 60 register int which = p->p_pri >> 2; 61 register struct prochd *q; 62 63 if ((whichqs & (1 << which)) == 0) 64 panic("remrq"); 65 p->p_link->p_rlink = p->p_rlink; 66 p->p_rlink->p_link = p->p_link; 67 p->p_rlink = NULL; 68 q = &qs[which]; 69 if (q->ph_link == (struct proc *)q) 70 whichqs &= ~(1 << which); 71 } 72