URI: 
       tchange to use new thread library - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 93f2ae0d92e0ed88fef8265194024606b78d58c6
   DIR parent 678ede7e54bf508991380c0f896fed6005b87ce9
  HTML Author: rsc <devnull@localhost>
       Date:   Mon, 27 Dec 2004 00:32:50 +0000
       
       change to use new thread library
       
       Diffstat:
         M src/cmd/samterm/io.c                |      21 ++++++++++++++-------
         M src/cmd/samterm/mesg.c              |       8 +++++++-
         M src/cmd/samterm/plan9.c             |      16 ++++++++++------
       
       3 files changed, 31 insertions(+), 14 deletions(-)
       ---
   DIR diff --git a/src/cmd/samterm/io.c b/src/cmd/samterm/io.c
       t@@ -96,13 +96,6 @@ waitforio(void)
                ulong type;
        
        again:
       -
       -        alts[RPlumb].c = plumbc;
       -        alts[RPlumb].v = &i;
       -        alts[RPlumb].op = CHANRCV;
       -        if((block & (1<<RPlumb)) || plumbc == nil)
       -                alts[RPlumb].op = CHANNOP;
       -
                alts[RHost].c = hostc;
                alts[RHost].v = &i;
                alts[RHost].op = CHANRCV;
       t@@ -121,12 +114,25 @@ again:
                if(block & (1<<RMouse))
                        alts[RMouse].op = CHANNOP;
        
       +        alts[RPlumb].c = plumbc;
       +        alts[RPlumb].v = &i;
       +        alts[RPlumb].op = CHANRCV;
       +        if((block & (1<<RPlumb)) || plumbc == nil)
       +                alts[RPlumb].op = CHANNOP;
       +
                alts[RResize].c = mousectl->resizec;
                alts[RResize].v = nil;
                alts[RResize].op = CHANRCV;
                if(block & (1<<RResize))
                        alts[RResize].op = CHANNOP;
        
       +if(0) print("waitforio %c%c%c%c%c\n",
       +        "h-"[alts[RHost].op == CHANNOP],
       +        "k-"[alts[RKeyboard].op == CHANNOP],
       +        "m-"[alts[RMouse].op == CHANNOP],
       +        "p-"[alts[RPlumb].op == CHANNOP],
       +        "R-"[alts[RResize].op == CHANNOP]);
       +
                alts[NRes].op = CHANEND;
        
                if(got & ~block)
       t@@ -135,6 +141,7 @@ again:
                type = alt(alts);
                switch(type){
                case RHost:
       +                if(0) print("hostalt recv %d %d\n", i, hostbuf[i].n);
                        hostp = hostbuf[i].data;
                        hoststop = hostbuf[i].data + hostbuf[i].n;
                        block = 0;
   DIR diff --git a/src/cmd/samterm/mesg.c b/src/cmd/samterm/mesg.c
       t@@ -38,7 +38,9 @@ rcv(void)
                static int i = 0;
                static int errs = 0;
        
       -        while((c=rcvchar()) != -1)
       +if(0) print("rcv in\n");
       +        while((c=rcvchar()) != -1){
       +if(0) print(".");
                        switch(state){
                        case 0:
                                h.type = c;
       t@@ -79,6 +81,10 @@ rcv(void)
                                }
                                break;
                        }
       +if(0) print(":");
       +        }
       +
       +if(0) print("rcv out\n");
        }
        
        Text *
   DIR diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c
       t@@ -112,11 +112,11 @@ extproc(void *argv)
                c = arg[0];
                fd = (int)arg[1];
        
       -        threadfdnoblock(fd);
                i = 0;
                for(;;){
                        i = 1-i;        /* toggle */
       -                n = threadread(fd, plumbbuf[i].data, sizeof plumbbuf[i].data);
       +                n = read(fd, plumbbuf[i].data, sizeof plumbbuf[i].data);
       +if(0) fprint(2, "ext %d\n", n);
                        if(n <= 0){
                                fprint(2, "samterm: extern read error: %r\n");
                                threadexits("extern");        /* not a fatal error */
       t@@ -177,9 +177,10 @@ extstart(void)
                }
        
                plumbc = chancreate(sizeof(int), 0);
       +        chansetname(plumbc, "plumbc");
                arg[0] = plumbc;
                arg[1] = (void*)fd;
       -        threadcreate(extproc, arg, STACK);
       +        proccreate(extproc, arg, STACK);
                atexit(removeextern);
        }
        
       t@@ -255,6 +256,7 @@ plumbstart(void)
                if(fid == nil)
                        return -1;
                plumbc = chancreate(sizeof(int), 0);
       +        chansetname(plumbc, "plumbc");
                if(plumbc == nil){
                        fsclose(fid);
                        return -1;
       t@@ -272,16 +274,17 @@ hostproc(void *arg)
                c = arg;
        
                i = 0;
       -        threadfdnoblock(hostfd[0]);
                for(;;){
                        i = 1-i;        /* toggle */
       -                n = threadread(hostfd[0], hostbuf[i].data, sizeof hostbuf[i].data);
       +                n = read(hostfd[0], hostbuf[i].data, sizeof hostbuf[i].data);
       +if(0) fprint(2, "hostproc %d\n", n);
                        if(n <= 0){
                                fprint(2, "samterm: host read error: %r\n");
                                threadexitsall("host");
                        }
                        hostbuf[i].n = n;
                        which = i;
       +if(0) fprint(2, "hostproc send %d\n", which);
                        send(c, &which);
                }
        }
       t@@ -290,5 +293,6 @@ void
        hoststart(void)
        {
                hostc = chancreate(sizeof(int), 0);
       -        threadcreate(hostproc, hostc, STACK);
       +        chansetname(hostc, "hostc");
       +        proccreate(hostproc, hostc, STACK);
        }