From a604ea68518e60bb9a53fbf76741335546658d26 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 31 Mar 2014 11:02:11 +0200 Subject: [PATCH] os: reprogram timer solely if needed If an alarm/timeout object became head of the timeout queue, then the low level timer must be reprogrammed. Issue #1106 --- os/include/os/alarm.h | 8 ++++++++ os/src/drivers/timer/include/timer_session_component.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/os/include/os/alarm.h b/os/include/os/alarm.h index b41d954b5b..43f51a6279 100644 --- a/os/include/os/alarm.h +++ b/os/include/os/alarm.h @@ -131,6 +131,14 @@ namespace Genode { * \return true if an alarm is scheduled */ bool next_deadline(Alarm::Time *deadline); + + /** + * Determine if given alarm object is current head element + * + * \param alarm alarm object + * \return true if alarm is head element of timeout queue + */ + bool head_timeout(const Alarm * alarm) { return _head == alarm; } }; } diff --git a/os/src/drivers/timer/include/timer_session_component.h b/os/src/drivers/timer/include/timer_session_component.h index 259c704e12..d97843f063 100644 --- a/os/src/drivers/timer/include/timer_session_component.h +++ b/os/src/drivers/timer/include/timer_session_component.h @@ -193,7 +193,8 @@ namespace Timer { } else schedule_absolute(alarm, now + timeout); /* interrupt current 'wait_for_timeout' */ - _platform_timer->schedule_timeout(0); + if (head_timeout(alarm)) + _platform_timer->schedule_timeout(0); } unsigned long curr_time() const