Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261337AbUK0VP4 (ORCPT ); Sat, 27 Nov 2004 16:15:56 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261338AbUK0VP4 (ORCPT ); Sat, 27 Nov 2004 16:15:56 -0500 Received: from www.zeroc.com ([63.251.146.250]:3819 "EHLO www.zeroc.com") by vger.kernel.org with ESMTP id S261337AbUK0VPv (ORCPT ); Sat, 27 Nov 2004 16:15:51 -0500 Message-ID: <009501c4d4c6$40b4f270$6400a8c0@centrino> From: "Bernard Normier" To: "Jan Engelhardt" Cc: References: <006001c4d4c2$14470880$6400a8c0@centrino> Subject: Re: Concurrent access to /dev/urandom Date: Sat, 27 Nov 2004 16:15:36 -0500 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="UTF-8"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1042 Lines: 28 > >As long as I serialize access to /dev/urandom, I get different values. >>However, with concurrent access to /dev/urandom, I quickly get duplicate > > How do you concurrently read from urandom? That's only possible with 2 or > more > CPUs, and even then, I hope that the urandom chardev has some spinlock. > As shown in the code included in my first e-mail, each thread simply open("/dev/urandom", O_RDONLY), use read(2) to read 16 bytes, and then close the file descriptor. Duplicates appear quickly on: single CPU with HT, dual CPU without HT, and dual CPU with HT (all with smp kernels) But not on a lower end single CPU without HT (2.6.8-1.521 non-smp). >>#include >>[...] > > Rule of thumb: Post the smallest possible code that shows the problem. Will do next time! Bernard - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/