plan 9 kernel history: overview | file list | diff list

1998/0901/port/proc.c (diff list | history)

1998/0825/sys/src/9/port/proc.c:186,1941998/0901/sys/src/9/port/proc.c:186,194 (short | long | prev | next)
Yet another runproc implementation.
rsc Mon Mar 20 20:36:30 2006
1990/0227    
Proc* 
runproc(void) 
{ 
1995/0110    
	int i; 
	Schedq *rq; 
1998/0901    
	Schedq *rq, *xrq; 
1995/0110    
	Proc *p, *l; 
1998/0901    
	ulong rt; 
1990/0227    
 
loop: 
1995/0110    
 
1998/0825/sys/src/9/port/proc.c:198,2361998/0901/sys/src/9/port/proc.c:198,239
1995/0110    
	 */ 
1992/0603    
	spllo(); 
1995/0912    
	for(;;){ 
1995/0110    
		/* 
1996/0315    
		 *  get lowest priority process that this 
		 *  processor can run given affinity constraints 
		 *  and that hasn't run in a while 
1995/0110    
		 */ 
1998/0606    
		if((m->fairness++ & 3) == 0){ 
1998/0901    
		if((++(m->fairness) & 3) == 0){ 
			/* 
			 *  once in a while, run process that's been waiting longest 
			 *  regardless of movetime 
			 */ 
			rt = 0xffffffff; 
			xrq = nil; 
1995/0110    
			for(rq = runq; rq < &runq[Nrq]; rq++){ 
				p = rq->head; 
1996/0315    
				if(p == 0) 
1995/0110    
					continue; 
1998/0901    
				if(p->readytime < rt){ 
					xrq = rq; 
					rt = p->readytime; 
				} 
			} 
			if(xrq != nil){ 
				rq = xrq; 
				p = rq->head; 
				if(p != nil) 
					p->movetime = 0; 
			} 
		} else { 
			/* 
			 *  get highest priority process that this 
			 *  processor can run given affinity constraints 
			 */ 
			for(rq = &runq[Nrq-1]; rq >= runq; rq--){ 
				p = rq->head; 
				if(p == 0) 
					continue; 
1996/0315    
				for(; p; p = p->rnext){ 
					if(p->mp != MACHP(m->machno)) 
					if(p->movetime >= m->ticks) 
						continue; 
					i = m->ticks - p->readytime; 
					if(i >= 2*nrdy*p->art) 
1998/0901    
					if(p->mp == MACHP(m->machno) 
					|| p->movetime < m->ticks) 
1996/0315    
						goto found; 
				} 
1995/0110    
			} 
		} 
                 
1994/0918    
		/* 
1995/0110    
		 *  get highest priority process that this 
		 *  processor can run given affinity constraints 
1994/0918    
		 */ 
1995/0110    
		for(rq = &runq[Nrq-1]; rq >= runq; rq--){ 
			p = rq->head; 
			if(p == 0) 
				continue; 
			for(; p; p = p->rnext){ 
1996/0315    
				if(p->mp == MACHP(m->machno) 
				|| p->movetime < m->ticks) 
1995/0110    
					goto found; 
			} 
		} 
1994/0729    
	} 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)