From owner-freebsd-smp Sat Jun 15 20:45:13 2002 Delivered-To: freebsd-smp@freebsd.org Received: from mta5.snfc21.pbi.net (mta5.snfc21.pbi.net [206.13.28.241]) by hub.freebsd.org (Postfix) with ESMTP id B36BD37B401; Sat, 15 Jun 2002 20:45:10 -0700 (PDT) Received: from FreeBSD.org ([63.193.112.125]) by mta5.snfc21.pbi.net (iPlanet Messaging Server 5.1 (built May 7 2001)) with ESMTP id <0GXS004W353AEO@mta5.snfc21.pbi.net>; Sat, 15 Jun 2002 20:45:10 -0700 (PDT) Date: Sat, 15 Jun 2002 20:45:19 -0700 From: Jeffrey Hsu Subject: Re: Sharing a single mutex between a socket and its PCB In-reply-to: Message from Seigo Tanimura "of Sun, 16 Jun 2002 00:44:51 +0900." <200206151545.g5FFipAY006726@silver.carrots.uucp.r.dl.itc.u-tokyo.ac.jp> To: Seigo Tanimura Cc: jhb@FreeBSD.org, smp@freebsd.org, yangjihui@yahoo.com Message-id: <0GXS004W453AEO@mta5.snfc21.pbi.net> MIME-version: 1.0 X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org > Seigo Tanimura writes: > As some socket operations (eg sosend(), soreceive(), ...) modify both > a socket and its PCB at once, both of them should be locked by a > single mutex. Since hsu has already locked down struct inpcb, I would > like to protect a socket by the mutex of the PCB. > In order for the socket subsystem to lock and unlock opaquely, two new > usrreq methods will be added: > - pru_lock() locks the PCB of a socket. > - pru_unlock() unlocks the PCB of a socket. > If the PCB has its own mutex, those methods simply lock and unlock the > mutex. Otherwise, those methods lock and unlock the Giant lock. This > is so that we can push down Giant for the socket subsystem later. > Comments? Let's stick with the BSD/OS design, which is to have a separate socket buffer lock. It's better for concurrency this way. (BSD/OS also shows there's no need to have a separate socket lock. The socket buffer lock doubles as a socket lock.) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message