On Wed, Aug 08, 2001 at 03:36:53PM -0700, Archie Cobbs wrote:
> Takashi Ishihara wrote:
> > Ok, so I have to use pth_select or pht_poll.
> > (simply putting pth_yield or pth_sleep did not work).
> > This makes code messy tho'. Is there any better (simple and clean) way?
>
> Sure... turn off non-blocking and create a separate thread for each
> I/O flow. Then each thread can block on it's own I/O flow.
Wait... I thought blocking I/O, which is default, will block the entire
process; not just the thread. In other words, I thought
int port;
pth_fdmode(port, PTH_FDMODE_BLOCK); /* by default (blocking is on) */
pth_read(port, buf, siziof(buf)); /* or pth_recv(..) */
pth_yield(NULL);
// pt1
pth_write(port, buff); /* or pth_send(..) */
pth_yield(NULL);
// pt2
does not improve the performance because both pth_yield mean nothing to do
with concurrency around I/O operation.
If I am wrong, i.e. pt1 and pt2 can take advantage of the concurrency,
then this is great. But then, I don't have to enable non-blocking mode to
the local file reading (as it won't improve the performance)...
I hope I am wrong. Would you confirm this? Thanks.
> In other words, if you're going to set your fd's to non-blocking and
> use pth_select() and pth_poll(), why are you bothering to use threads
> in the first place? One great advantage of threading is so you don't
> have to do that.
Exactly. I worried about messing up my src. It's fairly clean for now,
but I'm sure it'll be messier after putting pth_select for each I/O operation.
I'm writing a web server using pth; main goal is 1. good performance (as good
as Boa) 2. better/cleaner coding (Boa mess around select, so the src is not
pretty IMHO). If read from network port is set to non-blocking, using
pth_select would be the reasonable way to work around -1 (EWOULDBLOCK).
but if pth really multiplexes I/O automatically (even with blocking mode),
the it's really great. Please verify this. thans.
--
Takashi Ishihara http://wwwcsif.cs.ucdavis.edu/~ishihara
;; The first precept was never to accept a thing as true until I knew it
;; as such without a single doubt. (Rene Descartes, 1637)
______________________________________________________________________
GNU Portable Threads (Pth) http://www.gnu.org/software/pth/
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager (Majordomo) [EMAIL PROTECTED]