From 73aa6a9430656ae5fc0c3edc2f264479fd9db2b5 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 1 Jan 1995 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1995-01-01 --- port/portdat.h | 1 + port/proc.c | 5 +++-- port/qio.c | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/port/portdat.h b/port/portdat.h index f7ba3f2af15a60e19276ed7708532161fcbbfe19..518de559a863001135a12ff69563e99231045424 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -132,6 +132,7 @@ struct Block uchar* wp; /* first empty byte */ uchar* lim; /* 1 past the end of the buffer */ uchar* base; /* start of the buffer */ + void (*free)(Block*); ulong flag; }; #define BLEN(s) ((s)->wp - (s)->rp) diff --git a/port/proc.c b/port/proc.c index f5967e0ab8275073df1a4bd49b7bb15e25f7d75c..d3ca0d6baeab6a3d78c158494fb975be5256ace3 100644 --- a/port/proc.c +++ b/port/proc.c @@ -216,9 +216,10 @@ loop: * processor can run given affinity constraints */ for(rq = &runq[Nrq-1]; rq >= runq; rq--){ - if(rq->head == 0) + p = rq->head; + if(p == 0) continue; - for(p = rq->head; p; p = p->rnext){ + for(; p; p = p->rnext){ if(p->mp == m || m->ticks - p->movetime > HZ/2) goto found; } diff --git a/port/qio.c b/port/qio.c index 7d8af518208df91c2226ca311a0250f00416712f..6d2eda17a0f971a3369c5396955669d01a3c0f8a 100644 --- a/port/qio.c +++ b/port/qio.c @@ -109,6 +109,14 @@ iallocb(int size) void freeb(Block *b) { + /* + * drivers which perform non cache coherent DMA manage their + * own buffer pools, so they provide their own free routines. + */ + if(b->free) { + b->free(b); + return; + } if(b->flag & BINTR) { ilock(&ialloc); ialloc.bytes -= b->lim - b->base;