aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/time.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/time.go')
-rw-r--r--src/runtime/time.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/runtime/time.go b/src/runtime/time.go
index 517a493a700..70e21d4482e 100644
--- a/src/runtime/time.go
+++ b/src/runtime/time.go
@@ -390,7 +390,11 @@ func dodeltimer(pp *p, i int) int {
if i == 0 {
updateTimer0When(pp)
}
- atomic.Xadd(&pp.numTimers, -1)
+ n := atomic.Xadd(&pp.numTimers, -1)
+ if n == 0 {
+ // If there are no timers, then clearly none are modified.
+ atomic.Store64(&pp.timerModifiedEarliest, 0)
+ }
return smallestChanged
}
@@ -414,7 +418,11 @@ func dodeltimer0(pp *p) {
siftdownTimer(pp.timers, 0)
}
updateTimer0When(pp)
- atomic.Xadd(&pp.numTimers, -1)
+ n := atomic.Xadd(&pp.numTimers, -1)
+ if n == 0 {
+ // If there are no timers, then clearly none are modified.
+ atomic.Store64(&pp.timerModifiedEarliest, 0)
+ }
}
// modtimer modifies an existing timer.