1 /* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. 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 Laboratory. 13 * 14 * %sccs.include.redist.c% 15 * 16 * @(#)locore2.c 8.4 (Berkeley) 12/10/93 17 * 18 * from: $Header: locore2.c,v 1.8 92/11/26 03:05:01 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 void 37 setrunqueue(p) 38 register struct proc *p; 39 { 40 register struct prochd *q; 41 register struct proc *oldlast; 42 register int which = p->p_priority >> 2; 43 44 if (p->p_back != NULL) 45 panic("setrunqueue"); 46 q = &qs[which]; 47 whichqs |= 1 << which; 48 p->p_forw = (struct proc *)q; 49 p->p_back = oldlast = q->ph_rlink; 50 q->ph_rlink = p; 51 oldlast->p_forw = p; 52 } 53 54 /* 55 * Remove process p from its run queue, which should be the one 56 * indicated by its priority. Calls should be made at splstatclock(). 57 */ 58 remrq(p) 59 register struct proc *p; 60 { 61 register int which = p->p_priority >> 2; 62 register struct prochd *q; 63 64 if ((whichqs & (1 << which)) == 0) 65 panic("remrq"); 66 p->p_forw->p_back = p->p_back; 67 p->p_back->p_forw = p->p_forw; 68 p->p_back = NULL; 69 q = &qs[which]; 70 if (q->ph_link == (struct proc *)q) 71 whichqs &= ~(1 << which); 72 } 73