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 
This commit is contained in:
Alexander Boettcher 2014-03-31 11:02:11 +02:00 committed by Christian Helmuth
parent cd0d378142
commit a604ea6851
2 changed files with 10 additions and 1 deletions
os
include/os
src/drivers/timer/include

@ -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; }
};
}

@ -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