~kris/9p

9hist

3f85b6589809fc7d9f674dd73f26bbf641d90ef2 — David du Colombier 27 years ago 73ac58f
Plan 9 from Bell Labs 1999-01-15
2 files changed, 47 insertions(+), 16 deletions(-)

M port/qio.c
M port/swap.c
M port/qio.c => port/qio.c +29 -16
@@ 590,6 590,7 @@ qconsume(Queue *q, void *vp, int len)
	Block *b;
	int n, dowakeup;
	uchar *p = vp;
	Block *tofree = nil;

	/* sync with qwrite */
	ilock(q);


@@ 608,7 609,10 @@ qconsume(Queue *q, void *vp, int len)
			break;
		q->bfirst = b->next;
		q->len -= BALLOC(b);
		freeb(b);

		/* remember to free this */
		b->next = tofree;
		tofree = b;
	};

	if(n < len)


@@ 620,6 624,17 @@ qconsume(Queue *q, void *vp, int len)
	b->rp += len;
	q->dlen -= len;

	/* discard the block if we're done with it */
	if((q->state & Qmsg) || len == n){
		b->next = 0;
		q->len -= BALLOC(b);
		q->dlen -= BLEN(b);

		/* remember to free this */
		b->next = tofree;
		tofree = b;
	}

	/* if writer flow controlled, restart */
	if((q->state & Qflow) && q->len < q->limit/2){
		q->state &= ~Qflow;


@@ 632,14 647,9 @@ qconsume(Queue *q, void *vp, int len)
	if(dowakeup)
		wakeup(&q->wr);

	QDEBUG checkb(b, "qconsume 2");
	/* discard the block if we're done with it */
	if((q->state & Qmsg) || len == n){
		b->next = 0;
		q->len -= BALLOC(b);
		q->dlen -= BLEN(b);
		freeb(b);
	}
	if(tofree != nil)
		freeblist(tofree);

	return len;
}



@@ 798,6 808,9 @@ qproduce(Queue *q, void *vp, int len)
		q->state &= ~Qstarve;
		dowakeup = 1;
	}

	if(q->len >= q->limit)
		q->state |= Qflow;
	iunlock(q);

	if(dowakeup)


@@ 938,13 951,6 @@ qbread(Queue *q, int len)
	q->len -= BALLOC(b);
	QDEBUG checkb(b, "qbread 1");

	/* if writer flow controlled, restart */
	if((q->state & Qflow) && q->len < q->limit/2){
		q->state &= ~Qflow;
		dowakeup = 1;
	} else
		dowakeup = 0;

	/* split block if it's too big and this is not a message-oriented queue */
	nb = b;
	if(n > len){


@@ 967,6 973,13 @@ qbread(Queue *q, int len)
		nb->wp = nb->rp + len;
	}

	/* if writer flow controlled, restart */
	if((q->state & Qflow) && q->len < q->limit/2){
		q->state &= ~Qflow;
		dowakeup = 1;
	} else
		dowakeup = 0;

	iunlock(q);

	/* wakeup flow controlled writers */

M port/swap.c => port/swap.c +18 -0
@@ 369,6 369,9 @@ needpages(void*)
void
setswapchan(Chan *c)
{
	char dirbuf[DIRLEN];
	Dir d;

	if(swapimage.c) {
		if(swapalloc.free != conf.nswap){
			cclose(c);


@@ 376,5 379,20 @@ setswapchan(Chan *c)
		}
		cclose(swapimage.c);
	}

	/*
	 *  if this isn't a file, set the swap space
	 *  to be at most the size of the partition
	 */
	if(devtab[c->type]->dc != L'M'){
		devtab[c->type]->stat(c, dirbuf);
		convM2D(dirbuf, &d);
		if(d.length < conf.nswap*BY2PG){
			conf.nswap = d.length/BY2PG;
			swapalloc.top = &swapalloc.swmap[conf.nswap];
			swapalloc.free = conf.nswap;
		}
	}

	swapimage.c = c;
}