diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-09-07 23:36:04 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2016-09-07 23:36:04 +0200 |
commit | 1848f4e946c6a5d625c23f9c6a3ad7480816585a (patch) | |
tree | 46503781c5622942d07ef5000ca529aaea93687f /sys/src | |
parent | bfd8098b8de4c9dfbd5def087b92b09dfc97b41c (diff) |
kernel: tsemacquire() use MACHP(0)->ticks for time delta
we might wake up on a different cpu after the sleep so
delta from machX->ticks - machY->ticks can become negative
giving spurious timeouts. to avoid this always use the
same mach 0 tick counter for the delta.
Diffstat (limited to 'sys/src')
-rw-r--r-- | sys/src/9/port/sysproc.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/src/9/port/sysproc.c b/sys/src/9/port/sysproc.c index 6cc23c265..46f8f536f 100644 --- a/sys/src/9/port/sysproc.c +++ b/sys/src/9/port/sysproc.c @@ -1126,7 +1126,7 @@ static int tsemacquire(Segment *s, long *addr, ulong ms) { int acquired, timedout; - ulong t, elms; + ulong t; Sema phore; if(canacquire(addr)) @@ -1144,15 +1144,15 @@ tsemacquire(Segment *s, long *addr, ulong ms) } if(waserror()) break; - t = m->ticks; + t = MACHP(0)->ticks; tsleep(&phore, semawoke, &phore, ms); - elms = TK2MS(m->ticks - t); + t = TK2MS(MACHP(0)->ticks - t); poperror(); - if(elms >= ms){ + if(t >= ms){ timedout = 1; break; } - ms -= elms; + ms -= t; } semdequeue(s, &phore); coherence(); /* not strictly necessary due to lock in semdequeue */ |