From owner-freebsd-current Tue May 15 9:16: 8 2001 Delivered-To: freebsd-current@freebsd.org Received: from meow.osd.bsdi.com (meow.osd.bsdi.com [204.216.28.88]) by hub.freebsd.org (Postfix) with ESMTP id 3740E37B424 for ; Tue, 15 May 2001 09:16:05 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Received: from laptop.baldwin.cx (john@jhb-laptop.osd.bsdi.com [204.216.28.241]) by meow.osd.bsdi.com (8.11.2/8.11.2) with ESMTP id f4FGFrG52421; Tue, 15 May 2001 09:15:53 -0700 (PDT) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200105150614.f4F6E0P53295@rina.r.dl.itc.u-tokyo.ac.jp> Date: Tue, 15 May 2001 09:14:59 -0700 (PDT) From: John Baldwin To: Seigo Tanimura Subject: RE: atomic operation of flags (was: RE: select(2) converted to u Cc: current@FreeBSD.org Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 15-May-01 Seigo Tanimura wrote: > On Mon, 07 May 2001 12:37:22 -0700 (PDT), > John Baldwin said: > > John> You need the lock when clearing the bit in p_flag. That is why the > proc locks > John> are there, so all those proc locks need to stay. When you clear a bit, > you are > John> writing all the bits, so you need to ensure that you can atomically > John> read/modify/write all the bits in p_flag, hence the need for the proc > lock. > > As we now have a set of atomic operation functions in > machine/atomic.h, why do we not use them to read, modify and write > p_flag atomically? Is that more expensive than protecting by PROC_LOCK > and PROC_UNLOCK? That does not protect this operation: PROC_LOCK(p); if (p->p_flag & P_FOO) do_something_that_depends_on_FOO_being_set; PROC_UNLOCK(p); -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message