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

1991/0420/port/proc.c (diff list | history)

1991/0318/sys/src/9/port/proc.c:18,301991/0420/sys/src/9/port/proc.c:18,32 (short | long | prev | next)
Split runq into runhiq, runloq. Spell sleaze correctly.
rsc Mon Mar 20 17:14:09 2006
1990/0227    
	Proc	*free; 
}procalloc; 
 
struct 
1991/0420    
typedef struct 
1990/0227    
{ 
	Lock; 
	Proc	*head; 
	Proc	*tail; 
}runq; 
1991/0420    
}Schedq; 
1990/0227    
 
1991/0420    
Schedq runhiq, runloq; 
 
1990/0227    
char *statename[]={	/* BUG: generate automatically */ 
	"Dead", 
	"Moribund", 
1991/0318/sys/src/9/port/proc.c:75,811991/0420/sys/src/9/port/proc.c:77,83
1990/0227    
void 
sched(void) 
{ 
1990/1211    
	uchar procstate[64];		/* sleeze for portability */ 
1991/0420    
	uchar procstate[64];		/* sleaze for portability */ 
1990/0227    
	Proc *p; 
	ulong tlbvirt, tlbphys; 
1990/0731    
	void (*f)(ulong, ulong); 
1991/0318/sys/src/9/port/proc.c:104,1271991/0420/sys/src/9/port/proc.c:106,136
1990/1227    
int 
anyready(void) 
{ 
	return runq.head != 0; 
1991/0420    
	return runloq.head != 0 || runhiq.head != 0; 
1990/1227    
} 
 
1990/0227    
void 
ready(Proc *p) 
{ 
1991/0420    
	Schedq *rq; 
1990/0227    
	int s; 
 
	s = splhi(); 
	lock(&runq); 
1991/0420    
	if(p->state == Running) 
		rq = &runloq; 
	else 
		rq = &runhiq; 
 
	lock(&runhiq); 
1990/0227    
	p->rnext = 0; 
	if(runq.tail) 
		runq.tail->rnext = p; 
1991/0420    
	if(rq->tail) 
		rq->tail->rnext = p; 
1990/0227    
	else 
		runq.head = p; 
	runq.tail = p; 
1991/0420    
		rq->head = p; 
	rq->tail = p; 
 
1990/0227    
	p->state = Ready; 
	unlock(&runq); 
1991/0420    
	unlock(&runhiq); 
1990/0227    
	splx(s); 
} 
 
1991/0318/sys/src/9/port/proc.c:131,1571991/0420/sys/src/9/port/proc.c:140,172
1990/0227    
Proc* 
runproc(void) 
{ 
1991/0420    
	Schedq *rq; 
1990/0227    
	Proc *p; 
	int i; 
 
loop: 
	while(runq.head == 0) 
1991/0420    
	while(runhiq.head==0 && runloq.head==0) 
1990/1211    
		for(i=0; i<10; i++)	/* keep out of shared memory for a while */ 
1990/0227    
			; 
	splhi(); 
	lock(&runq); 
	p = runq.head; 
1991/0420    
	lock(&runhiq); 
	if(runhiq.head) 
		rq = &runhiq; 
	else 
		rq = &runloq; 
 
	p = rq->head; 
1990/0227    
	if(p==0 || p->mach){	/* p->mach==0 only when process state is saved */ 
		unlock(&runq); 
1991/0420    
		unlock(&runhiq); 
1990/0227    
		spllo(); 
		goto loop; 
	} 
	if(p->rnext == 0) 
		runq.tail = 0; 
	runq.head = p->rnext; 
1991/0420    
		rq->tail = 0; 
	rq->head = p->rnext; 
1990/0227    
	if(p->state != Ready) 
		print("runproc %s %d %s\n", p->text, p->pid, statename[p->state]); 
	unlock(&runq); 
1991/0420    
	unlock(&runhiq); 
1990/0227    
	p->state = Scheding; 
	spllo(); 
	return p; 


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