Re: RFD: adjtime() problems

Kris Karas (ktk@ktk.bidmc.harvard.edu)
Tue, 02 Mar 1999 12:25:18 -0500


Ulrich Windl wrote:

> Introduce some magic adjustment value like "-1 microsecond" that is
> ignored for an adjustment. That way a non-destructive readout can be
> performed by adjtimex() when the wrapper is doing the interface right.
> ... Also using a larger value for the magic number seems dangerous.

I had a EE professor years ago who noticed something sad about his students
when they were asked to determine the current in some circuit; they spent
roughly half the time coming up with the answer (some number of milliamps),
and then the remaining half of the time chasing down complex second-order
effects which at best changed the answer by a few microamps. The professor
decided upon a new philosophy to help put things in perspective - greatly
needed by a student body taught what to think rather than how to think:
"Eight is roughly equal to ten for large values of eight."

We can apply this philosophy here, I think. With some suitably (numerically)
large value of MAGIC, bumping any real offset left or right of MAGIC to avoid
MAGIC is trivial, if not somewhat ugly.

/* Caveat: I'm not a C programmer; I only play one on TV */

/* Replace this with whatever tickles your fancy. */
#define MAGIC (1 << 30)

adjtime_wrapper(struct timeval *delta, struct timeval *olddelta) {
if (delta.tv_usec == MAGIC) return_adjustment();
else set_adjustment(delta, olddelta); /* Or whatever */
}

userspace_read_adjtime() {
struct timeval foo, bar;
foo.tv_usec=MAGIC;
adjtime_wrapper(&foo, &bar);
}

userspace_set_adjtime(unsigned long how_many_usecs) {
struct timeval foo, bar;
if (how_many_usecs == MAGIC) ++how_many_usecs;
foo.tv_usec=how_many_usecs;
adjtime_wrapper(&foo, &bar);
}

/* Blah Blah */

--
Kristofer Karas                           *      kXtXk@bigfoot.com (delete X's)
AMA/CCS DoD RF900RR NT650++ !car          *    Senior systems engineer/SysAdmin
"Build a system that even a fool can use, * BI Deaconess Medical Center, Boston
 and only a fool will want to use it."    *  Will design LISP machines for food

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