mingw-cross-env-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mingw-cross-env-list] Solving the Pthreads issue


From: Martin Lambers
Subject: Re: [Mingw-cross-env-list] Solving the Pthreads issue
Date: Mon, 3 May 2010 22:27:03 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

On Mon, 03. May 2010, 15:07:53 +0200, Volker Grabsch wrote:
> The above mentioned dead-lock is caused by the Pthreads-w32
> library, which is a very old library and doesn't always work
> well. It provides a Pthreads-compatible POSIX layer around
> the Win32 threading API.

To use the pthread API both on Linux and on W32 via Mingw-cross-env, I
had to do the following in my application for each thread function that
is given to pthread_create():

void *thread_function(void *ptr)
{
#ifdef PTW32_STATIC_LIB
    pthread_win32_thread_attach_np();
#endif

    ... do the work ...

#ifdef PTW32_STATIC_LIB
    pthread_win32_thread_detach_np();
#endif
    return NULL;
}

These extra calls are probably missing in most libraries or applications
that use pthreads, because they are not necessary on POSIX systems.
Maybe this is one reason for the failures that were observed on this
list. 

With these extra calls, I never had trouble with Pthreads-w32. But I only
use basic pthread features, so that may not mean much.

Martin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]