caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Damien Doligez <Damien.Doligez@inria.fr>
To: <caml-list@inria.fr>
Subject: Re: [Caml-list] OCaml signal handlers (Sys.signal) and C code
Date: Fri, 18 Apr 2003 15:02:38 +0200	[thread overview]
Message-ID: <07E552C9-719E-11D7-B4BD-0003930FCE12@inria.fr> (raw)
In-Reply-To: <20030418084135.GA7689@lordsoth.takhisis.org>

On Friday, April 18, 2003, at 10:41 AM, Stefano Zacchiroli wrote:

> Your "in any way" include also read only access (e.g. "Field" 
> invocation
> on a caml value allocated outside the blocking section), right?

Right.

> If this is the case I'm a bit concerned about performances. I have a
> piece of C code, invoked by OCaml, that access caml values inside a
> loop. To convert this code so that it can be interrupted by ocaml
> callbacks I have to enter blocking before each access and exit
> afterwards.

Actually, you have to leave blocking before the access and enter 
afterwards.


>  Is this entering/existing time consuming?

Unless you use threads, this is only one C function call, two tests,
and three assignments.  Not very time consuming, but you still don't
want to do it within an inner loop.

If this is too much overhead, here is what I would recommend.
Instead of calling leave_blocking_section and enter_blocking_section
around each heap access, you can treat the pair of calls:
    enter_blocking_section ();
    leave_blocking_section ();
as a way to poll for signals.  It will test for any pending signals
and call the handlers immediately.  If you call it once every 100 or
1000 loop executions, the overhead should be quite small.

-- Damien

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-04-18 13:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-04 16:56 Stefano Zacchiroli
2003-04-16 19:16 ` Xavier Leroy
2003-04-18  8:41   ` Stefano Zacchiroli
2003-04-18 13:02     ` Damien Doligez [this message]
2003-04-18 18:04   ` Stefano Zacchiroli

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=07E552C9-719E-11D7-B4BD-0003930FCE12@inria.fr \
    --to=damien.doligez@inria.fr \
    --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;
as well as URLs for NNTP newsgroup(s).