From owner-freebsd-hackers@FreeBSD.ORG Wed May 21 16:00:29 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 E371637B401 for ; Wed, 21 May 2003 16:00:29 -0700 (PDT) Received: from srv1.cosmo-project.de (srv1.cosmo-project.de [213.83.6.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9CFA243F3F for ; Wed, 21 May 2003 16:00:26 -0700 (PDT) (envelope-from ticso@cicely8.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 h4LN0GrN023522 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Thu, 22 May 2003 01:00:23 +0200 (CEST) (envelope-from ticso@cicely8.cicely.de) Received: from cicely8.cicely.de (cicely8.cicely.de [10.1.1.10]) by cicely5.cicely.de (8.12.9/8.12.9) with ESMTP id h4LN0COs016804 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); Thu, 22 May 2003 01:00:13 +0200 (CEST) (envelope-from ticso@cicely8.cicely.de) Received: from cicely8.cicely.de (localhost [127.0.0.1]) by cicely8.cicely.de (8.12.6/8.12.6) with ESMTP id h4LN0BFP031066; Thu, 22 May 2003 01:00:11 +0200 (CEST) (envelope-from ticso@cicely8.cicely.de) Received: (from ticso@localhost) by cicely8.cicely.de (8.12.6/8.12.6/Submit) id h4LN0BJp031065; Thu, 22 May 2003 01:00:11 +0200 (CEST) Date: Thu, 22 May 2003 01:00:11 +0200 From: Bernd Walter To: Jay Cornwall Message-ID: <20030521230010.GD30678@cicely8.cicely.de> References: <3ECB041D.4FE961D@mindspring.com> <20030521162339.GL21312@cicely12.cicely.de> <200305212245.h4LMjEGm006250@viper.evilrealms.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200305212245.h4LMjEGm006250@viper.evilrealms.net> X-Operating-System: FreeBSD cicely8.cicely.de 5.0-CURRENT i386 User-Agent: Mutt/1.5.1i cc: freebsd-hackers@freebsd.org cc: ticso@cicely.de 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 23:00:30 -0000 On Wed, May 21, 2003 at 11:44:46PM +0100, Jay Cornwall wrote: > On Wednesday 21 May 2003 17:23 pm, you wrote: > > > 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. > > Yes, blocking I/O isn't a problem for this application (as it's thread-based). The problem arises from ugen blocking the entire process, rather than just the thread which invoked the blocking read. It is a problem as non-blocking I/O is the only way for a userland scheduler to handle I/O based wait conditions. The scheduler silently converts blocking I/O to non blocking so it can reschedule instead of block. If instead the kernel blocks then the userland scheduler is just out of business. > This isn't consistent with normal blocking read behaviour AFAIK, and I just wondered if there was a reason it was implemented in this way, or if it was simply an oversight on the use of threading with the ugen device. Both parts are handled that way for good reasons. As others already wrote - you have to use a thread implementation which is not entirely based on userland scheduling. -- B.Walter BWCT http://www.bwct.de ticso@bwct.de info@bwct.de