HP OpenVMS Systems

ask the wizard
Content starts here

Measuring time, system cycle counter? (rscc)

» close window

The Question is:

 
Gents,
I would like to use the AXP intruction RPCC for some precise timing measurements. It is straightforward to do the calls and retreive the numbers but the number returned is relative to the processor it is running on. Is there a way to determine the process
or, it's timing and updating frequency and convert the RPCC returns to 'real time'?
 
Many thanks
 
Paul
 


The Answer is :

 
$ cc/prefix=all rscc+sys$library:sys$lib_c/library
$ link/sysexe rscc
 
 
/*
// This program demonstrates the usage of the System Cycle Counter
//
// On an SMP system, the use of the system cycle counter at an IPL
// below 3 (or without using processor affinity) can be unreliable
// as the process or thread can be rescheduled to run on another cpu,
// and each cpu has its own cycle counter.  (The result of the
// "scc2 - scc1" may not be particularly useful if the process was
// rescheduled to another CPU.)
 
*/
 
#include <c_asm.h>
#include <evx_opcodes.h>
#include <hwrpbdef.h>
#include <signal.h>
#include <ssdef.h>
#include <stdio.h>
 
#define QUOTE(s) #s
#define QUOTEVAL(s) QUOTE (s)
#define RSCC() (asm ("call_pal " QUOTEVAL (EVX$PAL_RSCC)))
 
/*
//  Reference the Hardware Restart Parameter Block.
//  (This is the reason why this tool is linked against sys$lib_c,
//  as the rscc call itself does not require it.)
*/
extern HWRPB* exe$gpq_hwrpb;
 
int main( int argc, char** argv )
  {
  __int64 scc1, scc2, micro;
 
  scc1 = RSCC();
 
  /*
  // doze off for a few...
  */
  sleep( 3 );
 
  scc2 = RSCC();
 
  /*
  // The number of ticks per second is located in the Hardware
  // Restart Parameter Block (HWRPB).  Convert it to microseconds.
  */
 
  micro = (1000000 * (scc2 - scc1)) /
    exe$gpq_hwrpb->hwrpb$iq_cycle_count_freq;
 
  printf ("%Ld microseconds\n", micro);
 
  return SS$_NORMAL;
  }
 
 

answer written or last revised on ( 7-JAN-2004 )

» close window