update to use new thread library

This commit is contained in:
rsc 2004-12-26 02:10:47 +00:00
parent 6a5c5d4870
commit f99790979b
3 changed files with 31 additions and 13 deletions

View file

@ -5,10 +5,14 @@ SHORTLIB=draw bio 9
<$PLAN9/src/mkmany <$PLAN9/src/mkmany
$O.tcolors: tcolors.$O
$LD -o $target tcolors.$O -ldraw -lthread -l9 $LDFLAGS
$O.mc: mc.$O $O.mc: mc.$O
$LD -o $target mc.$O -lfs -lmux -lthread -ldraw -lbio -l9 $LDFLAGS $LD -o $target mc.$O -lfs -lmux -ldraw -lthread -lbio -l9 $LDFLAGS
$O.stats: stats.$O $O.stats: stats.$O
$LD -o $target stats.$O -lthread -ldraw -lbio -l9 $LDFLAGS $LD -o $target stats.$O -ldraw -lthread -lbio -l9 $LDFLAGS
LDFLAGS=$LDFLAGS -L$X11/lib -lX11 LDFLAGS=$LDFLAGS -L$X11/lib -lX11

View file

@ -666,14 +666,15 @@ keyboardthread(void *v)
killall("quit"); killall("quit");
} }
void machthread(void*); void machproc(void*);
void updateproc(void*);
void void
threadmain(int argc, char *argv[]) threadmain(int argc, char *argv[])
{ {
int i, j; int i, j;
char *s; char *s;
ulong v, vmax, nargs; ulong nargs;
char args[100]; char args[100];
nmach = 1; nmach = 1;
@ -733,7 +734,7 @@ threadmain(int argc, char *argv[])
} }
for(i=0; i<nmach; i++) for(i=0; i<nmach; i++)
threadcreate(machthread, &mach[i], STACK); proccreate(machproc, &mach[i], STACK);
for(i=0; i<nargs; i++) for(i=0; i<nargs; i++)
switch(args[i]){ switch(args[i]){
@ -804,10 +805,18 @@ threadmain(int argc, char *argv[])
threadcreate(keyboardthread, nil, XSTACK); threadcreate(keyboardthread, nil, XSTACK);
threadcreate(mousethread, nil, XSTACK); threadcreate(mousethread, nil, XSTACK);
threadcreate(resizethread, nil, XSTACK); threadcreate(resizethread, nil, XSTACK);
proccreate(updateproc, nil, XSTACK);
resize(); resize();
unlockdisplay(display); unlockdisplay(display);
}
void
updateproc(void *z)
{
int i;
ulong v, vmax;
USED(z);
for(;;){ for(;;){
parity = 1-parity; parity = 1-parity;
lockdisplay(display); lockdisplay(display);
@ -821,12 +830,12 @@ threadmain(int argc, char *argv[])
} }
flushimage(display, 1); flushimage(display, 1);
unlockdisplay(display); unlockdisplay(display);
threadsleep(sleeptime); sleep(sleeptime);
} }
} }
void void
machthread(void *v) machproc(void *v)
{ {
char buf[256], *f[4], *p; char buf[256], *f[4], *p;
int i, n, t; int i, n, t;
@ -835,7 +844,7 @@ machthread(void *v)
m = v; m = v;
t = 0; t = 0;
for(;;){ for(;;){
n = threadread(m->fd, buf+t, sizeof buf-t); n = read(m->fd, buf+t, sizeof buf-t);
m->dead = 0; m->dead = 0;
if(n <= 0) if(n <= 0)
break; break;

View file

@ -199,7 +199,7 @@ startfsys(void)
if(post9pservice(p[1], "plumb") < 0) if(post9pservice(p[1], "plumb") < 0)
sysfatal("post9pservice plumb: %r"); sysfatal("post9pservice plumb: %r");
close(p[1]); close(p[1]);
threadcreate(fsysproc, nil, Stack); proccreate(fsysproc, nil, Stack);
} }
static void static void
@ -218,14 +218,19 @@ fsysproc(void *v)
if(buf == nil) if(buf == nil)
error("malloc failed: %r"); error("malloc failed: %r");
qlock(&readlock); qlock(&readlock);
n = threadread9pmsg(srvfd, buf, messagesize); n = read9pmsg(srvfd, buf, messagesize);
if(n <= 0){ if(n <= 0){
if(n < 0) if(n < 0)
error("i/o error on server channel"); error("i/o error on server channel");
threadexitsall("unmounted"); threadexitsall("unmounted");
} }
if(readlock.head == nil) /* no other processes waiting to read; start one */ /*
threadcreate(fsysproc, nil, Stack); * can give false positive (create an extra fsysproc) once in a while,
* but no false negatives, so good enough. once we have one extra
* we'll never have more.
*/
if(readlock.waiting.head == nil) /* no other processes waiting to read; start one */
proccreate(fsysproc, nil, Stack);
qunlock(&readlock); qunlock(&readlock);
if(t == nil) if(t == nil)
t = emalloc(sizeof(Fcall)); t = emalloc(sizeof(Fcall));