From owner-freebsd-arch@FreeBSD.ORG Mon Apr 14 07:50:26 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DD72106566B for ; Mon, 14 Apr 2008 07:50:26 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from palm.hoeg.nl (mx0.hoeg.nl [IPv6:2001:610:652::211]) by mx1.freebsd.org (Postfix) with ESMTP id 436CC8FC24 for ; Mon, 14 Apr 2008 07:50:26 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: by palm.hoeg.nl (Postfix, from userid 1000) id 6CB561CD30; Mon, 14 Apr 2008 09:47:10 +0200 (CEST) Date: Mon, 14 Apr 2008 09:47:10 +0200 From: Ed Schouten To: Jeff Roberson Message-ID: <20080414074710.GI5934@hoeg.nl> References: <1309.1208100178@critter.freebsd.dk> <20080413131724.X959@desktop> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="w+rhPQc/K9ract27" Content-Disposition: inline In-Reply-To: <20080413131724.X959@desktop> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: arch@freebsd.org Subject: Re: f_offset X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Apr 2008 07:50:26 -0000 --w+rhPQc/K9ract27 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Jeff, * Jeff Roberson wrote: > Concurrent calls to read() are inherently racy. They will still use the= =20 > current value of f_offset and store it while they are done. I'm experiencing similar problems with implementing read() and write() inside my mpsafetty branch for TTY's. Just like the current TTY implementation, my implementation will do strange things when two threads call read() or write() at the same time. Data could end up mixed together. The main cause is that mutexes cannot be held when copying data back to userspace, which is obvious. I could store flags to indicate a read() or write() call is in progress, but because there is no requirement for this, I think I won't pay attention to this. With regular files you could probably increment the offset before copying any data back to userspace, but of course those calls may fail (EFAULT, EIO), which means the offset shouldn't advance. --=20 Ed Schouten WWW: http://g-rave.nl/ --w+rhPQc/K9ract27 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iEYEARECAAYFAkgDC/4ACgkQ52SDGA2eCwWwBACbBo/DheVrtSZtogASRWxCw9XS ic8An3qVDDDwk/lOzXNsaCCyfBie/w+8 =9SZf -----END PGP SIGNATURE----- --w+rhPQc/K9ract27--