what's the accepted method to get a random seed?

what's the accepted method to get a random seed?

i considered using seconds since the epoch, that may be good enough.

ummmm, by the way, is rand() still the way to go?  in the end i'm going
to want a random real between zero and one inclusive.   [0,1] as
the mathematicians say.

anyway, to seed rand() you need an unsigned int.  all i really want
is "not readily predictable" garbage.  seems like i heard of someone
just reading something out of the kernel, maybe the process table?

--

Head of Sun Support, Sr. Operating Systems Specialist
Applied Research Labs, Computer Science Div.                   S224
University of Texas at Austin

what's the accepted method to get a random seed?

Quote:

>i considered using seconds since the epoch, that may be good enough.

>ummmm, by the way, is rand() still the way to go?  in the end i'm going
>to want a random real between zero and one inclusive.   [0,1] as
>the mathematicians say.

>anyway, to seed rand() you need an unsigned int.  all i really want
>is "not readily predictable" garbage.  seems like i heard of someone
>just reading something out of the kernel, maybe the process table?

Read sizeof(int) bytes from /dev/urandom. Or are you using some horribly
ancient version of Solaris that doesn't have it?

--
Chris Thompson
Email: cet1 [at] cam.ac.uk

what's the accepted method to get a random seed?

>>i considered using seconds since the epoch, that may be good enough.

>>ummmm, by the way, is rand() still the way to go?  in the end i'm going
>>to want a random real between zero and one inclusive.   [0,1] as
>>the mathematicians say.

>>anyway, to seed rand() you need an unsigned int.  all i really want
>>is "not readily predictable" garbage.  seems like i heard of someone
>>just reading something out of the kernel, maybe the process table?

>Read sizeof(int) bytes from /dev/urandom. Or are you using some horribly
>ancient version of Solaris that doesn't have it?

GACK!  i used to have to install /dev/urandom from the source, too.
completely whiffed on that one.  thanks.

j.

Quote:

>--
>Chris Thompson
>Email: cet1 [at] cam.ac.uk

--

Head of Sun Support, Sr. Operating Systems Specialist
Applied Research Labs, Computer Science Div.                   S224
University of Texas at Austin

Is there a way to have a more random way to seed RANDOM?

Now I do RANDOM=(multiply part of the CPU number * part of time * Process
Id) % 32767

A better way would be to make a number by testing CPU usage and generate a 1
when it increases and a 0 when it doesn't.  But this is prettty involved for
the ksh and it only works for busy systems.

This has to run only once on different systems.