From owner-freebsd-arch Thu Sep 13 17:56: 5 2001 Delivered-To: freebsd-arch@freebsd.org Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id 5E8AD37B407 for ; Thu, 13 Sep 2001 17:56:02 -0700 (PDT) Received: (from eischen@localhost) by pcnet1.pcnet.com (8.8.7/PCNet) id UAA04029; Thu, 13 Sep 2001 20:54:53 -0400 (EDT) Date: Thu, 13 Sep 2001 20:54:53 -0400 (EDT) From: Daniel Eischen To: Alfred Perlstein Cc: mike varga , freebsd-arch@FreeBSD.ORG Subject: Re: FD_LOCK, pthreads and drivers In-Reply-To: <20010913183028.P968@elvis.mu.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 13 Sep 2001, Alfred Perlstein wrote: > * mike varga [010913 17:41] wrote: > > I noticed that while testing the driver I wrote > > for a crypto device, that only one thread > > can be executing within the context of > > my driver at a time. > > > > The problem is that the pthreads library > > replaces the ioctl with another that exclusively > > locks the file descriptor with calls to FD_LOCK/ > > FD_UNLOCK. This isn't true for -current. I removed automatic locking of file descriptors many months ago. > > Why? Indeed, it should be up to the application to provide protection for I/O operations on the same file descriptor :-) Or at least the threads library should stay out of the way and let the application and kernel decide... > > I went to extremes to make sure that it > > would be fully reentrant. > > The driver/crypto accelerator now suffers > > from slow performance. > > Under the native FreeBSD threading model there is only one > process context. You'll want to use the linuxthreads port > to do this. You can have multiple I/O requests within libc_r, but they are all converted to non-blocking requests and the thread scheduler periodically polls for I/O completion. If your device driver doesn't support non-blocking operations, then our threads library isn't going to help you much even in -current where FD locking is disabled. -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message