[Mono-dev] GC stop world stopping audio threads

Robert Jordan robertj at gmx.net
Wed Jun 4 10:13:23 EDT 2008

Zoltan Varga wrote:
> Hi,
> AFAIK, the GC only stops threads which are registered with it. This
> can happen in
> the following ways:
> - threads started by the runtime are registered automatically
> - threads registered using mono_thread_attach ().
> - on unix, if an application includes gc.h, the header file will
> redefine pthread_create
>  () etc. with gc specific versions which register threads
> - on windows, the gc registers all threads automatically.

One more:

- threads detected when a managed delegate is called by
unmanaged code from a thread that was not already attached.

These all together assure that the runtime is never executed
on a non-registered thread. It also means that on unix
you can have unregistered threads as long as the conditions
above are never met.

On Windows, only threads started after mono.dll was loaded
are registered. This means that it's still possible to
create unregistered threads, as long as the other conditions
are never met.


> Under what OS you experience this ? BTW, the problem with not
> registering threads
> with the GC is that threads suspended by the GC could hold locks etc.,
> so if another
> thread tries to use these locks (like the malloc lock), it will be
> suspended anyway.
> Also, if one of these unsuspended threads tries to register itself or enter the
> runtime while the word is suspended, various complex situations could occur.
>                                                               Zoltan
> On Wed, Jun 4, 2008 at 2:41 PM, Joachim Ante <joe at unity3d.com> wrote:
>> Hi,
>> When the GC is under stress because a lot of managed allocations
>> happen we get sound stuttering.
>> It seems very likely that the GC is doing that when it calls Stop
>> World on all other threads.
>> Is there any way to make the Garbage collector only stop threads
>> which are registered using mono_thread_attach?
>> Best regards,
>> Joachim Ante
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list

More information about the Mono-devel-list mailing list