From: Markus Mottl <markus.mottl@gmail.com>
To: "Daniel Bünzli" <daniel.buenzli@epfl.ch>
Cc: caml-list caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] C-threads & callbacks
Date: Thu, 20 Jan 2005 14:23:38 -0500 [thread overview]
Message-ID: <20050120192338.GC4919@quant3.janestcapital.quant> (raw)
In-Reply-To: <4D24C0F4-6B15-11D9-9ECD-000393DBC266@epfl.ch>
Daniel Bünzli schrieb am Donnerstag, den 20. Jänner 2005:
> I don't understand what you are refering to. I don't think there's a
> problem as long as you take care to acquire ocaml's global lock to
> exectue the callbacks.
>
> #include <caml/signals.h>
> ...
> caml_leave_blocking_section();
> callback(*caml_named_value("myfun"), Val_unit);
> caml_enter_blocking_section();
> ...
>
> This ensures that callbacks into caml are properly serialized.
This only works if the callback is performed by a thread that was
spawned by OCaml (i.e. OCaml -> C -> OCaml). In this case the runtime
knows what the "current thread" is. But if a C-thread executes
"caml_leave_blocking_section" (C -> OCaml), it can segfault there,
because there may be no "current thread". And if there is, it is not
the C-thread but another currently executing OCaml-thread, which will
mess things up later.
That's why there should be some way to register a C-thread with the
OCaml-runtime. Currently this does not seem to be possible without
hacking the OCaml-implementation.
Regards,
Markus
--
Markus Mottl markus.mottl@gmail.com http://www.ocaml.info
next prev parent reply other threads:[~2005-01-20 19:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-20 18:23 Markus Mottl
2005-01-20 18:58 ` [Caml-list] " Daniel Bünzli
2005-01-20 19:23 ` Markus Mottl [this message]
2005-01-20 19:37 ` Alex Baretta
2005-01-20 20:19 ` Markus Mottl
2005-01-21 1:16 ` SooHyoung Oh
2005-01-21 6:42 ` Alex Baretta
[not found] ` <200501211042.31749.vincenzo_mlRE.MOVE@yahoo.it>
2005-01-24 20:00 ` Markus Mottl
2005-01-30 10:19 ` [Caml-list] " Xavier Leroy
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=20050120192338.GC4919@quant3.janestcapital.quant \
--to=markus.mottl@gmail.com \
--cc=caml-list@inria.fr \
--cc=daniel.buenzli@epfl.ch \
/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