[Mono-dev] [PATCHES] Improve process exit/wait handling

Rodrigo Kumpera kumpera at gmail.com
Thu Mar 17 07:27:11 EDT 2011

Hi Rolf,

Reviewing *0004-io-layer-Improve-waiting-on-processes-a-lot.patch:*
+ // Ensure we're not in here in multiple threads at once, nor recursive.
+ if (InterlockedIncrement (&mono_processes_cleaning_up) > 1) {
+ InterlockedDecrement (&mono_processes_cleaning_up);
Use the standard idiom of CAS (&zzz, 0, 1) instead of doing 2 atomic ops.

+ if (mono_processes_soft_lock != 0) {
+ /* The sigchld handler is watching us. Spin a bit and try again */
+ _wapi_handle_spin (1);
+ } else {

This code doesn't make much sense to me. You spin with
the mono_processes_mutex lock held
only to drop it later to reacquire straight away. You must use an
exponential backoff since the other
thread might be blocked for a significant amount of time.

Overall the patch is ok, thou I have two comments, first that the style of
reclamation is kludgy, we
would be better with SMR; second that, if I understand correctly, we only
free process data when its
managed object is collected or another process is spawned, right?

On other notes, your code mixes C and C++ styles comments, stick with C
style, please. You're
not following our code conventions in a few places too:

+static void mono_processes_cleanup (void)

Should be:
static void
mono_processes_cleanup (void)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20110317/32bc9f2a/attachment.html 

More information about the Mono-devel-list mailing list