Commit 3a270395 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/libwr: use monotonic clock in shw_udelay_init (util.c)

Proper timeout will not work when clock is set to the past.

Check commit:
userspace/snmpd: bugfix 1164, replace time() with monotinic version
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 14a94373
......@@ -12,14 +12,13 @@ void shw_udelay_init(void)
{
volatile int i;
int j, cur, min = 0;
struct timeval tv1, tv2;
uint64_t tv1, tv2;
for (j = 0; j < 10; j++) {
gettimeofday(&tv1, NULL);
tv1 = get_monotonic_tics();
for (i = 0; i < 100*1000; i++)
;
gettimeofday(&tv2, NULL);
cur = (tv2.tv_sec - tv1.tv_sec) * 1000 * 1000
+ tv2.tv_usec - tv1.tv_usec;
tv2 = get_monotonic_tics();
cur = tv2 - tv1;
/* keep minimum time, assuming we were scheduled-off less */
if (!min || cur < min)
min = cur;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment