Omit timer RPC calls for usleep(0)

This commit is contained in:
Norman Feske 2015-04-04 17:57:26 +02:00 committed by Christian Helmuth
parent 77cba65b7a
commit 87f13d77c0

View File

@ -55,6 +55,17 @@ class Timer::Connection : public Genode::Connection<Session>, public Session_cli
void usleep(unsigned us)
{
/*
* Omit the interaction with the timer driver for the corner case
* of not sleeping at all. This corner case may be triggered when
* polling is combined with sleeping (as some device drivers do).
* If we passed the sleep operation to the timer driver, the
* timer would apply its policy about a minimum sleep time to
* the sleep operation, which is not desired when polling.
*/
if (us == 0)
return;
/* serialize sleep calls issued by different threads */
Genode::Lock::Guard guard(_lock);