From 9fans@cse.psu.edu Wed Sep 20 11:17:15 EDT 1995
Article: 330 of comp.os.plan9
Xref: cannon.ecf comp.os.plan9:330
Newsgroups: comp.os.plan9
Path: cannon.ecf!utnut!cs.utexas.edu!news.sprintlink.net!newsfeed.internetmci.com!tank.news.pipex.net!pipex!warwick!niss!bath.ac.uk!ccsis
From: presotto@plan9.ATt.COM
Subject: dirfstat on tcp/udp/il connections is always 0
Message-ID: <95Sep16.110531edt.78376@colossus.cse.psu.edu>
Sender: ccsis@bath.ac.uk (Icarus Sparry)
Reply-To: 9fans@cse.psu.edu
Organization: Plan 9 mailing list
Date: Sat, 16 Sep 1995 06:53:02 GMT
Approved: plan9mod@bath.ac.uk
Lines: 62
Status: RO

Since dirfstat returns the size of the next message queued
for reading for pipes, it would be nice if the same happened
for IP protocols.  The following changes make it work.
Note that dirstat will still return 0 (the stream gets bound
to the fd on open...).

--------------------------------------------
In port/stream.c, replace streamstat() with:
--------------------------------------------

ulong
streamlen(Chan *c)
{
	Stream *s;
	Queue *q;
	Block *bp;
	ulong n;

	s = c->stream;
	n = 0;
	if(s) {
		q = RD(s->procq);
		if(q->flag & QHUNGUP)
			error(Ehungup);
		lock(q);
		for(bp=q->first; bp; bp = bp->next){
			n += BLEN(bp);
			if(bp->flags&S_DELIM)
				break;
		}
		unlock(q);
	}
	return n;
}
void
streamstat(Chan *c, char *db, char *name, long perm)
{
	Dir dir;

	devdir(c, c->qid, name, streamlen(c), eve, perm, &dir);
	convD2M(&dir, db);
}

--------------------------------------------
In port/net.c
--------------------------------------------

% diff net.c $old/net.c
93c93
< 		devdir(c, q, "data", streamlen(c), o, perm, dp);
---
> 		devdir(c, q, "data", 0, o, perm, dp);

--------------------------------------------
In port/portfns.h
--------------------------------------------

% diff portfns.h $old/portfns.h
267d266
< ulong		streamlen(Chan*);




From cse.psu.edu!9fans-outgoing-owner Mon Feb  5 10:55:59 1996
Received: from colossus.cse.psu.edu ([130.203.1.2]) by cannon.ecf.toronto.edu with SMTP id <4839>; Mon, 5 Feb 1996 10:55:58 -0500
Received: by colossus.cse.psu.edu id <78439>; Mon, 5 Feb 1996 10:27:34 -0500
Received: from ns.dbSystems.com ([204.181.117.1]) by colossus.cse.psu.edu with SMTP id <78400>; Mon, 5 Feb 1996 10:13:10 -0500
Received: (from gdb@localhost) by ns.dbSystems.com (8.6.11/8.6.9) id BAA00398 for 9fans@cse.psu.edu; Mon, 5 Feb 1996 01:58:04 -0600
Date:	Mon, 5 Feb 1996 02:58:04 -0500
From:	"G. David Butler" <gdb@dbSystems.com>
Message-Id: <199602050758.BAA00398@ns.dbSystems.com>
To:	9fans@cse.psu.edu
Subject: Kernel <-> bitmapped memory fragmentation
Sender: owner-9fans@cse.psu.edu
Precedence: bulk
Reply-To: 9fans@cse.psu.edu
Status: RO

Hello All!

Ever notice (especially on small memory machines) how after a while
you can't make those 8 1/2 window as big as you used to?  Or how
you were able to display that graphic before you did a move or resize
on a window?  Even after you delete all the windows and re-create them
you just can't get it back unless you reboot?

Well here is a quick fix.  I changed the "first" fit xalloc into a "better"
fit xalloc.  In this way the xalloc memory will not become as fragmented
so when that bit device wants his "3 screens full", he can still get it
after he let it go.

David Butler
gdb@dbSystems.com

======================= alloc.c boddle =======================
#!/bin/rc
#
# command: /bin/boddle /sys/src/9/port/alloc.c alloc.c
# srcdir: /sys/src/9/port
# version: 823506923
# date: Mon Feb 5 01:55:23 CST 1996
#
myname=$0
doextract=no

fn usage{
	echo $myname: usage: $myname '[-X] [src-directory]' >[1=2]
	exit usage
}

