| plan 9 kernel history: overview | file list | diff list |
1993/0530/port/qio.c (diff list | history)
| 1993/0528/sys/src/9/port/qio.c:5,10 – 1993/0530/sys/src/9/port/qio.c:5,13 (short | long | prev | next) | ||
| 1993/0526 | #include "fns.h" #include "../port/error.h" | |
| 1993/0530 | /* * interrupt level memory allocation */ | |
| 1993/0526 | typedef struct Chunk Chunk; typedef struct Chunkl Chunkl; typedef struct Arena Arena; | |
| 1993/0528/sys/src/9/port/qio.c:39,44 – 1993/0530/sys/src/9/port/qio.c:42,97 | ||
| 1993/0526 | static Arena arena; /* | |
| 1993/0530 | * IO queues */ typedef struct Block Block; typedef struct Queue Queue; struct Block { Block *next; uchar *rp; /* first unconsumed byte */ uchar *wp; /* first empty byte */ uchar *lim; /* 1 past the end of the buffer */ uchar *base; /* start of the buffer */ uchar flag; }; #define BLEN(b) ((b)->wp - (b)->rp) struct Queue { Lock; Block *bfirst; /* buffer */ Block *blast; int len; /* bytes in queue */ int limit; /* max bytes in queue */ int state; void (*kick)(void*); /* restart output */ void *arg; /* argument to kick */ QLock rlock; /* mutex for reading processes */ Rendez rr; /* process waiting to read */ QLock wlock; /* mutex for writing processes */ Rendez wr; /* process waiting to write */ }; enum { /* Block.flag */ Bfilled=1, /* block filled */ /* Queue.state */ Qstarve= (1<<0), /* consumer starved */ Qmsg= (1<<1), /* message stream */ Qclosed= (1<<2), Qflow= (1<<3), }; /* | |
| 1993/0526 | * Manage interrupt level memory allocation. */ static void | |
| 1993/0528/sys/src/9/port/qio.c:297,303 – 1993/0530/sys/src/9/port/qio.c:350,356 | ||
| 1993/0526 | * called by non-interrupt code */ Queue* | |
| 1993/0530 | qopen(int limit, int msg, void (*kick)(void*), void *arg) | |
| 1993/0526 | { Queue *q; | |
| 1993/0528/sys/src/9/port/qio.c:309,315 – 1993/0530/sys/src/9/port/qio.c:362,368 | ||
| 1993/0526 | q->limit = limit; q->kick = kick; q->arg = arg; | |
| 1993/0530 | q->state = msg ? Qmsg : 0; | |
| 1993/0526 | return q; } | |
| 1993/0528/sys/src/9/port/qio.c:517,520 – 1993/0530/sys/src/9/port/qio.c:570,582 | ||
| 1993/0528 | qreopen(Queue *q) { q->state &= ~Qclosed; | |
| 1993/0530 | } /* * return bytes queued */ int qlen(Queue *q) { return q->len; | |
| 1993/0526 | } | |