Timer: Make Timer implementation robust against late firing platform alarm (#1917)

This commit changes the timer code to make the implementation robust
against late firing platform alarm case. In particular, it addresses
the (rare corner-case) scenario where alarm fire is late and the head
timer in the linked-list is already expired and then a new timer is
started with maximum interval. This can possibly violate the
requirement for `TimerScheduler::IsStringlyBefore()` method that the
two times being compared should not differ more than the maximum
interval `Timer::kMaxDt`. To address this, a new method
`Timer::DoesFireBefore()` is added to compare fire time of two timers
which checks for expired timers.

This commit also updates the timer unit test to add test cases related
to the late firing alarm.
This commit is contained in:
Abtin Keshavarzian
2017-06-21 00:14:33 -07:00
committed by Jonathan Hui
parent 49e7977d84
commit c99b4fb921
4 changed files with 206 additions and 1 deletions
+2
View File
@@ -79,6 +79,7 @@ namespace ot
// test_timer.cpp
int TestOneTimer();
int TestTwoTimers();
int TestTenTimers();
// test_toolchain.cpp
@@ -159,6 +160,7 @@ namespace ot
// test_timer.cpp
TEST_METHOD(TestOneTimer) { ::TestOneTimer(); }
TEST_METHOD(TestTwoTimers) { ::TestTwoTimers(); }
TEST_METHOD(TestTenTimers) { ::TestTenTimers(); }
// test_ncp_buffer.cpp