From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA24414; Fri, 18 Apr 2003 15:01:55 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA24224 for ; Fri, 18 Apr 2003 15:01:54 +0200 (MET DST) Received: from inria.fr (macaque.inria.fr [128.93.8.158]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h3ID1rX17788 for ; Fri, 18 Apr 2003 15:01:54 +0200 (MET DST) Date: Fri, 18 Apr 2003 15:02:38 +0200 Subject: Re: [Caml-list] OCaml signal handlers (Sys.signal) and C code Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v551) From: Damien Doligez To: Content-Transfer-Encoding: 7bit In-Reply-To: <20030418084135.GA7689@lordsoth.takhisis.org> Message-Id: <07E552C9-719E-11D7-B4BD-0003930FCE12@inria.fr> X-Mailer: Apple Mail (2.551) X-Spam: no; 0.00; damien:01 caml-list:01 invocation:01 callbacks:01 threads:01 ocaml:01 caml:01 blocking:01 doligez:01 inner:02 overhead:03 heap:03 wrote:03 zacchiroli:03 sys:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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