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 02:42:35 -0500

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.


On (at least) FreeBSD 4.8, the output comes out in a similar way (according to my friend who ran the test for me on that system).

I never actually read "man 3 rand" on DFly/FBSD because I knew how it worked from books I have. However, I now notice the first line is "These interfaces are obsoleted by random(3)." Regardless of this though, I think it might be worth me patching it with FreeBSD's fix since I'm sure several people use this function in older code, including me.

What do you think?

--Mike




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