[fa.info-vax] time of year clock

info-vax (06/04/82)

>From GCJ@MIT-MC Thu Jun  3 21:51:11 1982
I don't know whether there is a place directly readable that
has system-date-time, but for your purposes the system uptime
should be sufficient.  Location SYS$GL_ABSTIM is user-mode
readable and has uptime in (I believe) centiseconds.  Refer
to it as an external global and link in SYS.STB.

Greg

info-vax (06/11/82)

>From DP@MIT-ML Fri Jun 11 00:01:37 1982
  A while ago I asked the list how to get a high resolution clock for
timing code segments without using kernel mode (since the switch was
one of the slow things I wanted to time). well the only accessible
thing is SYS$L_GL_UPTIME, which is time in centiseconds since boot
(thanx to GJC@MC for this tidbit).

  Unfortunately centiseconds is not enough resolution for my purposes.
I wound up biting the bullet and doing the chmk. I then ran into the
problem of what clock to use. While many of the clocks floating around
the system are in units of 100ns ticks, they have 10ms resolution. I
was back where I started. I thought of using the KW-11 my system has,
but clock a was busy running the PUMA arm, and clock b only had 8 bits
of resolution, and it was belived that touching b's registers caused
the systm to die.

 I wound up reading the system todc clock (32 bits 10ms update, the
one that has the battery box, and is used to set the time at boot.)
and adding in the interval timer (32 bits, 1us resolution, inited to
-10000. every 10ms, used to generate the interrupts for the scheduler, etc)
The code that does the winning thing is as follows

	.entry	readtime,^m<r2,r3> 
;
;	function.
;	returns a random quad width semi absolute time, with a 1us resolution.
;
;	author.
;	Jeff Del Papa 10-Jun-1982
;
;	one argument.
;	a pointer to a quadword to store the time in.
;
;	requires.
;	kernel mode
;
;	typical calling.
;	$cmkrnl routin=readime,arglst=args
;	where args is a pre formed arg block ( a long containg the number
;	1, and a long pointing to a quad )
;
;	args:	.long	1
;		.long	time
;	time:	.blkq	1
;
;	code.
;
	probew	#0,#8,@4(ap)		; can we mung the location?
	beql	1$			; no, paranoia was justified
	mfpr	#26,r2			; get the interval timer
	addl2	#10000,r2		; make a positive integer out of it
	mfpr	#27,r3			; get the todc (10ms res) clock
	emul	r3,#10000,r2,@4(ap)	; convert todc to us, (quadword 
					; result)  add the interval
					; clock (converting to quad first) and
					; return value to the user
	movzbl	#ss$_normal,r0		; we did it
1$:	ret

  this returns a reasonable 1us resolution clock. It takes 125us for the
cmkrnl, and all the code (10us or so jitter best case. god knows how long
if an interrupt occurs while in the middle of this.) reasonably hairy privs
(cmkrnl) required.
						enjoy
						Jeff