[m-rev.] for review: threads and fork()
Peter Wang
wangp at students.cs.mu.OZ.AU
Thu Mar 23 23:21:32 AEDT 2006
Estimated hours taken: 1
Branches: main
compiler/process_util.m:
Disable forking by `mmc --make' if built in a parallel grade as
threads and fork() do not mix.
Index: compiler/process_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/process_util.m,v
retrieving revision 1.18
diff -u -r1.18 process_util.m
--- compiler/process_util.m 28 Nov 2005 04:11:51 -0000 1.18
+++ compiler/process_util.m 23 Mar 2006 12:19:37 -0000
@@ -292,7 +292,16 @@
can_fork,
[will_not_call_mercury, thread_safe, promise_pure],
"
-#ifdef MC_CAN_FORK
+ /*
+ ** call_in_forked_process_2 is not `thread_safe' so will hold a mutex
+ ** that the child process will want. At the same time the parent process
+ ** waits for the child to exit, so we have a deadlock.
+ **
+ ** Also, in pthreads, a forked process does not inherit the threads of
+ ** the original process so it is not at all clear whether we could use
+ ** fork() when running in a parallel grade.
+ */
+#if (defined MC_CAN_FORK) && (!defined MR_THREAD_SAFE)
SUCCESS_INDICATOR = MR_TRUE;
#else
SUCCESS_INDICATOR = MR_FALSE;
I did try marking call_in_forked_process_2 as `thread_safe', which
worked well enough to build hello_world, but it seems dodgy and will
likely break if there is actually more than one thread.
Peter
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list