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

1992/0701/port/proc.c (diff list | history)

1992/0622/sys/src/9/port/proc.c:326,3511992/0701/sys/src/9/port/proc.c:326,360 (short | long | prev | next)
Take self out of talarm.list if checkalarm didn't. (BUG FIX). Cleaner linked-list manipulation in tsleep.
rsc Mon Mar 20 17:30:39 2006
1992/0602    
tsleep(Rendez *r, int (*fn)(void*), void *arg, int ms) 
1990/0227    
{ 
1992/0602    
	ulong when; 
	Proc *p, *f, **l, **i; 
1992/0701    
	Proc *p, *f, **l; 
1990/0227    
 
1991/0727    
	p = u->p; 
1992/0602    
	when = MS2TK(ms)+MACHP(0)->ticks; 
	i = &talarm.list; 
 
	lock(&talarm); 
1992/0701    
	/* take out of list if checkalarm didn't */ 
	if(p->trend) { 
		l = &talarm.list; 
		for(f = *l; f; f = f->tlink) { 
			if(f == p) { 
				*l = p->tlink; 
				break; 
			} 
			l = &f->tlink; 
		} 
	} 
	/* insert in increasing time order */ 
1992/0602    
	l = &talarm.list; 
	for(f = talarm.list; f; f = f->tlink) { 
		if(f == p) 
			*l = p->tlink; 
		if(f->twhen && f->twhen < when) 
			i = &f->tlink; 
1992/0701    
	for(f = *l; f; f = f->tlink) { 
		if(f->twhen >= when) 
			break; 
1992/0602    
		l = &f->tlink; 
1991/0727    
	} 
1992/0602    
	p->trend = r; 
	p->twhen = when; 
	p->tlink = *i; 
1992/0617    
	p->tfn = fn; 
1992/0602    
	*i = p; 
1992/0701    
	p->tlink = *l; 
	*l = p; 
1992/0602    
	unlock(&talarm); 
 
1992/0617    
	sleep(r, tfn, arg); 


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