
Dear Josh Wu,
In message 1442373526-842-1-git-send-email-josh.wu@atmel.com you wrote:
As 'time(0) | getpid()' sometimes get same value. That depends on the value of getpid().
I think removing some "random input" from the way how we compute the seed is a bad idea.
So that is not a expected behavior. We expect different value for the seed when when run it in many times.
What is your execution environment? In any sane OS it is higly unlikely that you will see the same or even similar PIDs for successive runs of the program - each run will start a new process, which will get a new PID.
[On a mostly idle Linux system (4.1.6 kernel) I see zero dupes in a set of 30,000 invocations of getpid().]
One can argue if ORing the values is the most clever idea, or if for example ADDing them would result in more "randomness". But completely removing the pid() is bad - any parallel runs of the program on any machines with synchronized times would predictably result in the same seeds which is definitely worse behaviour than what we have now.
So this patch remove the getpid(), just use the time(0) as the seed.
NAK. This is a bad idea.
Best regards,
Wolfgang Denk