diff --git a/repos/os/include/timer/timeout.h b/repos/os/include/timer/timeout.h index 98ebdd2dcf..41f9ccf231 100644 --- a/repos/os/include/timer/timeout.h +++ b/repos/os/include/timer/timeout.h @@ -251,7 +251,7 @@ class Genode::Alarm_timeout_scheduler : private Noncopyable, Alarm *_alarm_get_pending_alarm(); - void _alarm_setup_alarm(Alarm &alarm, Alarm::Time period, Alarm::Time deadline); + void _alarm_setup_alarm(Alarm &alarm, Alarm::Time period, Alarm::Time first_duration); void _enable(); @@ -275,7 +275,7 @@ class Genode::Alarm_timeout_scheduler : private Noncopyable, void _alarm_discard(Alarm *alarm); - void _alarm_schedule_absolute(Alarm *alarm, Alarm::Time timeout); + void _alarm_schedule_absolute(Alarm *alarm, Alarm::Time duration); void _alarm_schedule(Alarm *alarm, Alarm::Time period); diff --git a/repos/os/src/lib/timeout/timeout.cc b/repos/os/src/lib/timeout/timeout.cc index 572f78048c..be6c7dff37 100644 --- a/repos/os/src/lib/timeout/timeout.cc +++ b/repos/os/src/lib/timeout/timeout.cc @@ -143,8 +143,7 @@ void Alarm_timeout_scheduler::_schedule_one_shot(Timeout &timeout, /* ensure that the schedulers time is up-to-date before adding a timeout */ _alarm_handle(curr_time_us); - _alarm_schedule_absolute(&timeout._alarm, - curr_time_us + duration.value); + _alarm_schedule_absolute(&timeout._alarm, duration.value); if (_alarm_head_timeout(&timeout._alarm)) { _time_source.schedule_timeout(Microseconds(0), *this); } @@ -325,7 +324,7 @@ void Alarm_timeout_scheduler::_alarm_handle(Alarm::Time curr_time) } -void Alarm_timeout_scheduler::_alarm_setup_alarm(Alarm &alarm, Alarm::Time period, Alarm::Time deadline) +void Alarm_timeout_scheduler::_alarm_setup_alarm(Alarm &alarm, Alarm::Time period, Alarm::Time first_duration) { /* * If the alarm is already present in the queue, re-consider its queue @@ -335,17 +334,18 @@ void Alarm_timeout_scheduler::_alarm_setup_alarm(Alarm &alarm, Alarm::Time perio if (alarm._active) _alarm_unsynchronized_dequeue(&alarm); + Alarm::Time deadline = _now + first_duration; alarm._alarm_assign(period, deadline, _now > deadline ? !_now_period : _now_period, this); _alarm_unsynchronized_enqueue(&alarm); } -void Alarm_timeout_scheduler::_alarm_schedule_absolute(Alarm *alarm, Alarm::Time timeout) +void Alarm_timeout_scheduler::_alarm_schedule_absolute(Alarm *alarm, Alarm::Time duration) { Lock::Guard alarm_list_lock_guard(_lock); - _alarm_setup_alarm(*alarm, 0, timeout); + _alarm_setup_alarm(*alarm, 0, duration); } @@ -365,7 +365,7 @@ void Alarm_timeout_scheduler::_alarm_schedule(Alarm *alarm, Alarm::Time period) } /* first deadline is overdue */ - _alarm_setup_alarm(*alarm, period, _now); + _alarm_setup_alarm(*alarm, period, 0); }