summaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorFlorian Angeletti <florian.angeletti@inria.fr>2022-12-15 11:29:54 +0100
committerFlorian Angeletti <florian.angeletti@inria.fr>2022-12-19 17:27:40 +0100
commit0f992b943e066193f38d0aa9da675d59166e79ca (patch)
treee869cde5b708d095f7eb1eda85e4ffb73e6df053 /manual
parentbe210179503c4a82b72dd4762560e13c408d37b7 (diff)
downloadocaml-0f992b943e066193f38d0aa9da675d59166e79ca.tar.gz
Merge pull request #11813 from edwintorok/5.0-docs
5.0 docs: Make new multicore chapters easier to discover, and emphasize impact on C bindings (cherry picked from commit 5f856479c79900c42525543677609b78a2032131)
Diffstat (limited to 'manual')
-rw-r--r--manual/src/cmds/intf-c.etex1
-rw-r--r--manual/src/tutorials/parallelism.etex10
2 files changed, 11 insertions, 0 deletions
diff --git a/manual/src/cmds/intf-c.etex b/manual/src/cmds/intf-c.etex
index d1473fcf09..fcdaf2453c 100644
--- a/manual/src/cmds/intf-c.etex
+++ b/manual/src/cmds/intf-c.etex
@@ -2433,6 +2433,7 @@ When OCaml calls the C code implementing a primitive, the domain lock
is held, therefore the C code has full access to the facilities of the
run-time system. However, no other thread in the same domain can execute
OCaml code concurrently with the C code of the primitive.
+See also chapter~\ref{s:par_c_bindings} for the behaviour with multiple domains.
If a C primitive runs for a long time or performs potentially blocking
input-output operations, it can explicitly release the domain lock,
diff --git a/manual/src/tutorials/parallelism.etex b/manual/src/tutorials/parallelism.etex
index 127335b8ab..1d41cb9035 100644
--- a/manual/src/tutorials/parallelism.etex
+++ b/manual/src/tutorials/parallelism.etex
@@ -594,6 +594,16 @@ systhread identifiers uniquely identify systhreads in the program. The initial
domain gets the domain id and the thread id as 0. The newly spawned domain gets
domain id as 1.
+\section{s:par_c_bindings}{Interaction with C bindings}
+
+During parallel execution with multiple domains, C code running on a domain may
+run in parallel with any C code running in other domains even if neither of
+them has released the ``domain lock''. Prior to OCaml 5.0, C bindings may have
+assumed that if the OCaml runtime lock is not released, then it would be safe
+to manipulate global C state (e.g. initialise a function-local static value).
+This is no longer true in the presence of parallel execution with multiple
+domains.
+
\section{s:par_atomics}{Atomics}
Mutex, condition variables and semaphores are used to implement blocking