Re: How to read xtime

David Miller (davem@twiddle.net)
Thu, 25 Feb 1999 22:44:13 -0800


Perhaps I am missing something, but I believe this is dealt with on
Sparc already in a more clever and efficient way (the idea is actually
by Van Jacobson to the best of my knowledge, his is the earliest
implementation of this "trick" that I am aware of)). The algorithm,
in pseudo assembly, is:

retry: ldd [xtime], %reg1 /* load all 8 bytes of xtime */
ld [timer_reg], %reg2 /* snapshot timer counter */
ldd [xtime], %reg3 /* load second copy of xtime */
cmp %reg1, %reg3 /* Did it change in between? */
bne retry /* Yep, try once more */
nop

No locks, no interrupt disabling, etc. I suppose using this technique
would be extremely troublesome if the architecture in question has no
method to load an aligned doublet of time_t's at once. But I believe
ix86 actually can.

Perhaps this solves a different problem than the one you are
tackling...

Later,
David S. Miller
davem@redhat.com

-
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/