Re: [RFC PATCH 16/22 -v2] add get_monotonic_cycles

Steven Rostedt
2008-01-16T23:50:47Z

On Wed, 16 Jan 2008, Mathieu Desnoyers wrote:
>
> > - cycle_t offset = (now - cs->cycle_last) & cs->mask;
> > + /* First update the monotonic base portion.
> > + * The dual array update method allows for lock-free reading.
> > + */
> > + int num = !cs->base_num;
> > + cycle_t offset = (now - cs->base[!num].cycle_base_last);
>
> !0 is not necessarily 1. This is why I use cpu_synth->index ? 0 : 1 in

How about simply "cpu_synth->index ^ 1"? Seems the best choice if you ask
me, if all you are doing is changing it from 1 to zero and back to 1.

-- Steve

> my code. The two previous lines seems buggy. (I did the same mistake in
> my first implementation) ;)
>
> > + offset &= cs->mask;
> > + cs->base[num].cycle_base = cs->base[!num].cycle_base + offset;
>
> Here too.