From owner-freebsd-questions Thu Jul 20 15:49:24 2000 Delivered-To: freebsd-questions@freebsd.org Received: from ns.tar.com (ns.tar.com [204.95.187.2]) by hub.freebsd.org (Postfix) with ESMTP id 7426737B515 for ; Thu, 20 Jul 2000 15:49:19 -0700 (PDT) (envelope-from dick@tar.com) Received: from test.tar.com (test [204.95.187.4]) by ns.tar.com (8.9.3/8.9.3) with ESMTP id RAA64727; Thu, 20 Jul 2000 17:49:18 -0500 (CDT) (envelope-from dick@tar.com) Received: by test.tar.com (Postfix, from userid 1000) id C02CC81D4E; Thu, 20 Jul 2000 17:49:17 -0500 (CDT) Date: Thu, 20 Jul 2000 17:49:17 -0500 From: "Richard Seaman, Jr." To: Tan Juay Kwang Cc: freebsd-questions@FreeBSD.ORG Subject: Re: pthreads on 4.0-STABLE Message-ID: <20000720174917.D404@tar.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: ; from tanjk@i-dns.net on Thu, Jul 20, 2000 at 03:30:31PM +0800 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Jul 20, 2000 at 03:30:31PM +0800, Tan Juay Kwang wrote: > Hi, I've got some questions regarding pthreads programming on the FBSD > 4.0-STABLE platform. I've 2 scenarios which I hope somebody can help me > out. [snip] > The second involves creating a thread that will block on a file I/O. > According to materials which I've read, a call to open a named pipe read > only will block until some other process opens it for writing. So the > scenario is that I've a main thread that uses pthread_create to spawn > another thread which will block on such an I/O, ie on the open(2) system > call. The anomaly is that the pthread_create does not return until that > I/O is completed. The call returns when I explicitly writes something to > it. The thread does more then just trying to open a file, but that is the > only point where it will block indefinitely. I tried the same thing on > RedHat 6.2 and it all works fine. I haven't try it on Solaris though. I've looked briefly at the FreeBSD user thread code, and I don't see that its designed to handle blocking open()s. I suggest you submit a pr (see send-pr(1)) about this. What happens if you specify the O_NONBLOCK flag in the open()? If you don't get an error return, possibly you can use poll(2) or select (2) to wait for data to read. Poll() and select() should handle blocking ok accross threads. -- Richard Seaman, Jr. email: dick@tar.com 5182 N. Maple Lane phone: 262-367-5450 Nashotah WI 53058 fax: 262-367-5852 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message