rand() function performs poorly
Eric J. Christeson
ejc at crackpot.org
Wed May 12 10:33:38 PDT 2004
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 at 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 at 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 at xxxxxxxxxxxxxxxxxxxx:/usr/src-all/stable/src/sys/compile/ROBIN
i386
echriste at 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 at xxxxxxxxxxxxxxxxxxxx:/usr/home/echriste
$ ./rand_test
oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOo
Eric
--
Eric J. Christeson <ejc at xxxxxxxxxxxx>
Attachment:
signature.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00004.pgp
Type: application/octet-stream
Size: 187 bytes
Desc: "Description: This is a digitally signed message part"
URL: <http://lists.dragonflybsd.org/pipermail/kernel/attachments/20040512/aa769688/attachment-0020.obj>
More information about the Kernel
mailing list