random() in multi-threaded pgbench

From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: random() in multi-threaded pgbench
Date: 2009-12-10 06:24:44
Message-ID: 20091210152444.1B6E.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2009-12-10 06:33:29 Re: [patch] pg_ctl init extension
Previous Message Takahiro Itagaki 2009-12-10 05:56:56 Re: Largeobject Access Controls (r2460)