What existing CLR hosts do not provide one-to-one mapping between managed and unmanaged threads?

Posted on

Problem :

I know I should not rely upon that there is one-to-one mapping between managed and unmanaged threads. From MSDN:

An operating-system ThreadId has no fixed relationship to a managed thread, because an unmanaged host can control the relationship between managed and unmanaged threads. Specifically, a sophisticated host can use the Fiber API to schedule many managed threads against the same operating system thread, or to move a managed thread among different operating system threads.

In real life though, do such CLR hosts exist? (and if so, what are they?) I just answered a related question, and I wonder how practically bad my advice was for that particular case.

Solution :

One would or could have been Microsoft SQL Server (starting with version 2005). IIRC that particular hosting support was even built into the CLR 2.0 upon their request (also see this blog post for more background), so that they could also support the CLR when using fibers (aka user mode scheduling) instead of threads in SQL Server.

However, that never really did work, it seems (source):

Common language runtime (CLR) execution is not supported under
lightweight pooling. Disable one of two options: “clr enabled” or
“lightweight pooling.

I would consider it rather safe to assume that there are no (production ready) hosts out there, that don’t map CLR threads to host threads 1:1.

There are a couple of Q&A around SO that seem to suggest the same.

For example,

Leave a Reply

Your email address will not be published. Required fields are marked *