[vox-tech] random # gen seeds
Bill Broadley
vox-tech@lists.lugod.org
Thu, 14 Mar 2002 19:31:31 -0800
On Wed, Mar 13, 2002 at 08:05:13PM -0800, Matt Holland wrote:
> I need to generate more than one random number generator seed per second
> within a C program (I have a program that runs about 6 times a second,
> and I need unique seeds for each run). time(0) only gives me a
> resolution of 1 second... any suggestions?
>
> Thanks,
> Matt
Ummm, you don't really say what kind of random numbers you need, true random?
Psuedo random? Unique? Just different? Any reason you couldn't just
once a minute get some bytes from /dev/random to initialize a random()
and generate 6*60 psuedorandom numbers?
Quite a bit of effort has been put into /dev/random to insure it's as
random as possible collecting entropy from as many places as possible,
protection against entropy flooding, support for adding entropy by
cat my_collection_of_random_stuff > /dev/random etc. Oh and it's
careful to query information that is not easily visible outside
the kernel.
But the main problem is if you read to quickly from /dev/random you
will block till the generator decides it has enough entropy to output
more.
--
Bill Broadley
Mathematics/Institute of Theoretical Dynamics
UC Davis