From: Samuel Mimram <samuel.mimram@ens-lyon.org>
To: Caml List <caml-list@inria.fr>
Subject: interaction between *_blocking_section and value
Date: Wed, 02 Mar 2005 23:32:03 +0100 [thread overview]
Message-ID: <42263EE3.6020701@ens-lyon.org> (raw)
Hello,
I'd like to have some clarifications about the interaction between
threads and the GC in C bindings.
As far as I understand the CAMLparam and CAMLlocal macros prevent values
from being garbage-collected i.e.
1. being completely removed from memory,
2. being *moved*
during the whole scope of the C function (am I right?).
I have received a mail concerning one of my programs which was telling
me that this is not true when in blocking sections, and that values can
be moved by the GC. Is it the case? Consider the following code:
CAMLprim value caml_send(value data)
{
CAMLparam1(data);
enter_blocking_section();
send(0, String_val(data), string_length(data));
leave_blocking_section();
CAMLreturn(Val_unit);
}
Is it safe or can the String_val(data) point to an invalid portion of
memory because data have been move by the GC because of the
enter_blocking_section()?
Also, it would be nice if the *_blocking_section() could be explained in
the documentation.
Thanks.
Regards,
Samuel.
next reply other threads:[~2005-03-02 22:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-02 22:32 Samuel Mimram [this message]
2005-03-03 0:28 ` [Caml-list] " David Brown
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=42263EE3.6020701@ens-lyon.org \
--to=samuel.mimram@ens-lyon.org \
--cc=caml-list@inria.fr \
/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