[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference vaxaxp::vmsnotes

Title:VAX and Alpha VMS
Notice:This is a new VMSnotes, please read note 2.1
Moderator:VAXAXP::BERNARDO
Created:Wed Jan 22 1997
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:703
Total number of notes:3722

98.0. "10mS clock/timer granularity - can I do better yet ?" by BBPBV1::WALLACE (john wallace @ bbp. +44 860 675093) Tue Jan 28 1997 15:10

    I'm looking for a simple way of implementing a much-better-than 10mS
    granularity timer on an AlphaStation, ideally without a real-time clock
    card. It needn't be 100% accurate, it's to get an "average" delay of
    around 1mS between outgoing messages on a (very) fast serial line, the
    occasional hiccup wouldn't be a problem.
    
    The customer involved says he's heard that with VMS V7.1 the system
    timer granularity on Alpha is now 1mS not 10mS. I know the Alpha clock
    ticks at 1024Hz but I see no definite evidence of this being visible to
    user mode code or to driver code, either in the online 7.0+7.1 docs,
    7.1 release notes/new features, or with a Notes/AltaVista search.
    
    $SCHDWK docs in 7.1 still refer to 10mS. However, I see the
    10mS-related stuff in the V7.0 docs for $SETIMR has vanished in the
    V7.1 System Services manual. Any significance ?
    
    Spinwait on RSCC would give the required resolution but would prevent
    other useful work being done in parallel and is therefore not ideal.
    But unless I can think of something to go "tick" to wake things up,
    I've got no real ideas E.g. Send one character down the console
    port and wait => 1mS at 9600baud? Too much overhead?
    
    All input gratefully received. Code even more welcome :-)
    
    regards
    john
T.RTitleUserPersonal
Name
DateLines
98.1EEMELI::MOSEROrienteers do it in the bush...Tue Jan 28 1997 15:2018
	the following routine expects nanoseconds as input. In my case
	I needed 500 msec delay within a driver...

	/cmos


[.....]
int64		delay_nanos = 500000000;  // 500 msec in nanosecond units
[.....]

[.....]
	//
	// Need to wait 500 msec before clearing the reset bit
	//
	status = exe$delay ( &delay_nanos );
[.....]
    
98.2UTRTSC::thecat.uto.dec.com::JurVanDerBurgChange mode to Panic!Wed Jan 29 1997 02:307
EXE$DELAY is just a loop inplemented by reading the rscc counter....

The system time resolution is still (in V7.1) 10 Ms. The system clock ticks
faster, but only 10Ms units are used.

Jur.

98.3AUSS::GARSONDECcharity Program OfficeWed Jan 29 1997 17:2714
re .2
    
>The system time resolution is still (in V7.1) 10 Ms. The system clock ticks
>faster, but only 10Ms units are used.
    
    Can you elaborate on this?
    
    Alpha VMS V6.2 updates the quadword system time at 1024Hz.
    
    Are you saying that despite this, timer requests are only processed
    with the traditional 10ms granularity?
    
    NB: 10 Ms would be disappointing. (-:
           ^
98.4Some VAX systems didRICKS::OPPWed Jan 29 1997 20:5912
    	Some VAX implementations included a hardware interval timer 
    register.  By programming this register, you could determine the
    interval between special hardware interrupts, from which you 
    could derive more accurate time measurements than the standard
    10 millisecond tick.  The VAX system I'm most familiar with 
    had a 1 MHz clock feeding a programmable divider to provide the
    increased resolution.  However, it was up to the "user" to imple-
    ment this feature.  Perhaps some Alpha CPU chips also have built-
    in interval timers that could be exploited.  
    
    Greg
    
98.5Previous Discussion of Interval Timer and Clock Ticks...XDELTA::HOFFMANSteve, OpenVMS EngineeringThu Jan 30 1997 09:337
:>The system time resolution is still (in V7.1) 10 Ms. The system clock ticks
:>faster, but only 10Ms units are used.
:    Can you elaborate on this?

   See VAXAXP::NOTES$ARCHIVE:ALPHANOTES_V2 note 385.*.
    
98.6It's either more hardware or some k-mode code, I'm afraid...STAR::CROLLThu Jan 30 1997 10:3427
I think you're out of luck, without adding new hardware, or possibly writing
some kernel-mode code.

The only VMS timer available from user-mode has a granularity of 10 milliseconds
(via $SETIMR).  The interval clock ticks at approximately 1 millisecond
intervals, but you have no access to that, short of stealing the interrupt
vector.

There are three hardware counters:

system cycle counter, which doesn't interrupt and so is useless unless you code
timing loops in your code (EXE$DELAY uses this technique);

process cycle counter, which is per-process and doesn't keep "real" time, which
is what I assume you're interested in -- on top of that, it doesn't interrupt.

Performance monitoring counters.  These count "events" (things like cache
misses, and the like), and I believe one of the events is elapsed cycles.
You may be able to create or modify some kernel-mode code to create a timer
using these counters; I don't know because I don't know very much about them. 
If you're interested in learning more, ask in PERFOM::INTERNAL_PERF_TOOLS. 
There was a mention in ALPHANOTES_V3, note 422.

If you do take the plunge and get something useful out of this, please let us
know!

John
98.710mS. Would a wishlist QAR achieve anything ?BBPBV1::WALLACEjohn wallace @ bbp. +44 860 675093Fri Jan 31 1997 13:2414
    Bah humbug.
    
    I've borrowed clock vectors before now, but not since RT11...
    
    At least it's fairly clear what the answer is.
    
    No comments on the inelegant but simple hack of writing character at a
    time to a 9600 baud port and using I/O completion to throttle the
    message rate ???? Remember, in this particular application, accuracy is
    not essential. I might have a go with that anyway and see just what
    the overhead is (somehow...)
    
    regards
    john
98.8EVMS::MORONEYUHF ComputersFri Jan 31 1997 13:578
>    No comments on the inelegant but simple hack of writing character at a
>    time to a 9600 baud port and using I/O completion to throttle the
>    message rate ????

I tried doing that once and found that there was definitely too much overhead.
Then again, this was on a Microvax II.

-Mike
98.9COMEUP::SIMMONDSlock (M); while (not *SOMETHING) { Wait(C,M); } unlock(M)Sat Feb 01 1997 20:169
    Re: .7
    
.7>    No comments on the inelegant but simple hack of writing character at a
.7>    time to a 9600 baud port and using I/O completion to throttle the
    
    Watch out for possible Transmit silos.  My own choice would also be the
    HWCLK interrupt intercept approach (via an execlet).
    
    John.