rand() function performs poorly
William M. Grim
wgrim at siue.edu
Wed May 12 02:26:37 PDT 2004
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.
Not to reply to myself, but the version of rand.c in dragonfly is quite
old.. 1.2.2.1. FreeBSD's rand.c is up to 1.15.
I'll just go ahead and try patching my system and testing it out. If it
works okay, I'll submit it to the patch list and someone can take it
from there if everyone feels it's okay to do so. It's not like I have
to do much work to do this, as the work has already been done in FBSD.
--Mike
More information about the Kernel
mailing list