dde_linux: prevent truncation in update_jiffies()

Before, jiffies wrapped after 2**32 microseconds (71.5 minutes) to 0.
This commit is contained in:
Christian Helmuth 2019-01-30 14:05:09 +01:00 committed by Norman Feske
parent bcef3aeb1e
commit 845253af3a
2 changed files with 15 additions and 4 deletions

View File

@ -188,7 +188,7 @@ class Lx::Timer
_tick(tick)
{
_timer_conn.sigh(_handler);
jiffies = 0;
update_jiffies();
}
/**
@ -271,7 +271,11 @@ class Lx::Timer
*/
void update_jiffies()
{
jiffies = msecs_to_jiffies(_timer_conn.elapsed_ms());
/*
* Do not use lx_emul usecs_to_jiffies(unsigned int) because
* of implicit truncation!
*/
jiffies = _timer_conn.curr_time().trunc_to_plain_ms().value / JIFFIES_TICK_MS;
}
/**

View File

@ -169,6 +169,7 @@ class Lx_kit::Timer : public Lx::Timer
_timer_alloc(&alloc)
{
_timer_conn.sigh(_dispatcher);
update_jiffies();
}
Context* first() { return _list.first(); }
@ -277,8 +278,14 @@ class Lx_kit::Timer : public Lx::Timer
return false;
}
void update_jiffies() {
_jiffies = usecs_to_jiffies(_timer_conn_modern.curr_time().trunc_to_plain_us().value); }
void update_jiffies()
{
/*
* Do not use lx_emul usecs_to_jiffies(unsigned int) because
* of implicit truncation!
*/
_jiffies = _timer_conn_modern.curr_time().trunc_to_plain_ms().value / JIFFIES_TICK_MS;
}
void usleep(unsigned us) {
_timer_conn.usleep(us); }