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

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

1991/1109/sys/src/9/port/proc.c:213,2541991/1110/sys/src/9/port/proc.c:213,249 (short | long | prev | next)
Rewrite goto in newproc as for loop. Call resrcwait instead of manual sleeping. Add traceme proc ctl message.
rsc Mon Mar 20 17:30:36 2006
1990/0227    
{ 
	Proc *p; 
 
loop: 
	lock(&procalloc); 
	if(p = procalloc.free){		/* assign = */ 
		procalloc.free = p->qnext; 
1991/0926    
		p->state = Scheding; 
		p->psstate = "New"; 
1991/1110    
	for(;;) { 
		lock(&procalloc); 
		if(p = procalloc.free){		/* assign = */ 
			procalloc.free = p->qnext; 
			p->state = Scheding; 
			p->psstate = "New"; 
			unlock(&procalloc); 
			p->mach = 0; 
			p->qnext = 0; 
			p->nchild = 0; 
			p->nwait = 0; 
			p->waitq = 0; 
			p->pgrp = 0; 
			p->egrp = 0; 
			p->fgrp = 0; 
			p->pdbg = 0; 
			p->fpstate = FPinit; 
			p->kp = 0; 
			p->procctl = 0; 
			p->notepending = 0; 
			memset(p->seg, 0, sizeof p->seg); 
			lock(&pidalloc); 
			p->pid = ++pidalloc.pid; 
			unlock(&pidalloc); 
			if(p->pid == 0) 
				panic("pidalloc"); 
			return p; 
		} 
1990/0227    
		unlock(&procalloc); 
		p->mach = 0; 
		p->qnext = 0; 
		p->nchild = 0; 
1991/0926    
		p->nwait = 0; 
		p->waitq = 0; 
1991/0317    
		p->pgrp = 0; 
1991/0705    
		p->egrp = 0; 
		p->fgrp = 0; 
1991/1109    
		p->procmode = 0644; 
1990/0722    
		p->fpstate = FPinit; 
1991/0425    
		p->kp = 0; 
1991/0705    
		p->procctl = 0; 
1991/0727    
		p->notepending = 0; 
1990/0227    
		memset(p->seg, 0, sizeof p->seg); 
		lock(&pidalloc); 
		p->pid = ++pidalloc.pid; 
		unlock(&pidalloc); 
		if(p->pid == 0) 
			panic("pidalloc"); 
		return p; 
1991/1110    
		resrcwait("no procs"); 
1990/0227    
	} 
	unlock(&procalloc); 
	print("no procs\n"); 
	if(u == 0) 
		panic("newproc"); 
1990/0619    
	u->p->state = Wakeme; 
1990/0227    
	alarm(1000, wakeme, u->p); 
	sched(); 
	goto loop; 
} 
 
void 
1991/1109/sys/src/9/port/proc.c:584,5911991/1110/sys/src/9/port/proc.c:579,592
1991/0705    
	/* 
	 * sched() cannot wait on these locks 
	 */ 
	lock(&procalloc); 
	lock(&c->debug); 
1991/1110    
	/* release debuggers */ 
	if(c->pdbg) { 
		wakeup(&c->pdbg->sleep); 
		c->pdbg = 0; 
	} 
 
	lock(&procalloc); 
1991/0705    
	lock(&palloc); 
 
1990/03081    
	c->state = Moribund; 
1991/1109/sys/src/9/port/proc.c:740,7501991/1110/sys/src/9/port/proc.c:741,761
1991/0705    
	switch(p->procctl) { 
	case Proc_exitme: 
		pexit("Killed", 1); 
1991/1110    
	case Proc_traceme: 
		if(u->nnote == 0) 
			return; 
		/* No break */ 
1991/0705    
	case Proc_stopme: 
		p->procctl = 0; 
1991/1108    
		state = p->psstate; 
		p->psstate = "Stopped"; 
                 
1991/1110    
		/* free a waiting debugger */ 
		lock(&p->debug); 
		if(p->pdbg) { 
			wakeup(&p->pdbg->sleep); 
			p->pdbg = 0; 
		} 
		unlock(&p->debug); 
1991/0705    
		p->state = Stopped; 
		sched(); 
1991/1108    
		p->psstate = state; 


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