diff options
| author | rsc <devnull@localhost> | 2004-02-29 22:10:26 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2004-02-29 22:10:26 +0000 |
| commit | 5a8e63b2f016735364d17866d5e2bcb35d20c78b (patch) | |
| tree | d5d0ce11e087efaf81c77311bac9d30aed41783d /src/libthread/proctab.c | |
| parent | d51419bf4397cf13d0c50bf84c125477c6bed307 (diff) | |
| download | plan9port-5a8e63b2f016735364d17866d5e2bcb35d20c78b.tar.gz plan9port-5a8e63b2f016735364d17866d5e2bcb35d20c78b.zip | |
Fighting the good fight.
Move libfmt, libutf into subdirectories of lib9.
Add poll-based socket i/o to libthread, so that we can
avoid using multiple procs when possible, thus removing
dependence on crappy pthreads implementations.
Convert samterm, acme to the single-proc libthread.
Bring libcomplete, acme up-to-date w.r.t. Plan 9 distribution.
Diffstat (limited to 'src/libthread/proctab.c')
| -rw-r--r-- | src/libthread/proctab.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libthread/proctab.c b/src/libthread/proctab.c index 5e5dcb2b..ec28d676 100644 --- a/src/libthread/proctab.c +++ b/src/libthread/proctab.c @@ -6,6 +6,18 @@ enum PTABHASH = 257, }; +static int multi; +static Proc *theproc; + +void +_threadmultiproc(void) +{ + if(multi == 0){ + multi = 1; + _threadsetproc(theproc); + } +} + static Lock ptablock; Proc *ptab[PTABHASH]; @@ -14,6 +26,10 @@ _threadsetproc(Proc *p) { int h; + if(!multi){ + theproc = p; + return; + } lock(&ptablock); h = ((unsigned)p->pid)%PTABHASH; p->link = ptab[h]; @@ -27,6 +43,9 @@ __threadgetproc(int rm) Proc **l, *p; int h, pid; + if(!multi) + return theproc; + pid = _threadgetpid(); lock(&ptablock); |
