RT1804: fix EXAMPLE in EVP_EncryptInit.pod
[openssl.git] / doc / crypto / OPENSSL_instrument_bus.pod
1 =pod
2
3 =head1 NAME
4
5 OPENSSL_instrument_bus, OPENSSL_instrument_bus2 - instrument references to memory bus
6
7 =head1 SYNOPSIS
8
9  #ifdef OPENSSL_CPUID_OBJ
10  size_t OPENSSL_instrument_bus (int *vector,size_t num);
11  size_t OPENSSL_instrument_bus2(int *vector,size_t num,size_t max);
12  #endif
13
14 =head1 DESCRIPTION
15
16 It was empirically found that timings of references to primary memory
17 are subject to irregular, apparently non-deterministic variations. The
18 subroutines in question instrument these references for purposes of
19 gathering entropy for random number generator. In order to make it
20 bus-bound a 'flush cache line' instruction is used between probes. In
21 addition probes are added to B<vector> elements in atomic or
22 interlocked manner, which should contribute additional noise on
23 multi-processor systems. This also means that B<vector[num]> should be
24 zeroed upon invocation (if you want to retrieve actual probe values).
25
26 OPENSSL_instrument_bus performs B<num> probes and records the number of
27 oscillator cycles every probe took.
28
29 OPENSSL_instrument_bus2 on the other hand B<accumulates> consecutive
30 probes with the same value, i.e. in a way it records duration of
31 periods when probe values appeared deterministic. The subroutine
32 performs at most B<max> probes in attempt to fill the B<vector[num]>,
33 with B<max> value of 0 meaning "as many as it takes."
34
35 =head1 RETURN VALUE
36
37 Return value of 0 indicates that CPU is not capable of performing the
38 benchmark, either because oscillator counter or 'flush cache line' is
39 not available on current platform. For reference, on x86 'flush cache
40 line' was introduced with the SSE2 extensions.
41
42 Otherwise number of recorded values is returned.