From owner-freebsd-current Tue May 22 7:57: 7 2001 Delivered-To: freebsd-current@freebsd.org Received: from pike.osd.bsdi.com (pike.osd.bsdi.com [204.216.28.222]) by hub.freebsd.org (Postfix) with ESMTP id 6050837B424 for ; Tue, 22 May 2001 07:56:59 -0700 (PDT) (envelope-from jhb@foo.osd.bsdi.com) Received: from foo.osd.bsdi.com (root@foo.osd.bsdi.com [204.216.28.137]) by pike.osd.bsdi.com (8.11.1/8.9.3) with ESMTP id f4MEurK45955; Tue, 22 May 2001 07:56:53 -0700 (PDT) (envelope-from jhb@foo.osd.bsdi.com) Received: (from jhb@localhost) by foo.osd.bsdi.com (8.11.1/8.11.1) id f4MEuqh41897; Tue, 22 May 2001 07:56:52 -0700 (PDT) (envelope-from jhb) 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: <200105221258.f4MCwAD85296@rina.r.dl.itc.u-tokyo.ac.jp> Date: Tue, 22 May 2001 07:56:52 -0700 (PDT) From: John Baldwin To: Seigo Tanimura Subject: RE: New strategy of locking a process group Cc: current@FreeBSD.org Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 22-May-01 Seigo Tanimura wrote: > On Tue, 22 May 2001 04:48:38 -0700 (PDT), > John Baldwin said: > > John> On 22-May-01 Seigo Tanimura wrote: >>> For now, p_mtx protects p_pgrp in struct proc. This is quite >>> troublesome for the following reason: > > John> Err, it doesn't really. It's mostly undecided at this point. Also, > have you > John> looked at the BSD/OS code on builder? They have process groups and > sessions > John> already locked not using global locks but using per-data structure > locks. > > If you do not protect both p_pgrp and p_pglist in struct proc by an > identical lock, you end up with breaking either setpgid(2) or kill(2) > for a process group. The following scenario depicts an example of the > breakage: I'll have to look over the code in more detail, but I would encourage you to check the BSD/OS code. > Finally, a fact missing in my last mail. psignal() actually checks for > the parent of a process, possibly sending SIGCHLD to it. This implies > that we have to slock proctree_lock so that the process hierarchy does > not change. Now that psignal() calls for both pgrpsess_lock and > proctree_lock, it should be cheaper to have only proctree_lock than > both of them. Actually, psignal does _not_ use proctree_lock. p_pptr is locked by both p_mtx and the proctree lock (writes to it require both locks) so either lock is sufficient to read the value. As a result, psignal() simply acquires p_mtx and doesn't go near proctree. -- 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