From owner-freebsd-hackers Fri Dec 11 07:19:24 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA17454 for freebsd-hackers-outgoing; Fri, 11 Dec 1998 07:19:24 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from ns.tar.com (ns.tar.com [204.95.187.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA17444 for ; Fri, 11 Dec 1998 07:19:20 -0800 (PST) (envelope-from lists@tar.com) Received: from ppro.tar.com (ppro.tar.com [204.95.187.9]) by ns.tar.com (8.9.1/8.9.1) with SMTP id JAA45380; Fri, 11 Dec 1998 09:19:07 -0600 (CST) (envelope-from lists@tar.com) Message-Id: <199812111519.JAA45380@ns.tar.com> From: "Richard Seaman, Jr." To: "Marc Slemko" Cc: "hackers@freebsd.org" Date: Fri, 11 Dec 98 09:19:06 -0600 Reply-To: "Richard Seaman, Jr." X-Mailer: PMMail 1.92 For OS/2 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Subject: Re: pread/pwrite Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, 10 Dec 1998 14:20:22 -0800 (PST), Marc Slemko wrote: >(not necessarily addressed specifically at pread/pwrite, but it does >apply to it because of how it is used...) > >Where is the locking if multiple threads are reading and/or writing >from or to the same descriptor at the same time? If you have x >threads reading from a descriptor opened from a file on disk, do >x-1 of them have to wait until the first one finishes before they can >do anything? > >What about with mixed reading/writing? Well, I'm no expert on the FreeBSD kernel, and know even less about FreeBSD SMP. But, here's my understanding (and I hope someone will correct me if I'm wrong). In the uniprocessor case, it is my understanding that the kernel is nonpreemtive. Thus, if pread/pwrite are syscalls, no locking is needed any more than it is needed for read/write. In the SMP case, you need locking, I think. My understanding is that FreeBSD currently has a kernel "giant lock". Moving to more fine grained locking could require locking fd's, but as long as that is not implemented for read/write, I don't see that its needed for pread/pwrite. If I'm wrong about this, then the pread/pwrite implementation I've supplied is not correct. And, based on this, I think read/write (or pread/pwrite) is effectively ordered (one thread at a time accessing an fd) by the nature of the kernel (uniprocessor) or by the locks (SMP). To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message