[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luuid vs. forks
- From: Javier Guerra <javier@...>
- Date: Mon, 8 Feb 2010 16:41:00 -0500
On Mon, Feb 8, 2010 at 3:49 PM, Alexander Gladysh <agladysh@gmail.com> wrote:
> This looks wrong to me. Also it (indirectly) breaks my tests. So I want to
> ask — is this normal, or my setup is broken?
> Alexander.
it _is_ very wrong. what happens if you run the program a second
time? do you get the same sequence? or is it different each time but
the same on both forks()?
if it's the same sequence on each time, you have to seed the
pseudorandom generator (PRG). it's a common pitfall on most PRGs.
(others auto-seed on first use if you don't do it yourself, usually
with a time-microdependent value)
if it's different each time, but always the same on both forks, you
have to figure where are you seeding the PRG and make sure it happens
_after_ the fork (or that it happens again, with a different seed, of
course).
--
Javier