Main Page   File List  

Time Stamp Counter Related Functions


Functions

l4_cpu_time_t l4_rdtsc (void)
 Return current value of CPU-internal time stamp counter.
l4_cpu_time_t l4_rdpmc (int nr)
 Return current value of CPU-internal performance measurement counter.
l4_uint64_t l4_tsc_to_ns (l4_cpu_time_t tsc)
 Convert time stamp counter into ns.
l4_uint64_t l4_tsc_to_us (l4_cpu_time_t tsc)
 Convert time stamp counter into micro seconds.
void l4_tsc_to_s_and_ns (l4_cpu_time_t tsc, l4_uint32_t *s, l4_uint32_t *ns)
 Convert time stamp counter into s.ns.
l4_cpu_time_t l4_ns_to_tsc (l4_uint64_t ns)
 Convert nano seconds into CPU ticks.
void l4_busy_wait_ns (l4_uint64_t ns)
 Wait busy for a small amount of time.
void l4_busy_wait_us (l4_uint64_t us)
 Wait busy for a small amount of time.
l4_uint32_t l4_calibrate_tsc (void)
 Determine some scalers to be able to convert between real time and CPU ticks.
L4_CV l4_uint32_t l4_tsc_init (int constraint)
 Initialize the scalers needed by l4_tsc_to_ns()/l4_ns_to_tsc() and so on.
L4_CV l4_uint32_t l4_get_hz (void)
 Get CPU frequency in Hz.

Function Documentation

l4_cpu_time_t l4_rdtsc ( void   )  [inline]

Return current value of CPU-internal time stamp counter.

Returns:
64-bit time stamp

Definition at line 151 of file ARCH-amd64/rdtsc.h.

Referenced by l4_busy_wait_ns(), and l4_busy_wait_us().

l4_cpu_time_t l4_rdpmc ( int  nr  )  [inline]

Return current value of CPU-internal performance measurement counter.

Parameters:
nr Number of counter (0 or 1)
Returns:
64-bit PMC

Definition at line 171 of file ARCH-amd64/rdtsc.h.

l4_uint64_t l4_tsc_to_ns ( l4_cpu_time_t  tsc  )  [inline]

Convert time stamp counter into ns.

Parameters:
tsc time value in CPU ticks
Returns:
time value in ns

Definition at line 226 of file ARCH-amd64/rdtsc.h.

l4_uint64_t l4_tsc_to_us ( l4_cpu_time_t  tsc  )  [inline]

Convert time stamp counter into micro seconds.

Parameters:
tsc time value in CPU ticks
Returns:
time value in micro seconds

Definition at line 240 of file ARCH-amd64/rdtsc.h.

void l4_tsc_to_s_and_ns ( l4_cpu_time_t  tsc,
l4_uint32_t *  s,
l4_uint32_t *  ns 
) [inline]

Convert time stamp counter into s.ns.

Parameters:
tsc time value in CPU ticks
Return values:
s seconds
ns nano seconds

Definition at line 254 of file ARCH-amd64/rdtsc.h.

l4_cpu_time_t l4_ns_to_tsc ( l4_uint64_t  ns  )  [inline]

Convert nano seconds into CPU ticks.

Parameters:
ns nano seconds
Returns:
CPU ticks

Definition at line 269 of file ARCH-amd64/rdtsc.h.

Referenced by l4_busy_wait_ns(), and l4_busy_wait_us().

void l4_busy_wait_ns ( l4_uint64_t  ns  )  [inline]

Wait busy for a small amount of time.

Parameters:
ns nano seconds to wait

Definition at line 283 of file ARCH-amd64/rdtsc.h.

References l4_ns_to_tsc(), and l4_rdtsc().

void l4_busy_wait_us ( l4_uint64_t  us  )  [inline]

Wait busy for a small amount of time.

Parameters:
us micro seconds to wait

Definition at line 293 of file ARCH-amd64/rdtsc.h.

References l4_ns_to_tsc(), and l4_rdtsc().

l4_uint32_t l4_calibrate_tsc ( void   )  [inline]

Determine some scalers to be able to convert between real time and CPU ticks.

This test uses channel 0 of the PIT (i8254) or the kernel KIP, depending on availability. Just calls l4_tsc_init(L4_TSC_INIT_AUTO).

Definition at line 145 of file ARCH-amd64/rdtsc.h.

References l4_tsc_init().

L4_CV l4_uint32_t l4_tsc_init ( int  constraint  ) 

Initialize the scalers needed by l4_tsc_to_ns()/l4_ns_to_tsc() and so on.

Current versions of Fiasco export these scalers from kernel into userland. The programmer may decide whether he allows to use these scalers or if an calibration should be performed.

Parameters:
constraint programmers constraint:
  • L4_TSC_INIT_AUTO if the kernel exports the scalers then use them. If not, perform calibration using channel 0 of the PIT (i8254). The latter case may lead into short (unpredictable) periods where interrupts are disabled.
  • L4_TSC_INIT_KERNEL depend on retrieving the scalers from kernel. If the scalers are not available, return 0.
  • L4_TSC_INIT_CALIBRATE Ignore possible scalers exported by the scaler, instead insist on calibration using the PIT.
Returns:
0 on error (no scalers exported by kernel, calibrating failed ...) otherwise returns (2^32 / (tsc per Ásec)). This value has the same semantics as the value returned by the calibrate_delay_loop() function of the Linux kernel.

Referenced by l4_calibrate_tsc().

L4_CV l4_uint32_t l4_get_hz ( void   ) 

Get CPU frequency in Hz.

Returns:
frequency in Hz


L4 Utilities, part of DROPS  © 2000-2003