in reply to Re: How do I get a unique Perl Interpreter ID?
in thread How do I get a unique Perl Interpreter ID?
Are you just trying to generate unique values as a guid or seed for a randomizer?
Mainly guids.
I would think it would be sufficient to just use microtime and rand().
microtime can get screwed by a really fast machine.
As I understand it, mod_perl clones all of its interpreters in one swell foop and if one is doing things the way they recommend by putting all of the nasty module loading and initialization into the master process so that the clone operation has almost nothing left to do beyond creating a bunch of entries in a page table with copy-on-write tags, it's not hard to imagine it eventually being possible for multiple interpreters to get cloned in the same microsecond.
and if the seeding for rand() is likewise done in the master process so that all interpreters are proceeding from the same seed, that's also going to be a lose.
As it happens I do need to seed a random number generator as well. /dev/urandom mostly takes care of that, however if you pull too much from there, then you reduce the entropy available to other processes making them less secure. So if we can get our distinct interpreter IDs from a different source, so much the better. There's also the small matter that /dev/urandom is somewhat broken on older versions of Linux, in which case having extra known-to-be-different junk to throw into the pot will be better than nothing.
rand(), by the way, is completely inadequate for generating random numbers, at least not if you want to be secure about it (far too predictable...).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do I get a unique Perl Interpreter ID?
by Eliya (Vicar) on Dec 01, 2011 at 10:42 UTC | |
by wrog (Friar) on Dec 01, 2011 at 12:16 UTC | |
|
Re^3: How do I get a unique Perl Interpreter ID?
by zwon (Abbot) on Dec 01, 2011 at 15:29 UTC | |
by wrog (Friar) on Dec 02, 2011 at 09:02 UTC | |
|
Re^3: How do I get a unique Perl Interpreter ID?
by TJPride (Pilgrim) on Dec 01, 2011 at 14:26 UTC | |
by davido (Cardinal) on Dec 01, 2011 at 17:39 UTC |