From c9bcce57e8b5609a261ea66258941720de189039 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Fri, 24 Nov 2017 09:34:00 +0100 Subject: [PATCH] timer/epit: limit timeout rate Limit rate to 1000 per second as it raises the throughput under stress significantly without having an effect on the tested accuracy. Issue #2579 --- repos/os/src/drivers/timer/epit/time_source.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/repos/os/src/drivers/timer/epit/time_source.cc b/repos/os/src/drivers/timer/epit/time_source.cc index f486eeecc2..95ba22755b 100644 --- a/repos/os/src/drivers/timer/epit/time_source.cc +++ b/repos/os/src/drivers/timer/epit/time_source.cc @@ -25,10 +25,6 @@ Microseconds Timer::Time_source::max_timeout() const { void Timer::Time_source::schedule_timeout(Microseconds duration, Timeout_handler &handler) { - /* make swift current time steady */ - Duration const time = curr_time(); - _curr_time_us = time.trunc_to_plain_us().value; - /* * Program max timeout in case of duration 0 to avoid lost of accuracy * due to wraps when value is chosen too small. Send instead a signal @@ -57,10 +53,13 @@ Duration Timer::Time_source::curr_time() unsigned const tic_value = _epit.value(wrapped); unsigned passed_tics = 0; - if (wrapped) + if (_irq && wrapped) passed_tics += max_value; passed_tics += max_value - tic_value; - return Duration(Microseconds(_curr_time_us + _epit.tics_to_us(passed_tics))); + if (_irq || _epit.tics_to_us(passed_tics) > 1000) + _curr_time_us += _epit.tics_to_us(passed_tics); + + return Duration(Microseconds(_curr_time_us)); }