[Mono-list] pthreads in mono

Andreas Färber andreas.faerber at web.de
Thu Mar 27 09:33:18 EDT 2008


Hi,

Am 27.03.2008 um 12:33 schrieb Chris Howie:

> On Thu, Mar 27, 2008 at 7:18 AM, Andreas Färber <andreas.faerber at web.de 
> > wrote:
>> You sure about that? Mono does use pthreads in some way, keeping it
>> from running on BeOS.
>>
>> Is getting a pointer to the current thread in native land or using p/
>> invoke not an option?
>>
>> Andreas
>
> [...]  However, you may be able to get
> a pointer to some other Thread object's pthread, but I would not be
> too sure that this can be done from Mono directly.
>
> You could use: [DllImport("pthread")] private static extern pthread_t
> pthread_self();
>
> However, you'd have to declare pthread_t somewhere,
using pthread_t = System.IntPtr; // for instance :)
> and this call
> would have to be executed from the other thread -- meaning you'd have
> to pass the return value over to the main thread and ... ugh.  A
> WaitHandle would undoubtedly be needed, and for what?
>
> Writing a ThreadStart that infinitely loops over a call to gps_poll
> sounds like a lot less work, no?

I didn't really care about libgps, never used it, so I can't tell.

I was just astonished by your saying, AFAYK, Mono didn't support  
pthreads, because:
* Mono links to it on many if not all non-Windows systems
* two years ago the LMF code was updated to cope with external pthread  
callbacks into managed code
* the 7.x branch of the Boehm GC appeared to have dropped support for  
non-posix threading packages

So are you implying there are some cases (apart from Windows) where a  
MonoThread/System.Threading.Thread is not a pthread but some non- 
pthread userland thread, like in Java IIRC? Or what did you mean by  
"doesn't support"?

Andreas


More information about the Mono-list mailing list