Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamlnet and kernel poll
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus.mottl@g...>
Subject: Re: [Caml-list] ocamlnet and kernel poll
On Thu, Sep 11, 2008 at 11:43 AM, Joel Reymont <joelr1@gmail.com> wrote:
> Are you suggesting using multiple OS threads within a single process?

Yes.

> When exactly do you release the lock and how do you perform IO outside of
> it?
>
> How do you determine whether to release the lock or not?

Look at our Core-library.  It contains a module "Bigstring", which
provides many efficient I/O-functions for those.  Look at
"bigstring_stubs.c", where you'll see how these functions are
implemented in C-land, e.g. when the lock gets released, etc.

There are functions like e.g. "read_assume_nonblocking", which one can
use if one knows for sure that a read cannot block (e.g. after a
"select").  Then the function determines whether it's worth/necessary
releasing the lock.

If, for example, the read is performed into a bigstring which happens
to be a memory-mapped file, then the lock will always be released,
because if the memory page happens to be on disk you might otherwise
experience latency spikes when it's being paged in, since all other
threads would temporarily freeze.  Same for very large I/O-operations:
there the lock would be released, too, to exploit parallelism, improve
throughput, and avoid latency spikes.

Regards,
Markus

-- 
Markus Mottl http://www.ocaml.info markus.mottl@gmail.com