diff options
| author | rsc <devnull@localhost> | 2005-01-06 23:43:42 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2005-01-06 23:43:42 +0000 |
| commit | a0a331aad99bbca5a13fa4b69593061f29dc3a29 (patch) | |
| tree | 1cba91b1f702a098a9c805fb3c876e9b372ba679 /src/libthread/Linux.c | |
| parent | 815552b9ed41df2f20892f6467dd47f91f93aca1 (diff) | |
add _procwakeupandunlock
to help ease locking contention
on Linux 2.4.
Diffstat (limited to 'src/libthread/Linux.c')
| -rw-r--r-- | src/libthread/Linux.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/libthread/Linux.c b/src/libthread/Linux.c index 85003c29..25a98d96 100644 --- a/src/libthread/Linux.c +++ b/src/libthread/Linux.c @@ -32,7 +32,7 @@ _threadlock(Lock *l, int block, ulong pc) { int i; static int first=1; -if(first) {first=0; fmtinstall('T', timefmt);} +if(first) {first=0; fmtinstall('\001', timefmt);} USED(pc); @@ -48,43 +48,43 @@ if(first) {first=0; fmtinstall('T', timefmt);} return 1; sched_yield(); } - /* now nice and slow */ + /* now increasingly slow */ for(i=0; i<10; i++){ if(!_tas(&l->held)) return 1; usleep(1); } -fprint(2, "%T lock loop %p from %lux\n", l, pc); +fprint(2, "%\001 %s: lock loop1 %p from %lux\n", argv0, l, pc); for(i=0; i<10; i++){ if(!_tas(&l->held)) return 1; usleep(10); } -fprint(2, "%T lock loop %p from %lux\n", l, pc); +fprint(2, "%\001 %s: lock loop2 %p from %lux\n", argv0, l, pc); for(i=0; i<10; i++){ if(!_tas(&l->held)) return 1; usleep(100); } -fprint(2, "%T lock loop %p from %lux\n", l, pc); +fprint(2, "%\001 %s: lock loop3 %p from %lux\n", argv0, l, pc); for(i=0; i<10; i++){ if(!_tas(&l->held)) return 1; usleep(1000); } -fprint(2, "%T lock loop %p from %lux\n", l, pc); +fprint(2, "%\001 %s: lock loop4 %p from %lux\n", argv0, l, pc); for(i=0; i<10; i++){ if(!_tas(&l->held)) return 1; usleep(10*1000); } -fprint(2, "%T lock loop %p from %lux\n", l, pc); +fprint(2, "%\001 %s: lock loop5 %p from %lux\n", argv0, l, pc); for(i=0; i<1000; i++){ if(!_tas(&l->held)) return 1; usleep(100*1000); } -fprint(2, "%T lock loop %p from %lux\n", l, pc); +fprint(2, "%\001 %s: lock loop6 %p from %lux\n", argv0, l, pc); /* take your time */ while(_tas(&l->held)) usleep(1000*1000); @@ -150,13 +150,20 @@ again: } void -_procwakeup(_Procrendez *r) +_procwakeupandunlock(_Procrendez *r) { + int pid; + + pid = 0; if(r->asleep){ r->asleep = 0; assert(r->pid >= 1); - kill(r->pid, SIGUSR1); + pid = r->pid; } + assert(r->l); + unlock(r->l); + if(pid) + kill(pid, SIGUSR1); } /* |