commit a2eb7d516f7c6a824ae891f63f17eaa52ddcf053
parent 03b1418e51df3c32d0536457e0b6ed444785c040
Author: Russ Cox <rsc@swtch.com>
Date: Thu, 3 Jul 2008 17:24:53 -0400
9vx: more graceful backoff in lock
Diffstat:
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/9vx/stub.c b/src/9vx/stub.c
@@ -276,18 +276,19 @@ _tas(void *x)
int
lock(Lock *lk)
{
- int i, printed;
+ int i, j, printed;
for(i=0; i<1000; i++){
if(canlock(lk))
return 1;
sched_yield();
}
- for(i=0; i<100; i++){
- if(canlock(lk))
- return 1;
- microdelay(10);
- }
+ for(j=10; j<=1000; j*=10)
+ for(i=0; i<10; i++){
+ if(canlock(lk))
+ return 1;
+ microdelay(j);
+ }
printed = 0;
for(;;){
if(canlock(lk))
@@ -295,7 +296,7 @@ lock(Lock *lk)
if(!printed++)
iprint("cpu%d deadlock? %p caller=%p\n",
m->machno, lk, getcallerpc(&lk));
- microdelay(1000000);
+ microdelay(10000);
}
return 0;
}