From owner-freebsd-arch@FreeBSD.ORG Mon Nov 3 05:03:47 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 37D2716A4CF; Mon, 3 Nov 2003 05:03:47 -0800 (PST) Received: from silver.tanimura.dyndns.org (IP1A0600.kng.mesh.ad.jp [211.13.103.220]) by mx1.FreeBSD.org (Postfix) with ESMTP id D5C1A43FAF; Mon, 3 Nov 2003 05:03:43 -0800 (PST) (envelope-from tanimura@tanimura.dyndns.org) Received: from silver.tanimura.dyndns.org (localhost [127.0.0.1]) with ESMTP id hA3D3TQK038461 ; Mon, 3 Nov 2003 22:03:29 +0900 (JST) Message-Id: <200311031303.hA3D3TQK038461@silver.tanimura.dyndns.org> Date: Mon, 03 Nov 2003 22:03:29 +0900 From: Seigo Tanimura To: current@FreeBSD.org, arch@FreeBSD.org In-Reply-To: <200310221021.h9MALkUM023905@urban> References: <200310220319.h9M3JGI1005225@urban> <200310221021.h9MALkUM023905@urban> User-Agent: Wanderlust/2.10.0 (Venus) SEMI/1.14.4 (Hosorogi) FLIM/1.14.4 (=?ISO-8859-1?Q?Kashiharajing=FE-mae?=) APEL/10.4 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: My Home MIME-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, hits=0.0 required=8.0 tests=none autolearn=no version=2.60 X-Spam-Checker-Version: SpamAssassin 2.60 (1.212-2003-09-23-exp) on silver.tanimura.dyndns.org cc: Seigo Tanimura Subject: Re: Who should set the priority of a select(2)ing thread being waken up? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Nov 2003 13:03:47 -0000 [posted to -current as well, because there were no replies in -arch] On Wed, 22 Oct 2003 19:21:46 +0900, Seigo Tanimura said: tanimura> In good old days, only a socket and a pipe were the major file tanimura> descriptors being select(2)ed. As select(2) was just a socket tanimura> operation, it was sufficient to set the priority of select(2)ing tanimura> process to PSOCK(*1), I suppose. tanimura> Nowadays, quite a few drivers support select(2) as well, including tanimura> sound, usb, scsi controllers, and so on. I am not convinced whether a tanimura> process should select(2) those devices at PSOCK as we do for a socket. tanimura> Suppose that a process select(2)s for a pcm device and a socket at tanimura> once. If the process is waken up by the pcm driver at PSOCK, another tanimura> process at a better priority may preempt the first one, which can tanimura> result in dropping some pcm data. tanimura> Maybe it would be better if the caller of selwakeup() could determine tanimura> the priority of a process or a thread. That would let us raise the tanimura> priority to PRIBIO if pcm data was ready, while the priority would tanimura> stay at PSOCK if the socket was ready. tanimura> (*1) I broke that in 5-CURRENT when I modified select(2) and poll(2) tanimura> to use a conditional variable. tanimura> The attached patch implements selwakeuppri(), which lets you set the tanimura> priority of a thread being waken up. Also in the patch is a small tanimura> test code to use selwakeuppri() in pcm(4). (patch snipped) The updated patch at: http://people.freebsd.org/~tanimura/selwakeuppri.diff.gz converts all selwakeup()s into selwakeuppri()s with appropriate priorities. Old selwakeup() is left, but I may axe it. Any objections if I commit the patch in a week? -- Seigo Tanimura