Re: Where to get a unique id for a newly allocated datastructure member



2006-12-01 <75SdnZKEC4gVmO3YnZ2dnUVZ8v2dnZ2d@xxxxxx>,
Richard Heathfield wrote:
A. Farber said:

MY PROBLEM is to get a unique id for a newly allocated
table structure. Here are the options I've considered:

1) Using epoch seconds - is not nice, race condition

Agreed - that's a bad idea.

2) Using a random number - not nice, same as above

Not agreed. Construct a random (or at least pseudorandom) bit string using
as a seed the information you already have from your client. XOR it with an
arbitrary random bit string using some other seed (such as your real-time
clock, if you have access to it), both strings having the same length.

If you use enough bits, you can reduce the probability of a collision to a
far lower value than the probability that your brain will suddenly melt and
pour out through your nostrils.

Wouldn't it be better to use the timestamp _and_ a random number? After
all, the probability is much lower for a short period of time [namely,
the time period during which some computers somewhere will have their
clock set to that time, not to mention that the probable _number_ of
computers that have a time set to that timestamp or will at any point
in the future quickly vanishes to a very small number] and the
possibility is closed once the number of such computers reaches zero,
whereas if you only use randomness, or if you negate the determinicity
of the timestamp by XORing it with randomness, the possibility of
a collision remains open forever.

I also suspect it would take a VERY large number of bits to literally
reduce the probability to that of anyone's brain suddenly melting
(though, once there, reducing it further to that of any _particular_
person's brain doing so will only take 35 or so more bits).

Adding the MAC address, too, will substantially reduce the number of
computers you have to worry about generating the same value, though it
has the disadvantage of making the generated value traceable to your
computer.

At that point, if you do not see the point
in concerning yourself with the latter possibility, then there is no
rational reason to be concerned about the former.


.



Relevant Pages

  • Re: The Hard Problem for Behaviorists
    ... correct low level abstractions to define the operation of the brain with - ... Do you not know how computers work? ... you can think of this type of network like you ... when you drop a marble in hole X1, ...
    (sci.cognitive)
  • Re: before Cantor there was Rantor
    ... > hitting the bulls eye, alas he is the only one who can see ... > could the apes one day learn what random genetic animal freaks ... they conduct rather sadistic experiments with human brain, ... that era were busy researching computers at some point), ...
    (sci.math)
  • Re: before Cantor there was Rantor
    ... > hitting the bulls eye, alas he is the only one who can see ... > could the apes one day learn what random genetic animal freaks ... they conduct rather sadistic experiments with human brain, ... that era were busy researching computers at some point), ...
    (sci.logic)
  • Re: Guessing?
    ... various claims of the uncomputability of the brain reduce to. ... there are processing primitives we haven't thought ... of expressive power. ... anything that regular computers can't. ...
    (comp.databases.theory)
  • Re: The Future
    ... I'm not sure how understanding human genome will "end hunger". ... i.e. we won't nescessarily share this technology with those ... Technology to enable reverse engineering of the brain is ... I thought his explaination of quantum computers, ...
    (comp.lang.cobol)