DragonFly kernel List (threaded) for 2004-05
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
rand() function performs poorly
Hello!
It came to my attention during a test of the rand() function on
DragonFly that the rand() function performs poorly.
Take this code for example:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
int cs, i,r; /*cs == case*/
srand(time(0));
while(1)
{
cs = rand() % 2;
if(cs)
printf("O");
else
printf("o");
fflush(stdout);
}
return EXIT_SUCCESS;
}
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
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]