[comp.unix.internals] adjtime on a VAX?

jeffrey@sci.ccny.cuny.edu (Jeffrey L Bromberger) (02/28/91)

Hi.  I'm peeking at the src at 4.3BSD, especially at the code for
adjtime.  The routine adjusts the system's clock (when given a number
of microseconds to differ).  After it figures out how much has to
change, this is (summarized) what happens:

	Call splclock
		this copies the contents of processor register
		$18 to r0 (the return value) and copies the value
		$0x18 into this same register.
	Do some math to figure out the remaining adjustment
	Call splx with the return value from the splclock.

Now, register $18 is the Interval Count Control (according to the VAX
hardware handbook).  The bit pattern from $0x18 sets the 2^3 bit.
But the manual claims that this bit MUST BE ZERO to work.  The bit set
in the 2^4 position tells the machine to transfer the Next Interval
Count Register into the systems Interval Count Register.

So.  That's what the code and the FM's say.  But how does the time
actually change?  I don't see a set of the Next Interval register.
What was there, and what effect does it have to load a seemingly
random register over the machine's system clock?  And, where does the
computed change fit it?  If the math is meant to be a delay loop, then
how can one slow the clock down?

Have I missed something here??  Any help would be appreciated!

j
-- 
Jeffrey L. Bromberger
System Operator---City College of New York---Science Computing Facility
jeffrey@sci.ccny.cuny.edu			jeffrey@ccnysci.BITNET
	Anywhere!{cmcl2,philabs,phri}!ccnysci!jeffrey

torek@elf.ee.lbl.gov (Chris Torek) (03/01/91)

In article <1991Feb27.194230.3708@sci.ccny.cuny.edu>
jeffrey@sci.ccny.cuny.edu (Jeffrey L Bromberger) writes:
>... I'm peeking at the src at 4.3BSD, especially at the code for
>adjtime. ... splclock ... copies the contents of processor register
>$18 to r0 (the return value) and copies the value $0x18 into this same
>register.  Now, register $18 is the Interval Count Control (according
>to the VAX hardware handbook).

You have confused the value 18 with the value 0x18.  splclock() writes
to register 18, or 0x12, which is the IPL register.  It just so happens
that the level used to block clock interrupts is also 0x18, which helps
confuse matters.

adjtime() actually works by changing the amount the current time is
incremented on each clock interrupt.  That is, every 10 ms. (assuming
the default 100 Hz clock), the time is incremented by 11 ms. or 9 ms.
instead of 10 ms., so that after some number $n$ of these the total time
is $n$ ms ahead or behind where it would be otherwise.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab EE div (+1 415 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov