Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The problem is that the RTC peripheral will not properly deliver an interrupt if the scheduled compare is less than two ticks in the future. Together with the timer uncertainty it was determined that it is necessary to schedule always at least
now + 3
ticks in the future.The current workaround, however, did the following. If it checked the queue and if there is a delay in the queue that is less than 3 ticks in the future, it will dequeue it. This means that the delay will only get re-checked and released at whatever timer interrupt comes in the future, or not at all if it was the last thing to ever wait for, causing a deadlock.
This was the current behavior when scheduling a bunch of delays all at once:
This is obviously not desired behavior.
With the rework, the same situation now plays out as follows:
Fixes #851.