I am working on a project that mixes CIL code with natively compiled C
and C++ in a multi-threaded environment.  The natively compiled code may
make calls into the CIL universe from different threads, and I am trying
to figure out how to manage that with Mono's C API.  In the
documentation about embedding Mono, I see a reference to the function
mono_thread_attach().  My (very preliminary) testing has allowed me to
make a call from a native thread other than the primordial thread into
the CIL universe by calling mono_thread_attach() first.  I pass in a
pointer to a MonoDomain object allocated on the heap by the calling
thread via mono_domain_create().

After the call into the CIL code returns, however, I appear to get into
a deadlock state later when I make another call to
mono_thread_attach().  I have successfully dealt with a similar
situation using Python/C where the Global Interpreter Lock (GIL) must be
acquired and released to allow native code threads to call into the
Python interpreter.  I am wondering if calling mono_thread_attach() has
the effect of acquiring a mutex somewhere that needs to be released by
my code when I no longer need to hold it.  Is that the case?  If so,
what is the call to make this happen?  Or am I just on the wrong track
entirely?

Lastly, is there any documentation for doing multi-threaded programming
with Mono?  So far, I have mostly been looking through the code trying
to find types and functions that look roughly like what I need.

 -Patrick


-- 
Patrick L. Hartling                     | Research Assistant, VRAC
[EMAIL PROTECTED]                | 2274 Howe Hall Room 2624
http://www.vrac.iastate.edu/~patrick/   | http://www.vrac.iastate.edu/
PGP: http://wwwkeys.gpg.cz:11371/pks/lookup?op=get&search=0xEBF86398

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to