On 27 feb 2006, at 09:41, Vincent Snijders wrote:

Some other workaround that comes to my mind is to do something like
  Randomize;
  RandSeed := RandSeed * getpid;
This worked, cut the initial generation time from about 30 seconds down to under 1, of course right now it's NOT platform independent at all so I will need to enhance it but I like the direction of your thinking, combining randseed with some virtually guaranteed unique value solves the problem.

Maybe you use a global variable and just add one for each randseed call. After all the only thing that matters for the randseed, is that it is different.

BTW, I never would have guessed that the random number generator would have used threadvars.

It doesn't currently.

I would have thought, that on app start you would set one randseed and then call random from all threads.

Every time you call random, the current randseed is read, some calculations are performed and a new value is stored in the randseed variable. So if two threads call random "at the same time", then both will use the same randseed value and thus return the same random value (in the -current- case that randseed is not a threadvar).


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to