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

1990/0312/port/stream.c (diff list | history)

1990/0312/sys/src/9/port/stream.c:7,121990/0321/sys/src/9/port/stream.c:7,17 (short | long | prev | next)
1990/0227    
#include	"errno.h" 
#include	"devtab.h" 
 
1990/0321    
enum { 
	Nclass=4,	/* number of block classes */ 
	Nlds=32,	/* max number of pushable line disciplines */ 
}; 
 
1990/0312    
/* 
 *  process end line discipline 
 */ 
1990/0312/sys/src/9/port/stream.c:15,371990/0321/sys/src/9/port/stream.c:20,41
1990/0227    
 
1990/0312    
/* 
 *  line disciplines that can be pushed 
 * 
 *  WARNING: this table should be the result of configuration 
 */ 
extern Qinfo noetherinfo; 
extern Qinfo dkmuxinfo; 
extern Qinfo urpinfo; 
1990/0227    
static Qinfo *lds[] = { 
	&noetherinfo, 
1990/0312    
	&dkmuxinfo, 
	&urpinfo, 
1990/0227    
	0 
}; 
1990/0321    
static Qinfo *lds[Nlds+1]; 
1990/0227    
 
enum { 
	Nclass=4, 
}; 
1990/0321    
void 
newqinfo(Qinfo *qi) 
{ 
	int i; 
1990/0227    
 
1990/0321    
	for(i=0; i<Nlds && lds[i]; i++) 
		if(lds[i] == qi) 
			return; 
	if(i == Nlds) 
		panic("pushable"); 
	lds[i] = qi; 
} 
 
1990/0227    
/* 
 *  All stream structures are ialloc'd at boot time 
 */ 
1990/0312/sys/src/9/port/stream.c:52,591990/0321/sys/src/9/port/stream.c:56,63
1990/0227    
} Bclass; 
Bclass bclass[Nclass]={ 
	{ 0 }, 
	{ 64 }, 
	{ 512 }, 
1990/0321    
	{ 68 }, 
	{ 260 }, 
1990/0227    
	{ 4096 }, 
}; 
 
1990/0312/sys/src/9/port/stream.c:89,951990/0321/sys/src/9/port/stream.c:93,98
1990/0227    
	} 
} 
 
                 
/* 
 *  allocate a block 
 */ 
1990/0312/sys/src/9/port/stream.c:170,1761990/0321/sys/src/9/port/stream.c:173,180
1990/0312    
	} 
1990/0227    
	bcp->last = bp; 
	unlock(bcp); 
1990/0312    
	wakeup(&bcp->r); 
1990/0321    
	if(bcp->r.p) 
		wakeup(&bcp->r); 
1990/0227    
} 
 
/* 
1990/0312/sys/src/9/port/stream.c:717,7231990/0321/sys/src/9/port/stream.c:721,727
1990/0227    
void 
stputq(Queue *q, Block *bp) 
{ 
	int i; 
1990/0321    
	int delim; 
1990/0227    
 
	if(bp->type == M_HANGUP){ 
		freeb(bp); 
1990/0312/sys/src/9/port/stream.c:724,7301990/0321/sys/src/9/port/stream.c:728,736
1990/0227    
		q->flag |= QHUNGUP; 
		q->other->flag |= QHUNGUP; 
1990/0312    
		wakeup(&q->other->r); 
1990/0321    
		delim = 1; 
1990/0227    
	} else { 
1990/0321    
		delim = 0; 
1990/0227    
		lock(q); 
		if(q->first) 
			q->last->next = bp; 
1990/0312/sys/src/9/port/stream.c:731,7461990/0321/sys/src/9/port/stream.c:737,757
1990/0227    
		else 
			q->first = bp; 
1990/0312    
		q->len += BLEN(bp); 
1990/0321    
		delim = bp->flags & S_DELIM; 
1990/0312    
		while(bp->next) { 
			bp = bp->next; 
			q->len += BLEN(bp); 
1990/0321    
			delim |= bp->flags & S_DELIM; 
1990/0312    
		} 
1990/0227    
		q->last = bp; 
		if(q->len >= Streamhi) 
1990/0321    
		if(q->len >= Streamhi){ 
1990/0227    
			q->flag |= QHIWAT; 
1990/0321    
			delim = 1; 
		} 
1990/0227    
		unlock(q); 
	} 
	wakeup(&q->r); 
1990/0321    
	if(delim) 
		wakeup(&q->r); 
1990/0227    
} 
 
/* 


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