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

2002/1011/port/qio.c (diff list | history)

2002/0714/sys/src/9/port/qio.c:405,4142002/1011/sys/src/9/port/qio.c:405,414 (short | long | prev | next)
1997/0327    
	ilock(q); 
1995/0902    
 
1997/0327    
	b = q->bfirst; 
	if(b == 0){ 
2002/1011    
	if(b == nil){ 
1997/0327    
		q->state |= Qstarve; 
		iunlock(q); 
		return 0; 
2002/1011    
		return nil; 
1997/0327    
	} 
	q->bfirst = b->next; 
	b->next = 0; 
2002/0714/sys/src/9/port/qio.c:484,4892002/1011/sys/src/9/port/qio.c:484,525
2001/0306    
	return sofar; 
1993/0526    
} 
 
2002/1011    
long 
qblen(Queue *q) 
{ 
	Block *b; 
	int n; 
	Block *tofree = nil; 
 
	ilock(q); 
 
	for(;;) { 
		b = q->bfirst; 
		if(b == 0){ 
			q->state |= Qstarve; 
			iunlock(q); 
			return -1; 
		} 
		QDEBUG checkb(b, "qblen 1"); 
 
		n = BLEN(b); 
		if(n > 0) 
			break; 
		q->bfirst = b->next; 
		q->len -= BALLOC(b); 
 
		/* remember to free this */ 
		b->next = tofree; 
		tofree = b; 
	}; 
	iunlock(q); 
 
	if(tofree != nil) 
		freeblist(tofree); 
 
	return len; 
} 
 
1993/0526    
/* 
1994/0322    
 *  Interrupt level copy out of a queue, return # bytes copied. 
1993/0526    
 */ 
2002/0714/sys/src/9/port/qio.c:522,5342002/1011/sys/src/9/port/qio.c:558,569
1993/0526    
		len = n; 
	memmove(p, b->rp, len); 
1997/0327    
	consumecnt += n; 
1993/0527    
	if((q->state & Qmsg) || len == n) 
1993/0526    
		q->bfirst = b->next; 
1994/0222    
	b->rp += len; 
1998/0922    
	q->dlen -= len; 
1993/0526    
 
1999/0115    
	/* discard the block if we're done with it */ 
	if((q->state & Qmsg) || len == n){ 
2002/1011    
		q->bfirst = b->next; 
1999/0115    
		b->next = 0; 
		q->len -= BALLOC(b); 
		q->dlen -= BLEN(b); 


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