random() in multi-threaded pgbench - Mailing list pgsql-hackers

From Takahiro Itagaki
Subject random() in multi-threaded pgbench
Date
Msg-id 20091210152444.1B6E.52131E4D@oss.ntt.co.jp
Whole thread Raw
Responses Re: random() in multi-threaded pgbench
List pgsql-hackers
While testing the pgbench setshell command patch with -j option,
I found all threads use the same sequence of random value.

At first, I think we need to call srandom() in each thread,
but the manual says we should use random_r() instead of random()
on multi-threaded programs.
http://www.kernel.org/doc/man-pages/online/pages/man3/random_r.3.html

Should we replace random() to random_r()?
Some configure test might be needed.

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center



pgsql-hackers by date:

Previous
From: Takahiro Itagaki
Date:
Subject: Re: Largeobject Access Controls (r2460)
Next
From: Peter Eisentraut
Date:
Subject: Re: [patch] pg_ctl init extension