src/runtime/time.go | 12 ++++++++++-- diff --git a/src/runtime/time.go b/src/runtime/time.go index 517a493a70014ccee4b7ee1f4cf3ec2b9b81ad88..70e21d4482e1829a9f02407cf79db4a1b24d652c 100644 --- a/src/runtime/time.go +++ b/src/runtime/time.go @@ -390,7 +390,11 @@ } 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 @@ if last > 0 { 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.