![]() |
Boost : |
From: Andy (atompkins_at_[hidden])
Date: 2006-11-13 11:15:29
Matthias Troyer <troyer_at_[hidden]> wrote in
news:6A1ACC3A-7E4B-41FF-8EAD-17BD127AE8D4_at_[hidden]:
< snip >
> Hi Andy,
>
> It seems from looking at the code that create_v4 will create
> identically the same guid if two computers (or nodes in a parallel
> computer) create a guid during the same second? This would be very
> common in any parallel program. This is why the paper you cite
> suggests using the MAC address of the computer for the lowest 6
> octets.
>
> Matthias
>
Hi,
First thank you for your comments.
Version 4 guids are just random values. There really is no 'node' part
of the guid with this version. What you are talking about is a version 1
guid. They do have a node and the document does suggest using the MAC
address. I took out the code that creates version 1 guids because I
don't know of a portable way to get the MAC address. You are correct in
that the version 1 code was not following the doc to create a time-based
guid.
The create_v4 private() function is called by create() which (when
compiled with Boost.Thread) is protected by a mutex so only one thread
can create a guid at a time.
It is still possible for 2 calls to create_v4() to create the same guid
if the 2 calls were in different processes and the internal random number
generator was seeded with the same value. I am always looking for better
ways to seed the random number generator.
I plan to add a name-based create function (version 5) in the future.
This can be used to ensure that two computers (or nodes in a parallel
computer) will never create the same guid by ensuring that each computer
(or node) uses a different 'name space identifier'
Again, thank you for the comments.
Andy Tompkins.
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk