Re: Linux timekeeping plans

Alan Cox (alan@lxorguk.ukuu.org.uk)
Sat, 5 Dec 1998 19:24:06 +0000 (GMT)


> In linux-kernel, you wrote:
> > volatile master_lock = 1, slave_lock = 0;
> >
> >master:
> > tell_slave_to_start_calibration();
> >
> > for (i = 0; i < 100; i++) {
> > /* Send to slave */
> > while (slave_lock) /* Wait for slave to start spinning */
> > ;
> > nop(); /* Wait a moment for slave to really start spinning */
> > master_time[2*i] = rdtsc();
> > master_lock = 1;
> >
> > /* Receive from slave */
> > master_lock = 0; /* Announce that we're spinning */
> > while (!slave_lock)
> > ;
>
> I think you need mb() after the setting of master/slave_lock to make sure
> that the other CPU sees it as early as possible.

Also you will need to allow for the cross CPU migration of cache lines and
the store ordering. That will throw your estimate out wildly.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/