From 5307a1cd38d71e1905e8eddab98e2ffe89fce094 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 16 Nov 1990 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1990-11-16 --- gnot/dat.h | 2 +- gnot/devcons.c | 9 +++++- gnot/devdk.c | 18 ++++++++++-- gnot/devincon.c | 9 +++++- gnot/devpipe.c | 2 +- gnot/main.c | 2 +- gnot/stasync.c | 10 ++++++- gnot/stream.c | 77 ++++++++++++++++++++++++++----------------------- gnot/sturp.c | 10 ++++++- port/stasync.c | 10 ++++++- port/stream.c | 11 +++++-- port/sturp.c | 10 ++++++- power/devhs.c | 9 +++++- power/main.c | 2 +- 14 files changed, 130 insertions(+), 51 deletions(-) diff --git a/gnot/dat.h b/gnot/dat.h index 1450b4e184551953f138cd4f6745263e4de5937a..9a88688b32cd894c3b478353b2b47c626b7c0d5f 100644 --- a/gnot/dat.h +++ b/gnot/dat.h @@ -462,7 +462,7 @@ struct Queue { * a stream head */ struct Stream { - Lock; /* structure lock */ + QLock; /* structure lock */ short inuse; /* number of processes in stream */ short opens; /* number of processes with stream open */ ushort hread; /* number of reads after hangup */ diff --git a/gnot/devcons.c b/gnot/devcons.c index a93eb6c1d3a1eee7fe54ab9d9c04c92a551f89c1..c316a6dda2f9d91b0a896e3e9835e0945ff4901e 100644 --- a/gnot/devcons.c +++ b/gnot/devcons.c @@ -83,7 +83,14 @@ static void rs232kproc(void*); static void rs232open(Queue*, Stream*); static void rs232close(Queue*); static void rs232oput(Queue*, Block*); -Qinfo rs232info = { nullput, rs232oput, rs232open, rs232close, "rs232" }; +Qinfo rs232info = +{ + nullput, + rs232oput, + rs232open, + rs232close, + "rs232" +}; void printinit(void) diff --git a/gnot/devdk.c b/gnot/devdk.c index 0727297a45bf67112e3daf70eed3ba2b66d13e5f..dc3721909326f35e658fe70833032ddc7837db05 100644 --- a/gnot/devdk.c +++ b/gnot/devdk.c @@ -202,7 +202,14 @@ static void dkmuxopen(Queue *, Stream *); static void dkmuxclose(Queue *); static void dkmuxoput(Queue *, Block *); static void dkmuxiput(Queue *, Block *); -Qinfo dkmuxinfo = { dkmuxiput, dkmuxoput, dkmuxopen, dkmuxclose, "dkmux" }; +Qinfo dkmuxinfo = +{ + dkmuxiput, + dkmuxoput, + dkmuxopen, + dkmuxclose, + "dkmux" +}; /* * Look for a dk struct with a name. If none exists, create one. @@ -357,7 +364,14 @@ static void dkstopen(Queue *, Stream *); static void dkstclose(Queue *); static void dkoput(Queue *, Block *); static void dkiput(Queue *, Block *); -Qinfo dkinfo = { dkiput, dkoput, dkstopen, dkstclose, "dk" }; +Qinfo dkinfo = +{ + dkiput, + dkoput, + dkstopen, + dkstclose, + "dk" +}; /* * open and save a pointer to the conversation diff --git a/gnot/devincon.c b/gnot/devincon.c index a00c40fc1e575044f0a5993fb65c34d41b30f8a3..13bb806ee20bab07cc049efcf38706dd6fcf7aed 100644 --- a/gnot/devincon.c +++ b/gnot/devincon.c @@ -131,7 +131,14 @@ static void inconkproc(void*); static void inconoput(Queue*, Block*); static void inconstopen(Queue*, Stream*); static void inconstclose(Queue*); -Qinfo inconinfo = { nullput, inconoput, inconstopen, inconstclose, "incon" }; +Qinfo inconinfo = +{ + nullput, + inconoput, + inconstopen, + inconstclose, + "incon" +}; int incondebug; diff --git a/gnot/devpipe.c b/gnot/devpipe.c index db04fb3a7a565a13766283001aa89307acc4f865..404d4a51544bef7ba639d4cf433201137f3c7016 100644 --- a/gnot/devpipe.c +++ b/gnot/devpipe.c @@ -178,7 +178,7 @@ pipeopen(Chan *c, int omode) * pointer from the other stream. */ if(streamenter(local)<0) - panic("pipeopen"); + panic("pipeattach"); } unlock(p); poperror(); diff --git a/gnot/main.c b/gnot/main.c index 1a35571f38a1ba9fb813443d662a23e209c5b107..8e074159bb72a9b6922e3b1d07b95c112883bbed 100644 --- a/gnot/main.c +++ b/gnot/main.c @@ -317,7 +317,7 @@ confinit(void) conf.nmntbuf = 2*conf.nmntdev; conf.nmnthdr = 2*conf.nmntdev; conf.nstream = 40 + 16*mul; /* was 64 */ - conf.nqueue = 4 * conf.nstream; /* was 5 */ + conf.nqueue = 5 * conf.nstream; conf.nblock = 24 * conf.nstream; /* was 32 */ conf.nsrv = 16*mul; /* was 32 */ conf.nbitmap = 300*mul; diff --git a/gnot/stasync.c b/gnot/stasync.c index a4d5d19e4bcc3c65d602a83ad07bdffeafeeb6ba..6f3a5f2a11c86464d75dde8aaa68785a032bfd54 100644 --- a/gnot/stasync.c +++ b/gnot/stasync.c @@ -59,7 +59,15 @@ static void asyncoput(Queue*, Block*); static void asyncopen(Queue*, Stream*); static void asyncclose(Queue*); static void asyncreset(void); -Qinfo asyncinfo = { asynciput, asyncoput, asyncopen, asyncclose, "async", asyncreset }; +Qinfo asyncinfo = +{ + asynciput, + asyncoput, + asyncopen, + asyncclose, + "async", + asyncreset +}; int asyncdebug = 0; int asyncerror; diff --git a/gnot/stream.c b/gnot/stream.c index b089a1a1739187f9d645a16560c87d616c524376..bcd0ff9ad5e969ab136567f77b7bf8cb4b6d6417 100644 --- a/gnot/stream.c +++ b/gnot/stream.c @@ -16,7 +16,14 @@ enum { * process end line discipline */ static void stputq(Queue*, Block*); -Qinfo procinfo = { stputq, nullput, 0, 0, "process" }; +Qinfo procinfo = +{ + stputq, + nullput, + 0, + 0, + "process" +}; /* * line disciplines that can be pushed @@ -645,10 +652,10 @@ streamnew(ushort type, ushort dev, ushort id, Qinfo *qi, int noopen) */ for(s = slist; s < &slist[conf.nstream]; s++) { if(s->inuse == 0){ - if(canlock(s)){ + if(canqlock(s)){ if(s->inuse == 0) break; - unlock(s); + qunlock(s); } } } @@ -657,7 +664,7 @@ streamnew(ushort type, ushort dev, ushort id, Qinfo *qi, int noopen) error(0, Enostream); } if(waserror()){ - unlock(s); + qunlock(s); streamclose1(s); nexterror(); } @@ -690,7 +697,7 @@ streamnew(ushort type, ushort dev, ushort id, Qinfo *qi, int noopen) if(qi->open) (*qi->open)(RD(s->devq), s); - unlock(s); + qunlock(s); poperror(); return s; } @@ -710,17 +717,17 @@ streamopen(Chan *c, Qinfo *qi) for(s = slist; s < &slist[conf.nstream]; s++) { if(s->inuse && s->type == c->type && s->dev == c->dev && s->id == STREAMID(c->qid)){ - lock(s); + qlock(s); if(s->inuse && s->type == c->type && s->dev == c->dev && s->id == STREAMID(c->qid)){ s->inuse++; s->opens++; c->stream = s; - unlock(s); + qunlock(s); return; } - unlock(s); + qunlock(s); } } @@ -737,13 +744,13 @@ streamopen(Chan *c, Qinfo *qi) int streamenter(Stream *s) { - lock(s); + qlock(s); if(s->opens == 0){ - unlock(s); + qunlock(s); return -1; } s->inuse++; - unlock(s); + qunlock(s); return 0; } @@ -760,10 +767,10 @@ streamexit(Stream *s, int locked) char *name; if(!locked) - lock(s); + qlock(s); if(s->inuse == 1){ if(s->opens != 0) - print("streamexit %d %s\n", s->opens, s->devq->info->name); + panic("streamexit %d %s\n", s->opens, s->devq->info->name); /* * ascend the stream freeing the queues @@ -777,7 +784,7 @@ streamexit(Stream *s, int locked) s->inuse--; rv = s->inuse; if(!locked) - unlock(s); + qunlock(s); return rv; } @@ -794,33 +801,33 @@ streamclose1(Stream *s) /* * decrement the reference count */ - lock(s); + qlock(s); if(s->opens == 1){ - if(!waserror()){ - /* - * descend the stream closing the queues - */ - for(q = s->procq; q; q = q->next){ + /* + * descend the stream closing the queues + */ + for(q = s->procq; q; q = q->next){ + if(!waserror()){ if(q->info->close) (*q->info->close)(q->other); WR(q)->put = nullput; - - /* - * this may be 2 streams joined device end to device end - */ - if(q == s->devq->other) - break; } poperror(); + + /* + * this may be 2 streams joined device end to device end + */ + if(q == s->devq->other) + break; } + } - /* - * ascend the stream flushing the queues - */ - for(q = s->devq; q; q = nq){ - nq = q->next; - flushq(q); - } + /* + * ascend the stream flushing the queues + */ + for(q = s->devq; q; q = nq){ + nq = q->next; + flushq(q); } s->opens--; @@ -828,7 +835,7 @@ streamclose1(Stream *s) * leave it and free it */ streamexit(s, 1); - unlock(s); + qunlock(s); } void streamclose(Chan *c) @@ -1006,8 +1013,6 @@ streamread(Chan *c, void *vbuf, long n) * hangup -- send an M_HANGUP up the stream * push ldname -- push the line discipline named ldname * pop -- pop a line discipline - * - * This routing is entrered with s->wrlock'ed and must unlock. */ static long streamctlwrite(Chan *c, void *a, long n) diff --git a/gnot/sturp.c b/gnot/sturp.c index f2eccd03a43ff7b7ed3a3d845a3da878bc3c3004..6f092cc6aff782acf972e0fe4b454c0f52252bb4 100644 --- a/gnot/sturp.c +++ b/gnot/sturp.c @@ -120,7 +120,15 @@ static void urpkproc(void *arg); static void urptimer(Alarm*); static void urpvomit(char*, Urp*); -Qinfo urpinfo = { urpciput, urpoput, urpopen, urpclose, "urp", urpreset }; +Qinfo urpinfo = +{ + urpciput, + urpoput, + urpopen, + urpclose, + "urp", + urpreset +}; static void urpreset(void) diff --git a/port/stasync.c b/port/stasync.c index a4d5d19e4bcc3c65d602a83ad07bdffeafeeb6ba..6f3a5f2a11c86464d75dde8aaa68785a032bfd54 100644 --- a/port/stasync.c +++ b/port/stasync.c @@ -59,7 +59,15 @@ static void asyncoput(Queue*, Block*); static void asyncopen(Queue*, Stream*); static void asyncclose(Queue*); static void asyncreset(void); -Qinfo asyncinfo = { asynciput, asyncoput, asyncopen, asyncclose, "async", asyncreset }; +Qinfo asyncinfo = +{ + asynciput, + asyncoput, + asyncopen, + asyncclose, + "async", + asyncreset +}; int asyncdebug = 0; int asyncerror; diff --git a/port/stream.c b/port/stream.c index b089a1a1739187f9d645a16560c87d616c524376..2a30050163ed89b43ee33d6dfa3b540fda29765d 100644 --- a/port/stream.c +++ b/port/stream.c @@ -16,7 +16,14 @@ enum { * process end line discipline */ static void stputq(Queue*, Block*); -Qinfo procinfo = { stputq, nullput, 0, 0, "process" }; +Qinfo procinfo = +{ + stputq, + nullput, + 0, + 0, + "process" +}; /* * line disciplines that can be pushed @@ -763,7 +770,7 @@ streamexit(Stream *s, int locked) lock(s); if(s->inuse == 1){ if(s->opens != 0) - print("streamexit %d %s\n", s->opens, s->devq->info->name); + panic("streamexit %d %s\n", s->opens, s->devq->info->name); /* * ascend the stream freeing the queues diff --git a/port/sturp.c b/port/sturp.c index f2eccd03a43ff7b7ed3a3d845a3da878bc3c3004..6f092cc6aff782acf972e0fe4b454c0f52252bb4 100644 --- a/port/sturp.c +++ b/port/sturp.c @@ -120,7 +120,15 @@ static void urpkproc(void *arg); static void urptimer(Alarm*); static void urpvomit(char*, Urp*); -Qinfo urpinfo = { urpciput, urpoput, urpopen, urpclose, "urp", urpreset }; +Qinfo urpinfo = +{ + urpciput, + urpoput, + urpopen, + urpclose, + "urp", + urpreset +}; static void urpreset(void) diff --git a/power/devhs.c b/power/devhs.c index 6f9d3f11785ffc44ab436e8c53df23fb562b9979..38b43d614465bcee5d6899a3d35a239ca86941cd 100644 --- a/power/devhs.c +++ b/power/devhs.c @@ -88,7 +88,14 @@ static void hsvmekproc(void*); static void hsvmeoput(Queue*, Block*); static void hsvmestopen(Queue*, Stream*); static void hsvmestclose(Queue*); -Qinfo hsvmeinfo = { nullput, hsvmeoput, hsvmestopen, hsvmestclose, "hsvme" }; +Qinfo hsvmeinfo = +{ + nullput, + hsvmeoput, + hsvmestopen, + hsvmestclose, + "hsvme" +}; /* * restart a VME board diff --git a/power/main.c b/power/main.c index 3a4358f252897857e6299d487bb3deacaca97547..5704b698d575229ac380d9369bdab301388f9efe 100644 --- a/power/main.c +++ b/power/main.c @@ -610,7 +610,7 @@ confinit(void) conf.nenv = 15*conf.nproc; conf.nenvchar = 20 * conf.nenv; conf.npte = 4 * conf.npage; - conf.nqueue = 3 * conf.nstream; + conf.nqueue = 5 * conf.nstream; conf.nblock = 10 * conf.nstream; conf.npipe = conf.nstream/2;