fn sigint{
	rm -rf 823506923
	exit interrupt
}

while(~ $1 -*){
	switch($1){
	case -X
		doextract=yes
	case -*
		usage
	}
	shift
}

switch($#*){
case 0
	srcdir=/sys/src/9/port
case 1
	srcdir=$1
case *
	usage
}

if(! ~ $doextract yes){
	echo This shell file contains a bundle of diffs representing changes
	echo to original source files in the Plan 9 distribution. It will run
	echo against the files in
	echo ' ' $srcdir
	echo '(unless overridden by the optional source directory argument)'
	echo and create a directory 823506923 containing the updated files.
	echo It will NOT automatically update the original files.
	echo
	echo Invoke with argument -X to perform the actual extraction.
	exit 0
}

rm -rf 823506923
mkdir 823506923

target=823506923/alloc.c
echo -n '823506923/alloc.c: '
if(! test -f $srcdir/alloc.c || ! test -r $srcdir/alloc.c){
	echo $srcdir/alloc.c unreadable
	exit unreadable
}
sum=`{sum < $srcdir/alloc.c}
if(! ~ 8e1aa10a7934  $sum(1)^$sum(2)){
	echo $srcdir/alloc.c is not the original distribution file
	exit original
}
cp $srcdir/alloc.c 823506923/alloc.c
ed 823506923/alloc.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM alloc.c'
193c
	}

	if (sh) {
		p = (Xhdr*)sh->addr;
		sh->addr += size;
		sh->size -= size;
		if(sh->size == 0) {
			*sl = sh->link;
			sh->link = xlists.flist;
			xlists.flist = sh;
		}
		unlock(&xlists);
		p = KADDR(p);
		memset(p, 0, size);
		p->magix = Magichole;
		p->size = size;
		return p->data;
.
176,191c
	sh = (Hole *)nil;
	SET(sl);
	SET(smallest);
	for(h = *l; h; l = &h->link, h = h->link) {
		if (h->size >= size && (!sh || h->size < smallest)) {
			smallest = h->size;
			sh = h;
			sl = l;
.
169c
	Hole *h, **l, *sh, **sl;
	ulong smallest;
.
10c
 * Plan 9 has two kernel allocators, the x... routines provide a best
.
wq
//GO.SYSIN DD VADIM alloc.c
sum=`{sum < 823506923/alloc.c}
if(~ 44c9fb008090  $sum(1)^$sum(2))
	echo
if not{
	echo 823506923/alloc.c checksum error creating updated file
	exit checksum
}


From cse.psu.edu!9fans-outgoing-owner Tue Feb  6 12:12:48 1996
Received: from colossus.cse.psu.edu ([130.203.1.2]) by cannon.ecf.toronto.edu with SMTP id <10408>; Tue, 6 Feb 1996 12:12:38 -0500
Received: by colossus.cse.psu.edu id <78351>; Tue, 6 Feb 1996 11:45:08 -0500
Received: from plan9.att.com ([192.20.225.253]) by colossus.cse.psu.edu with SMTP id <78370>; Tue, 6 Feb 1996 11:39:56 -0500
From:	philw@plan9.att.com
To:	9fans@cse.psu.edu
Date:	Tue, 6 Feb 1996 04:57:34 -0500
Subject: re: exec(2) problem?
Message-Id: <96Feb6.113956est.78370@colossus.cse.psu.edu>
Sender: owner-9fans@cse.psu.edu
Precedence: bulk
Reply-To: 9fans@cse.psu.edu
Status: RO

It's a problem, imagereclaim should not call sleep.
change segment.c:228 from resrcwait(0) to sched().
This will prevent races cleaning the cache but
still allow things to proceed. I looked at the
other potentially sleeping things (close, fdclose)
and they seem ok because there is a waserror
on close which prevents the error from propagating
back to exec.

Diff's from the CD:

diff /n/juke/plan_9/sys/src/9/port/segment.c /sys/src/9/port:

228c228
< 		resrcwait(0);
---
> 		sched();


