Browse thread
Interfacing C-code with ocaml and Exception handling
-
Christian Sternagel
-
Gerd Stolpmann
-
Christian Sternagel
- Gerd Stolpmann
-
Christian Sternagel
-
Gerd Stolpmann
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Gerd Stolpmann <info@g...> |
| Subject: | Re: [Caml-list] Interfacing C-code with ocaml and Exception handling |
> > > 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 ------------------------------------------------------------