Skip to content

Commit 41d8f0f

Browse files
maciejbocianskicmonr
authored andcommitted
sleep_manager_racecondition: fix for slow devices
sleep_manager_racecondition test fix for devices with low CPU clock This RP contains fix for sleep_manager_racecondition test for very slow devices (like NRF51). It fixes the test itself as well as side effects of fix introduced in #5046 (us ticker: fix fire interrupt handling) The idea of the test was to test race condition between main thread and interrupt handler calling the same function. To efficiently test this, each handler call should interrupt main thread to make race more likely. On very slow devices (like NRF51) when we set very low ticker period (e.g less then 1000us for NRF51) there is no much time for thread scheduling. On such slow devices, setting period to 500 us cause that main thread is scheduled very rarely and only handler is constantly called making test unreliable. Fix introduced in #5046 (us ticker: fix fire interrupt handling) changed fire_interrupt function implementation causing more interrupt tailing thus even less time for main thread scheduling. After introduction of #5046 (us ticker: fix fire interrupt handling) when running sleep_manager_racecondition test on NRF51 (with ticker1.attach_us(&sleep_manager_locking_irq_test, 500);) test is failing with timeout due to the fact that interrupt handler is constantly called and main thread is never scheduled.
1 parent 8d516fd commit 41d8f0f

File tree

1 file changed

+3
-3
lines changed
  • TESTS/mbed_hal/sleep_manager_racecondition

1 file changed

+3
-3
lines changed

TESTS/mbed_hal/sleep_manager_racecondition/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ void sleep_manager_irq_test()
6767
Ticker ticker1;
6868
Timer timer;
6969

70-
ticker1.attach_us(&sleep_manager_locking_irq_test, 500);
70+
ticker1.attach_us(&sleep_manager_locking_irq_test, 1000);
7171

72-
// run this for 5 seconds
72+
// run this for 10 seconds
7373
timer.start();
7474
int start = timer.read();
75-
int end = start + 5;
75+
int end = start + 10;
7676
while (timer.read() < end) {
7777
sleep_manager_locking_irq_test();
7878
}

0 commit comments

Comments
 (0)