[vox-tech] random # gen seeds

Mark K. Kim vox-tech@lists.lugod.org
Wed, 13 Mar 2002 20:46:07 -0800 (PST)


gettimeofday returns a structure with seconds as well as microseconds.
You can use the microseconds portion as the seed.  However, there is a
resolution issue with microseconds, which may or may not be a problem, so
you probably want to mix up the seconds with the microseconds somehow.

Also, you can read /dev/random.

-Mark

On Wed, 13 Mar 2002, 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
>
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech
>

--
Mark K. Kim
http://www.cbreak.org/
PGP key available upon request.