Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jul 2000 17:49:17 -0500
From:      "Richard Seaman, Jr." <dick@tar.com>
To:        Tan Juay Kwang <tanjk@i-dns.net>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: pthreads on 4.0-STABLE
Message-ID:  <20000720174917.D404@tar.com>
In-Reply-To: <NEBBLKHLGDECFCNMHPEECEMPCOAA.tanjk@i-dns.net>; from tanjk@i-dns.net on Thu, Jul 20, 2000 at 03:30:31PM %2B0800
References:  <NEBBLKHLGDECFCNMHPEECEMPCOAA.tanjk@i-dns.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000720174917.D404>