From owner-freebsd-arch@FreeBSD.ORG Sun Nov 7 00:38:47 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A52F916A4CE for ; Sun, 7 Nov 2004 00:38:47 +0000 (GMT) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7C3F443D2F for ; Sun, 7 Nov 2004 00:38:47 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 19326 invoked from network); 7 Nov 2004 00:38:47 -0000 Received: from gate.funkthat.com (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 7 Nov 2004 00:38:47 -0000 Received: from hydrogen.funkthat.com (lejqdo@localhost.funkthat.com [127.0.0.1])iA70chB6076933; Sat, 6 Nov 2004 16:38:46 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id iA70cgjw076932; Sat, 6 Nov 2004 16:38:42 -0800 (PST) Date: Sat, 6 Nov 2004 16:38:42 -0800 From: John-Mark Gurney To: Poul-Henning Kamp Message-ID: <20041107003842.GB73306@funkthat.com> Mail-Followup-To: Poul-Henning Kamp , arch@freebsd.org References: <10847.1099784360@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10847.1099784360@critter.freebsd.dk> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: arch@freebsd.org Subject: Re: Multi-threading access to device drivers. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Nov 2004 00:38:47 -0000 Poul-Henning Kamp wrote this message on Sun, Nov 07, 2004 at 00:39 +0100: > Assume a device driver which is not Giant-handicapped. > > Assume an I/O path which does not need Giant to get from > read(2) to the device driver. > > Assume a SMP machine. > > Assume a process with two threads on two CPUs, both > doing read(fd, buf, len) at the same time. > > Should we let both reads into the driver at the same time ? > > If so, which uio_offset do we hand them ? As was quoted POSIX, the update should be atomic.. so my reading of that is that you lock the fd, when you read the offset from the fd, you need to also update the offset with the number of bytes read, so that a racing read both doesn't drop any data, nor duplicate any data.. i.e. single file with fixed records, it should be perfectly safe to throw five threads looping doing a read processing of the records w/o fear of duplicate records, or dropped records... And if we handle it in this manner, then you can allow multiple reads into the driver... -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."