DragonFly BSD
DragonFly kernel List (threaded) for 2004-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: rand() function performs poorly


From: "Eric J. Christeson" <ejc@xxxxxxxxxxxx>
Date: Wed, 12 May 2004 12:32:35 -0500

On Wed, 2004-05-12 at 04:26, William M. Grim wrote:
> William M. Grim wrote:
> > Matthew Dillon wrote:
> > 
> >> :When you run that code, it will print "OoOoOoOo..." without any 
> >> change; :it's very predictable.
> >> :
> >> :I'm certainly up for bringing the later 4.x rand() code down into 
> >> :DragonFly.  Where do you think they keep it?
> >> :
> >> :And don't one of you other peeps go and do it for me. :-D  I want to 
> >> try :this one on my own!  >:-)
> >> :
> >> :Thanks,
> >> :Mike
> >>
> >>     I think you are talking about /usr/src/lib/libc/stdlib/rand.c, but
> >>     I don't think FreeBSD-4 or FreeBSD-5 has fixed that.  They committed
> >>     something but it looks like they backed it out.
> >>
> >>     Most people use the random()/srandom() facility rather then the old
> >>     rand() facility, or use /dev/urandom.  The old rand() facility     
> >> is severely limited due to API requirements and constraints.
> >>
> >>                     -Matt
> >>                     Matthew Dillon                     
> >> <dillon@xxxxxxxxxxxxx>
> > 
> > 
> > You could be right.  I am attempting to update my dfly before I go 
> > searching for the fixes FreeBSD has.  However, I am assuming it was 
> > "fixed" in some way, because on FreeBSD 5.2.1, the output comes out more 
> > random, such as "OOooooOOoOOOOOOoo..." or something.
> > 

4.9 doesn't appear fixed:
echriste@xxxxxxxxxxxxxxxxxxxx:/usr/home/echriste
$ uname -a
FreeBSD robin.christeson.net 4.9-RELEASE-p5 FreeBSD 4.9-RELEASE-p5 #4:
Mon Apr 26 12:51:12 CDT 2004    
root@xxxxxxxxxxxxxxxxxxxx:/usr/src-all/stable/src/sys/compile/ROBIN 
i386
echriste@xxxxxxxxxxxxxxxxxxxx:/usr/home/echriste
$ grep FreeBSD /usr/src/lib/libc/stdlib/rand.c
 * $FreeBSD: src/lib/libc/stdlib/rand.c,v 1.2.2.1 2001/03/05 11:33:57
obrien Exp $
echriste@xxxxxxxxxxxxxxxxxxxx:/usr/home/echriste
$ ./rand_test
oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo

Eric
-- 
Eric J. Christeson <ejc@xxxxxxxxxxxx>

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]