RFD: adjtime() problems

Ulrich Windl (ulrich.windl@rz.uni-regensburg.de)
Mon, 1 Mar 1999 09:42:54 +0100


The current implementation of "adjtime(const struct timeval *delta,
struct timeval *olddelta)" uses the kernel function adjtimex(struct
timex *tx).

The adtime() syscall allows four combinations for its arguments:

number delta olddelta
------------------------
1) NULL NULL
2) NULL !NULL
3) !NULL NULL
4) !NULL !NULL

Case 1) is a no-op, cases 3) and 4) are the regular cases.
Unfortunately 2) has a problem:

With only one argument passed to adjtimex, usually the "first", the
routine can't return information if that pointer is NULL. And if the
pointer is not NULL, it will always do an adjustment. Saying "0" for
the adjustment will stop any adjustment in progress.

While the clean solution would be to have seperate functions for the
three basic flavours of adjtimex(), I can imagine a working solution:

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.
If you really want to do a "-1us" adjustment, the wrapper could to a
"-2us" adjustment followed by a "+1us" adjustment (after a pause of
one timer interrupt). For compatibility there is one flaw: If a large
adjustment is in progress, and you want to make the tiny "-1us"
adjustment, it would be ignored, letting the huge one finish. That's
why I thought "0" is not the best magic value. Also using a larger
value for the magic number seems dangerous.

Opinions?

Regards,
Ulrich Windl

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