diff --git a/repos/dde_linux/src/lib/lxip/timer_handler.cc b/repos/dde_linux/src/lib/lxip/timer_handler.cc index fc7b21c4f..2aacb15d5 100644 --- a/repos/dde_linux/src/lib/lxip/timer_handler.cc +++ b/repos/dde_linux/src/lib/lxip/timer_handler.cc @@ -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; } /** diff --git a/repos/dde_linux/src/lx_kit/timer.cc b/repos/dde_linux/src/lx_kit/timer.cc index a27e92b80..70be31fe2 100644 --- a/repos/dde_linux/src/lx_kit/timer.cc +++ b/repos/dde_linux/src/lx_kit/timer.cc @@ -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); }