[Scottish] allowing a large newborn sea-mammal to collide with a rocky plane toid object devoid of atmosphere somewhere in another galaxy

Colin McKinnon scottish at mailman.lug.org.uk
Thu Mar 20 12:48:01 2003


Gordon JC Pearce wrote:

>On Thu, 2003-03-20 at 11:56, Huard, Elise - D C&W Consultant wrote:
>  
>
>>wee question (to replace the pin-drop jokes :-) ) :
>>program in C under Unix.
>>Is there any way to get the time in tenth or hundredth of seconds ?
>>Or to phrase it differently : i need a random number generator that won't
>>give the same sequence of numbers every time that the seed is reinitialised
>>in the same second (by 2 different users)
>>srand(time(NULL)) 
>>and then rand()
>>doesn't work.
>>Or a different kind of seed ?  Suggestions are welcome (should be readily
>>available in your standard Unix system)
>>Thanks,
>>
>>Elise
>>***********************************************************************************
>>    
>>
>
>Read some entropy from /dev/urandom
>
....which isn't available on all flavours of Unix (e.g. Solaris up to 
v8). To solve this problem for cryptographic purposes, some brainy 
person wrote egd. This however requires 'input' to generate random 
numbers - and I don't no where to find it. A quick search on Freshmeat 
did turn up PRNGD 
(http://freshmeat.net/projects/prngd/?topic_id=44%2C136) which works in 
a similar manner to EGD and might suit your purposes.

Although I'm happy to be proved wrong, I don't know of a portable method 
of measuring sub-1second time on Unix. The usleep function  seems to be 
fairly std as does clock, but not ideally suited to what you are doing.

...or the kludgy solution which is to create a hash of the time + PID + 
UID and seed the generator with that.

HTH

Colin