
#use wml::openssl-macros area=docs page=OPENSSL_instrument_bus

<title>Documents, OPENSSL_instrument_bus(3)</title>

<h1>OPENSSL_instrument_bus(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#RETURN_VALUE">RETURN VALUE</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
OPENSSL_instrument_bus[2] - instrument references to memory bus

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #ifdef OPENSSL_CPUID_OBJ
 size_t OPENSSL_instrument_bus (int *vector,size_t num);
 size_t OPENSSL_instrument_bus2(int *vector,size_t num,size_t max);
 \#endif
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
It was empirically found that timings of references to primary memory are
subject to irregular, apparently non-deterministic variations. The
subroutines in question instrument these references for purposes of
gathering entropy for random number generator. In order to make it
bus-bound a 'flush cache line' instruction is used between probes. In
addition probes are added to <STRONG>vector</STRONG> elements in atomic or interlocked manner, which should contribute
additional noise on multi-processor systems. This also means that <STRONG>vector[num]</STRONG> should be zeroed upon invocation (if you want to retrieve actual probe
values).

</P>
<P>
OPENSSL_instrument_bus performs <STRONG>num</STRONG> probes and records the number of oscillator cycles every probe took.

</P>
<P>
OPENSSL_instrument_bus2 on the other hand <STRONG>accumulates</STRONG> consecutive probes with the same value, i.e. in a way it records duration
of periods when probe values appeared deterministic. The subroutine
performs at most <STRONG>max</STRONG> probes in attempt to fill the <STRONG>vector[num]</STRONG>, with <STRONG>max</STRONG> value of 0 meaning ``as many as it takes.''

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUE">RETURN VALUE</A></H1>
<P>
Return value of 0 indicates that CPU is not capable of performing the
benchmark, either because oscillator counter or 'flush cache line' is not
available on current platform. For reference, on x86 'flush cache line' was
introduced with the SSE2 extensions.

</P>
<P>
Otherwise number of recorded values is returned.
</P>
:}


