From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id B8CB6BC0A for ; Tue, 17 Apr 2007 16:40:32 +0200 (CEST) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l3HEeW4d017547 for ; Tue, 17 Apr 2007 16:40:32 +0200 Received: from [84.59.118.255] (helo=gate.lan.gerd-stolpmann.de) by mrelayeu.kundenserver.de (node=mrelayeu8) with ESMTP (Nemesis), id 0ML31I-1Hdor30CdQ-0005zc; Tue, 17 Apr 2007 16:40:25 +0200 Received: from flakew.lan.gerd-stolpmann.de (fw.lan.gerd-stolpmann.de [192.168.1.1]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id B40BBC178; Tue, 17 Apr 2007 16:40:24 +0200 (CEST) Subject: Re: [Caml-list] Interfacing C-code with ocaml and Exception handling From: Gerd Stolpmann To: Christian Sternagel Cc: caml-list@yquem.inria.fr In-Reply-To: <20070417135613.GE3368@pc6197-c703.uibk.ac.at> References: <20070417113557.GC3368@pc6197-c703.uibk.ac.at> <1176811379.2316.13.camel@localhost.localdomain> <20070417135613.GE3368@pc6197-c703.uibk.ac.at> Content-Type: text/plain Date: Tue, 17 Apr 2007 16:40:23 +0200 Message-Id: <1176820824.2316.32.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Provags-ID: V01U2FsdGVkX1+eMEPBcl30UtZ3sKy04gYAO6omZE/TjuxPGkh c5OWRCxvla6hpvWteTARCHh2FBZejw63I99W6tsMWHtEMi+D4L wTkbycW92L0Ub5I/SSG2CuxdUxsXEhg X-Miltered: at concorde with ID 4624DC60.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; interfacing:01 ocaml:01 gerd:01 stolpmann:01 defines:01 o'caml:01 o'caml:01 solver:01 unblock:01 solver:01 gerd:01 cheers:01 beginner's:01 ocaml:01 bug:01 > > > Is this theory correct and are there any suggestions how to work around this problem (implementing timed execution of arbitrary code). > > > > Arbitrary code? No way to make that happen. For specific cases: yes, > > there are many ways to do it. > I don't really need that for arbitraty code. Our tool calls a stub-function that executes C-code of a SAT-Solver. And I want to make sure, that this function stops after a certain timeout. Are there any suggestions? Maybe this works: - Create a new C function set_timeout_handler that defines the signal handler. The handler is another C function timeout_handler. - In O'Caml, only do: * block SIGALRM (so O'Caml never sees this signal) * Start the itimer - Change the C code of the SAT solver as follows. Before it starts, unblock SIGALRM, so this signal can be delivered. Then define an exit with sigsetjmp. - In timeout_handler, just siglongjump out of the solver to the previously defined exit. SIGALRM should be blocked again, before returning to O'Caml. Complicated, isn't it, but if a signal is the only way to stop the solver, the handler must be defined in C. Gerd > cheers > > christian > > > > Gerd > > > > > > > > thnx in advance > > > > > > christian > > > > > > _______________________________________________ > > > Caml-list mailing list. Subscription management: > > > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > > > Archives: http://caml.inria.fr > > > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > > > Bug reports: http://caml.inria.fr/bin/caml-bugs > > > > > -- > > ------------------------------------------------------------ > > Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany > > gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de > > Phone: +49-6151-153855 Fax: +49-6151-997714 > > ------------------------------------------------------------ > > > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------