From owner-freebsd-hackers@FreeBSD.ORG Wed May 21 09:24:36 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B230D37B401 for ; Wed, 21 May 2003 09:24:36 -0700 (PDT) Received: from srv1.cosmo-project.de (srv1.cosmo-project.de [213.83.6.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id C2DFC43FAF for ; Wed, 21 May 2003 09:24:34 -0700 (PDT) (envelope-from ticso@cicely12.cicely.de) Received: from cicely5.cicely.de (cicely5.cicely.de [IPv6:3ffe:400:8d0:301:200:92ff:fe9b:20e7]) by srv1.cosmo-project.de (8.12.9/8.12.9) with ESMTP id h4LGO2rN018084 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Wed, 21 May 2003 18:24:20 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (cicely12.cicely.de [IPv6:3ffe:400:8d0:301::12]) by cicely5.cicely.de (8.12.9/8.12.9) with ESMTP id h4LGNqOs014901 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 May 2003 18:23:52 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: from cicely12.cicely.de (localhost [127.0.0.1]) by cicely12.cicely.de (8.12.9/8.12.9) with ESMTP id h4LGNpPY089251; Wed, 21 May 2003 18:23:51 +0200 (CEST) (envelope-from ticso@cicely12.cicely.de) Received: (from ticso@localhost) by cicely12.cicely.de (8.12.9/8.12.9/Submit) id h4LGNecQ089250; Wed, 21 May 2003 18:23:40 +0200 (CEST) Date: Wed, 21 May 2003 18:23:40 +0200 From: Bernd Walter To: Terry Lambert Message-ID: <20030521162339.GL21312@cicely12.cicely.de> References: <3ECB041D.4FE961D@mindspring.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3ECB041D.4FE961D@mindspring.com> X-Operating-System: FreeBSD cicely12.cicely.de 5.1-BETA alpha User-Agent: Mutt/1.5.4i cc: freebsd-hackers@freebsd.org cc: Julian Elischer cc: Jay Cornwall Subject: Re: USB bulk read & pthreads X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: ticso@cicely.de List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 May 2003 16:24:37 -0000 On Tue, May 20, 2003 at 09:44:13PM -0700, Terry Lambert wrote: > Julian Elischer wrote: > > On Wed, 21 May 2003, Jay Cornwall wrote: > > > The problem seems to be a result of reading from a USB endpoint file > > > descriptor, which invokes tsleep() within the kernel > > > (/sys/dev/usb/usbdi_util.c:432) while it waits for data to read. This has the > > > effect of blocking the whole process, rather than just the thread which > > > called the read. > > > > You should load teh "linuxthreads" port > > and link with that.. > > > > under 5.x you will be able to use the native threads (we will have > > several to choose from :-) > > > > under 4.x (I presume that's what you are using) the threading is all in > > one process and if a device decides to return "data waiting" in select() > > but keeps the reader waiting, it will block the entire process. > > Or it's a bug in the USB driver, not honoring non-blocking I/O. ugen(4) does not support non-blocking I/O like most other driver also do not. I don't count it as a bug as noone ever told that it does. It's even documented in ugen(4): The bulk transfer mode can be in or out depending on the endpoint. To perform I/O on a bulk endpoint read(2) and write(2) should be used. All I/O operations on a bulk endpoint are unbuffered. non-blocking requires buffered I/O. The device gets regulary polled if someone has an outstanding transfer. Implementing nonblocking I/O would require always to have an outstanding read for open devices - similar is done in ucom(4). -- B.Walter BWCT http://www.bwct.de ticso@bwct.de info@bwct.de