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: "William M. Grim" <wgrim@xxxxxxxx>
Date: Wed, 12 May 2004 04:26:37 -0500

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.


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




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