From: Michael Hicks <mwh@dsl.cis.upenn.edu>
To: caml-list@inria.fr
Subject: thread i/o
Date: Tue, 12 Jan 1999 15:12:32 -0500 (EST) [thread overview]
Message-ID: <199901122012.PAA16699@codex.cis.upenn.edu> (raw)
One of the adverisements of OCaml 2.01 was that user-level (not POSIX)
thread I/O is made faster. The trick used in the implementation is to make
sockets non-blocking, and then only perform a select() when the I/O would
have blocked (by signalling EINTR or EWOULDBLOCK). However, looking at the
implementation, it looks like in many cases the select() is performed
anyway. Here is an excerpt from threadUnix.ml:
let rec read fd buff ofs len =
Thread.wait_read fd;
try Unix.read fd buff ofs len
with Unix_error((EAGAIN | EWOULDBLOCK), _, _) -> read fd buff ofs len
The implementation of Thread.wait_read and Thread.wait_write will perform
either a select() or go through the scheduler which will perform the
select(). It seems to me that the implementation should be:
let rec read fd buff ofs len =
try Unix.read fd buff ofs len
with Unix_error((EAGAIN | EWOULDBLOCK), _, _) ->
begin
Thread.wait_read fd;
read fd buff ofs len
end
This way, if I/O is already available, there is no need to do the extra
select(). Am I missing something?
Mike
--
Michael Hicks
Ph.D. Candidate, the University of Pennsylvania
http://www.cis.upenn.edu/~mwh mailto://mwh@dsl.cis.upenn.edu
"I worked with an individual who plugged his power strip back into itself
and for the life of him could not understand why his computer would not
turn on."
next reply other threads:[~1999-01-13 11:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-01-12 20:12 Michael Hicks [this message]
1999-01-13 13:20 ` Xavier Leroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199901122012.PAA16699@codex.cis.upenn.edu \
--to=mwh@dsl.cis.upenn.edu \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox