Subject: Re: System clock resolution and random numbers
To: Rick Byers <firstname.lastname@example.org>
From: John C. Hayward <John.C.Hayward@wheaton.edu>
Date: 04/30/1997 14:58:47
On Wed, 30 Apr 1997, Rick Byers wrote:
> I'm working on an application that needs as-random-as-possible values.
> I've been using the tv_usec from gettimeofday as the seed. My question
> is, what is the resolution of tv_usec? Is it possible to say that it will
> only ever be a certain subset of possible values? I assume it's very
> difficult to predict the exact value at any given time (because subsequent
> calls return significantly different values).
> Is there any better way to make a random number? I don't like the idea of
> having a 32 bit seed because that limits the possible outcomes to 2^32.
> Has their been any thought into putting a random number generator in the
> kernel, and are there any patches to do this? I would think this would be
> nearly perfect since it would be impossible to find the pattern unless you
> had root/physical access.
Use random - it has a larger facility than 2^32 (from man 3 random)
The random() function uses a non-linear additive feedback random number
generator employing a default table of size 31 long integers to return
successive pseudo-random numbers in the range from 0 to (2**31)-1.
The period of this random number generator is very large, approximately
This should be large enough for _any_ application.
> Rick Byers Internet Access Worldwide
> email@example.com System Administrator
> Welland, Ontario, Canada (905)714-1400
> http://www.iaw.on.ca/rickb/ http://www.iaw.on.ca/