[LTP] [PATCH v3 3/7] fzsync: Add long running thread support and deviation stats

Cyril Hrubis chrubis@suse.cz
Fri Sep 15 14:48:14 CEST 2017


Hi!
> >>  /**
> >>   * tst_fzsync_pair_update - Recalculate the delay
> >> @@ -169,8 +194,16 @@ static void tst_fzsync_pair_update(int loop_index, struct tst_fzsync_pair *pair)
> >>  	double target = pair->avg_diff_trgt;
> >>  	double avg = pair->avg_diff;
> >>  
> >> +	if (pair->a.tv_sec > pair->b.tv_sec)
> >> +		pair->a.tv_nsec += 1000000000;
> >> +	else if (pair->a.tv_sec < pair->b.tv_sec)
> >> +		pair->b.tv_nsec += 1000000000;
> >
> > Why the else here? These two cases are mutually exclusive.
> 
> Because if (pair->a.tv_sec == pair->b.tv_sec) then we want to do
> nothing.

Ah right, missed that. I wonder if can compute the diff directly as:

	 pair->a.tv_nsec - pair->b.tv_nsec + 1000000000 *
	 (pair->a.tv_sec - pair->b.tv_sec)

instead.

Or do we care not to overflow here?

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list