From cse.psu.edu!owner-9fans Thu Oct 17 11:03:22 1996
Received: from cse.psu.edu ([130.203.3.50]) by cannon.ecf.toronto.edu with SMTP id <11976>; Thu, 17 Oct 1996 11:03:18 -0400
Received: from localhost (majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) with SMTP id LAA29014; Thu, 17 Oct 1996 11:02:53 -0400 (EDT)
Received: by claven.cse.psu.edu (bulk_mailer v1.5); Thu, 17 Oct 1996 11:02:40 -0400
Received: (from majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) id LAA28935 for 9fans-outgoing; Thu, 17 Oct 1996 11:02:09 -0400 (EDT)
X-Authentication-Warning: claven.cse.psu.edu: majordom set sender to owner-9fans using -f
Received: from plan9.cs.bell-labs.com (plan9.bell-labs.com [204.178.16.2]) by cse.psu.edu (8.7.5/8.7.3) with SMTP id LAA28923 for <9fans@cse.psu.edu>; Thu, 17 Oct 1996 11:01:50 -0400 (EDT)
From:	presotto@plan9.bell-labs.com
Message-Id: <199610171501.LAA28923@cse.psu.edu>
To:	9fans@cse.psu.edu
Date:	Thu, 17 Oct 1996 10:56:13 -0400
Sender: owner-9fans@cse.psu.edu
Reply-To: 9fans@cse.psu.edu
Precedence: bulk
Status: RO

Ncube has had problems with the fact that proc.c requires all
Rendez structures to not be reallocatable, i.e., they can't
exist on stacks or in objects that are freed.  If anyone cares,
I have a rewrite of sleep/wakeup that gets around that.
The shipped kernel should be clean this way so that it shouldn't
be a problem to anyone that hasn't been hacking hard.

They also found a neat bug in pexit().  Move the unlock on line
691 to after the wakeup.  Otherwise you can blow up indirecting
through a null reference.

			p->nwait++;
			unlock(&p->exl);

			wakeup(&p->waitr);

goes to

			p->nwait++;

			wakeup(&p->waitr);
			unlock(&p->exl);

From cse.psu.edu!owner-9fans Thu Oct 17 17:12:12 1996
Received: from cse.psu.edu ([130.203.3.50]) by cannon.ecf.toronto.edu with SMTP id <12053>; Thu, 17 Oct 1996 17:12:04 -0400
Received: from localhost (majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) with SMTP id RAA06402; Thu, 17 Oct 1996 17:10:12 -0400 (EDT)
Received: by claven.cse.psu.edu (bulk_mailer v1.5); Thu, 17 Oct 1996 17:09:09 -0400
Received: (from majordom@localhost) by cse.psu.edu (8.7.5/8.7.3) id RAA06348 for 9fans-outgoing; Thu, 17 Oct 1996 17:09:02 -0400 (EDT)
X-Authentication-Warning: claven.cse.psu.edu: majordom set sender to owner-9fans using -f
Received: from plan9.cs.bell-labs.com (plan9.bell-labs.com [204.178.16.2]) by cse.psu.edu (8.7.5/8.7.3) with SMTP id RAA06344 for <9fans@cse.psu.edu>; Thu, 17 Oct 1996 17:08:57 -0400 (EDT)
From:	presotto@plan9.bell-labs.com
Message-Id: <199610172108.RAA06344@cse.psu.edu>
To:	9fans@cse.psu.edu
Date:	Thu, 17 Oct 1996 17:08:32 -0400
Sender: owner-9fans@cse.psu.edu
Reply-To: 9fans@cse.psu.edu
Precedence: bulk
Status: R

I put the sleep/wakeup changed and the pexit fix
from ncube in 

http://plan9.bell-labs.com/plan9/update/9/port/845586056.rc
and
http://plan9.bell-labs.com/plan9/update/9/port/845586092.rc

these changes to pertain to everyone.

From 9fans@cse.psu.edu Thu Oct 24 15:39:40 EDT 1996
Article: 1990 of comp.os.plan9
Xref: info.ecf comp.os.plan9:1990
Newsgroups: comp.os.plan9
Path: info.ecf!utnut!cs.utexas.edu!howland.erols.net!EU.net!usenet2.news.uk.psi.net!uknet!usenet1.news.uk.psi.net!uknet!uknet!yama.mcc.ac.uk!news.salford.ac.uk!aber!bath.ac.uk!ccsis
From: presotto@plan9.bell-labs.com
Subject: (none)
Approved: plan9mod@bath.ac.uk
Reply-To: 9fans@cse.psu.edu
Sender: ccsis@bath.ac.uk (Icarus Sparry)
Organization: Plan 9 mailing list
Message-ID: <199610172108.RAA06344@cse.psu.edu>
Date: Thu, 17 Oct 1996 21:12:15 GMT
Lines: 8

I put the sleep/wakeup changed and the pexit fix
>from  ncube in 

http://plan9.bell-labs.com/plan9/update/9/port/845586056.rc
and
http://plan9.bell-labs.com/plan9/update/9/port/845586092.rc

these changes to pertain to everyone.


