mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-26 08:51:08 +00:00
timeout fw: be robust against past _timestamp()
_timestamp() returns CPU local values which may not be in sync with _ts taken from another CPU. Be robust and don't produce wraparound/negative timeout values. Issue #3657
This commit is contained in:
parent
7dbf836217
commit
309597bbda
@ -166,16 +166,19 @@ Duration Timer::Connection::curr_time()
|
||||
mutex_guard.destruct();
|
||||
|
||||
/* interpolate time difference since the last real time update */
|
||||
Timestamp const ts_diff = _timestamp() - ts;
|
||||
Timestamp const ts_current_cpu = _timestamp();
|
||||
Timestamp const ts_diff = (ts_current_cpu < ts) ? 0 : ts_current_cpu - ts;
|
||||
uint64_t const us_diff = _ts_to_us_ratio(ts_diff, us_to_ts_factor,
|
||||
us_to_ts_factor_shift);
|
||||
|
||||
interpolated_time.add(Microseconds(us_diff));
|
||||
|
||||
} else {
|
||||
Timestamp const us = elapsed_us();
|
||||
Timestamp const us_diff = (us < _us) ? 0 : us - _us;
|
||||
|
||||
/* use remote timer instead of timestamps */
|
||||
interpolated_time.add(Microseconds(elapsed_us() - _us));
|
||||
interpolated_time.add(Microseconds(us_diff));
|
||||
|
||||
mutex_guard.destruct();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user