From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Christian Sternagel <christian.sternagel@uibk.ac.at>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Interfacing C-code with ocaml and Exception handling
Date: Tue, 17 Apr 2007 16:40:23 +0200 [thread overview]
Message-ID: <1176820824.2316.32.camel@localhost.localdomain> (raw)
In-Reply-To: <20070417135613.GE3368@pc6197-c703.uibk.ac.at>
> > > 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
------------------------------------------------------------
prev parent reply other threads:[~2007-04-17 14:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-17 11:35 Christian Sternagel
2007-04-17 12:02 ` [Caml-list] " Gerd Stolpmann
2007-04-17 13:56 ` Christian Sternagel
2007-04-17 14:40 ` Gerd Stolpmann [this message]
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=1176820824.2316.32.camel@localhost.localdomain \
--to=info@gerd-stolpmann.de \
--cc=caml-list@yquem.inria.fr \
--cc=christian.sternagel@uibk.ac.at \
/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