From fc05fe1582e53e114a5fd41bd80f043e472670b8 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 2 Oct 1991 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1991-10-02 --- pc/vga.c | 2 +- port/devlance.c | 2 -- port/portdat.h | 4 ++-- port/qlock.c | 51 ++++++++++++++++++++++++++----------------------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/pc/vga.c b/pc/vga.c index 92301d73e89d423bfb500d9583692bb90a87b8e0..fc5cab769e61e886124cd791323f268c480c9e9e 100644 --- a/pc/vga.c +++ b/pc/vga.c @@ -159,7 +159,7 @@ vga1(void) crout(Cmode, 0xe3); /* turn off address wrap & * word mode */ crout(Cmsl, 0x40); /* 1 pixel per scan line */ - crout(Cvertend, MAXY); /* 480 lne display */ + crout(Cvertend, MAXY-1); /* 480 lne display */ srout(Smode, 0x06); /* extended memory, * odd/even off */ srout(Sclock, 0x01); /* 8 bits/char */ diff --git a/port/devlance.c b/port/devlance.c index 9a48e1816eabb6ca1e3fd095f008840cfc8a6e51..b357e7a1c684f639deaa68c5fc7d61ec0b34540b 100644 --- a/port/devlance.c +++ b/port/devlance.c @@ -241,8 +241,6 @@ lancestclose(Queue *q) } /* - * assume the q is locked external to this routine - * * the ``connect'' control message specifyies the type */ Proc *lanceout; diff --git a/port/portdat.h b/port/portdat.h index 9102428b6964c1a6f890e9937049d3bcd9cdfb7c..65566b1c78e3c296beff76d8def9aade0778283e 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -53,10 +53,10 @@ struct Rendez struct QLock { + Lock use; /* to use object */ Proc *head; /* next process waiting for object */ Proc *tail; /* last process waiting for object */ - Lock use; /* to use object */ - Lock queue; /* to access list */ + int locked; /* flag */ }; struct Alarm diff --git a/port/qlock.c b/port/qlock.c index 5dceace5faba4e34496d0e28f8e68b4e1b17867c..44fdf50ed50f99585a16e38405b3fbb4f01d2638 100644 --- a/port/qlock.c +++ b/port/qlock.c @@ -8,34 +8,38 @@ void qlock(QLock *q) { - Proc *p; + Proc *p, *mp; - if(canlock(&q->use)) - return; - lock(&q->queue); - if(canlock(&q->use)){ - unlock(&q->queue); + lock(&q->use); + if(!q->locked) { + q->locked = 1; + unlock(&q->use); return; } - if(u == 0) - panic("qlock"); p = q->tail; + mp = u->p; if(p == 0) - q->head = u->p; + q->head = mp; else - p->qnext = u->p; - q->tail = u->p; - u->p->qnext = 0; - u->p->state = Queueing; -/* u->p->qlock = q; /* DEBUG */ - unlock(&q->queue); + p->qnext = mp; + q->tail = mp; + mp->qnext = 0; + mp->state = Queueing; + unlock(&q->use); sched(); } int canqlock(QLock *q) { - return canlock(&q->use); + lock(&q->use); + if(q->locked) { + unlock(&q->use); + return 0; + } + q->locked = 1; + unlock(&q->use); + return 1; } void @@ -43,17 +47,16 @@ qunlock(QLock *q) { Proc *p; - lock(&q->queue); -/* u->p->qlock = 0; /* DEBUG */ - if(q->head){ - p = q->head; + lock(&q->use); + p = q->head; + if(p) { q->head = p->qnext; if(q->head == 0) q->tail = 0; - unlock(&q->queue); - ready(p); - }else{ unlock(&q->use); - unlock(&q->queue); + ready(p); + return; } + q->locked = 0; + unlock(&q->use); }