<div dir="ltr">Sparkfun to the rescue! <a href="https://www.sparkfun.com/tutorials/132" target="_blank">https://www.sparkfun.com/tutorials/132</a></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Aug 19, 2013 at 1:40 PM, Matt Graham <span dir="ltr"><<a href="mailto:mhgraham@crow202.org" target="_blank">mhgraham@crow202.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2013-08-19 10:39, Carruth, Rusty wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Don't' know if I need to see the code, but I'm certainly curious to know<br>
how you made it slightly more efficient :-)<br>
</blockquote>
<br>
If you do "dd if=/dev/zero of=/dev/sdb bs=32k" , then dd is constantly reading from /dev/zero . Sure, reading from /dev/zero is fast, but<br>
<br>
zeroes=calloc(1,32768*sizeof(<u></u>char));<br>
/* later */<br>
fwrite(zeroes,32768,1,WRITE_<u></u>PTR);<br>
<br>
doesn't do *any* I/O to /dev/zero .<br>
<br>
When doing the "write random data" pass, randbuffer contains 32K of data read from /dev/urandom . After the data is written, randbuffer is only rewritten with new random data if rand() % 2 == 0. This means that there's 50% less I/O to /dev/urandom at the price of having the random data repeated for more than 1 block in a mostly non-deterministic way. Which means the program spends more time writing and less time reading.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I figure /dev/urandom is at least one order of magnitude better<br>
than /dev/zero (in some base or other) :-) But, yes, if you REALLY<br>
want good random numbers use /dev/random and be prepared for a wait.<br>
</blockquote>
<br>
If you need more than about 256 bytes of stuff out of /dev/random, you'll be waiting for a looooong time. At least IME. If you have serious needs for lots of high-quality non-deterministic entropy, I guess you build an RNG made out of the beta emitters in old smoke detectors. (Fun for the whole family! :-) )<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Crow202 Blog: <a href="http://crow202.org/wordpress" target="_blank">http://crow202.org/wordpress</a><br>
There is no Darkness in Eternity<br>
But only Light too dim for us to see.<br>
------------------------------<u></u>---------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org" target="_blank">PLUG-discuss@lists.phxlinux.<u></u>org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/<u></u>mailman/listinfo/plug-discuss</a><br>
</font></span></blockquote></div><br></div>