how to Generate a unique sequence ID to be stored in unsigned long ?
Getting seconds elapsed after 1970 would have been good idea but requirement is within a second the id might be updated , so second wont be unique !
how to Generate a unique sequence ID to be stored in unsigned long ?
Share
If your requirements are to pick something pseudo random, fast, reliably unique, and not used for requirement for crytographic security purposes, I offer up the following
On Windows X86:
__rdtsc() – is about as good of a sequential number as it gets. XOR the upper 32-bits of the return value with the lower 32-bits. As the lower 32-bits will cycle every couple of seconds
Other sources of entropy include GetTickCount() (unique to the millisecond)
On Linux:
Just read 4 bytes from /dev/urandom